这是运行后的结果(到 update android):
cordova plugin save
cordova platform remove android
cordova platform add android
这是我得到的错误,我认为这是版本值没有正确合并。
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-35:19 to override.
我已经遇到这个问题并研究了几天。
让我们看看,我只会分享我认为相关的内容,但如果需要更多信息。请告诉我:
config.xml
<platform name="android">
<allow-intent href="market:*" />
<preference name="android-minSdkVersion" value="19" />
<preference name="android-targetSdkVersion" value="28" />
...
</platform>
<plugin name="cordova-android-support-gradle-release" spec="^3.0.1">
<variable name="ANDROID_SUPPORT_VERSION" value="28.+" />
</plugin>
AndroidManifest.xml
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28"/>
我什至在我的 build.gradle 中尝试过这个(我在相关问题的答案中发现它似乎解决了 QO):
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '28.0.0'
}
}
}
}
问题是,如果我将所有 28
更改为 27
,那么 cordova build android
仍会显示 28:
cordova-android-support-gradle-release: Wrote custom version '28.+' to /Users/myuser/Proyectos/localhost/cordova/my-app/platforms/android/app/build.gradle
cordova-android-support-gradle-release: Wrote custom version '28.+' to /Users/myuser/Proyectos/localhost/cordova/my-app/platforms/android/cordova-android-support-gradle-release/my-cordova-android-support-gradle
所以我真的不知道接下来要尝试什么......有什么想法吗?
这是完整的回复:
cordova build android
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '28.+' to /Users/toniweb/Proyectos/localhost/cordova/my-app/platforms/android/app/build.gradle
cordova-android-support-gradle-release: Wrote custom version '28.+' to /Users/toniweb/Proyectos/localhost/cordova/my-app/platforms/android/cordova-android-support-gradle-release/my-cordova-android-support-gradle-release.gradle
Running command: /Users/toniweb/Proyectos/localhost/cordova/my-app/hooks/after_prepare/030_remove-permissions.js /Users/toniweb/Proyectos/localhost/cordova/my-app
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '28.+' to /Users/toniweb/Proyectos/localhost/cordova/my-app/platforms/android/app/build.gradle
cordova-android-support-gradle-release: Wrote custom version '28.+' to /Users/toniweb/Proyectos/localhost/cordova/my-app/platforms/android/cordova-android-support-gradle-release/my-cordova-android-support-gradle-release.gradle
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/toniweb/Library/Android/sdk (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app
> Configure project :app
+-----------------------------------------------------------------
| cordova-android-support-gradle-release: 28.+
+-----------------------------------------------------------------
> Task :app:preBuild UP-TO-DATE
> Task :CordovaLib:preBuild UP-TO-DATE
> Task :CordovaLib:preDebugBuild UP-TO-DATE
> Task :CordovaLib:checkDebugManifest UP-TO-DATE
> Task :CordovaLib:processDebugManifest UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :CordovaLib:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :CordovaLib:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript UP-TO-DATE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
> Task :CordovaLib:compileDebugRenderscript UP-TO-DATE
> Task :CordovaLib:generateDebugBuildConfig UP-TO-DATE
> Task :CordovaLib:generateDebugResValues UP-TO-DATE
> Task :CordovaLib:generateDebugResources UP-TO-DATE
> Task :CordovaLib:packageDebugResources UP-TO-DATE
> Task :CordovaLib:generateDebugRFile UP-TO-DATE
> Task :CordovaLib:prepareLintJar UP-TO-DATE
> Task :CordovaLib:generateDebugSources UP-TO-DATE
> Task :CordovaLib:javaPreCompileDebug UP-TO-DATE
> Task :CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
> Task :CordovaLib:processDebugJavaRes NO-SOURCE
> Task :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:processDebugManifest FAILED
/Users/toniweb/Proyectos/localhost/cordova/my-app/platforms/android/app/src/main/AndroidManifest.xml:22:18-91 Error:
Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-35:19 to override.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-35:19 to override.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
22 actionable tasks: 1 executed, 21 up-to-date
/Users/toniweb/Proyectos/localhost/cordova/my-app/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/toniweb/Proyectos/localhost/cordova/my-app/platforms/android/app/src/main/AndroidManifest.xml:22:18-91 Error:
Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-35:19 to override.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-35:19 to override.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
最佳答案
您的插件之一正在使用 Android X 依赖项,该依赖项与常规 Android 支持依赖项不兼容。
您必须搜索该插件并将其删除或使用未使用 Android X 依赖项的先前版本。
或者,使用在项目中启用 Android X 的 Cordova Android X 插件,并修补 Android X 等效项的插件依赖项和代码使用情况。
安装cordova-plugin-androidx
以启用Android X
cordova 插件添加 cordova-plugin-androidx
然后安装cordova-plugin-androidx-adapter
来修补现有插件
cordova 插件添加 cordova-plugin-androidx-adapter
并删除 cordova-android-support-gradle-release
以及任何尝试将支持版本强制为 28 的 gradle 代码,因为它将与 Android X 更改发生冲突。
关于android - Cordova 无法构建 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58507566/