Monday, 28 October 2019

Cordova fails to build Android

This is after running (to update android):

cordova plugin save
cordova platform remove android
cordova platform add android

This is the error I get, which I think is that version values are not being merged properly.

    * 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.

I've been having this issue and digging into for a few days.

Lets see, I'll share only what I think is relevant but if any more info is needed.. just let me know:

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"/>

And I even tried this in my build.gradle (wich I found in a answer for a related question that it seems to solve it for the 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'
            }
        }
    }
}

The thing is if I change all this 28's for 27 then cordova build android will still say 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

So I don't really know what to try next.. any thoughts?

This is the full response:

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


from Cordova fails to build Android

1 comment: