Build Error -Ionic Cordova fails for android

10,332

Solution 1

I had to do the stuff of both the answers above:

In platforms/android/phonegap-plugin-barcodescanner:

Search for compile 'com.android.support:support-v4:+ and replace for compile 'com.android.support:support-v4:27+'.

In platforms/android:

Search for cordova.system.library.2=com.android.support:support-v4:+ and replace for cordova.system.library.2=com.android.support:support-v4:27.1.0.

Hope it helps.

Solution 2

found this on the ionic forum https://forum.ionicframework.com/t/android-build-broken-after-gradle-dependencies-update-execution-failed-for-task-processdebugresources-com-android-ide-common-process-processexception-failed-to-execute-aapt/109982/134 the suggestion that worked for me was "I got it working, my issue was in the cordova-plugin-file-opener2.
Change com.android.support:support-v4:+ to com.android.support:support-v4:23+ in the plugin.xml for the cordova-plugin-file-opener2 in the plugins folder and the node_modules folder.
Then do the same in the project.properties in platforms/android.
My plugin however was the background-geolocation and actually i dont believe i had to make a fix in the project.properties for mine.

Solution 3

Mine required a similar fix as above only it was in the de.appplant.cordova.plugin.local-notification plugin. I changed ‘com.android.support:support-v4:+’ to ‘com.android.support:support-v4:23+’ and then removed and added the android platform and it built. However, I had an extra brace '}' in my build-extras.gradle that had to be removed also.

Solution 4

In my case, problem was in barcode scanner plug in. Removing and adding this plug in did not work, after all get it worked by changing 'com.android.support:support-v4:+' to 'com.android.support:support-v4:27+' in file 'platform/android/phonegap-plugin-barcodescanner/{projectName}-barcodescanner'. What I did not understand is project was working yesterday perfectly, what happened in 24 hours and this problem occured...

Solution 5

Had the same issue, what I did was following:

  1. Clear the build directory
    • cordova clean
  2. Add multiDexEnabled under android -> defaultConfig to the build.gradle file
    • "your project\platforms\android\app\build.gradle"
    • multiDexEnabled true
  3. Change dependencies for "com.android.support" within the build.gradle file
    • com.android.support:support-v4:+ => com.android.support:support-v4:23+
  4. Go through the plugins folder and look in all "plugins.xml" and replace:
    • com.android.support:support-v4:+ => com.android.support:support-v4:23+
  5. Change project.properties under "platforms\android\project.properties"
    • cordova.system.library.4=com.android.support:support-v4:23+
  6. Run "ionic cordova run build"

Unable to merge dex

Clean install

Wrong Namespace / Version

.

android {

    defaultConfig {
        multiDexEnabled true
        versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
        applicationId privateHelpers.extractStringFromManifest("package")

        if (cdvMinSdkVersion != null) {
            minSdkVersion cdvMinSdkVersion
        }
    }
}
Share:
10,332
Kumar
Author by

Kumar

Updated on July 12, 2022

Comments

  • Kumar
    Kumar almost 2 years

    I get following error while running the command "ionic cordova build android --stacktrace" :

    :generateDebugResources
    :mergeDebugResources
    
    :processDebugManifest
    
    :processDebugResources
    ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
     FAILED
    ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
    
    I am using following tools on Window's:
     Editor : VScode
    
    Ionic: C:\Users\xyz>ionic -version
    3.19.1
    Npm as packagemanager
    

    Project Properties:

    target=android-26
    cordova.system.library.1=com.google.android.gms:play-services-analytics:+
    cordova.system.library.2=com.facebook.android:facebook-android-sdk:4.+
    cordova.gradle.include.1=cordova-plugin-appsflyer-sdk/customerapp-cordovaAF.gradle
    cordova.gradle.include.2=twitter-connect-plugin/customerapp-twitter.gradle
    cordova.system.library.3=com.android.support:support-v4:26.+
    cordova.system.library.4=com.android.support:appcompat-v7:26.+
    cordova.system.library.5=com.android.support:support-v4:24.1.1+
    cordova.system.library.6=com.android.support:support-v4:+
    android.library.reference.1=CordovaLib
    
  • Kumar
    Kumar about 6 years
    I may sound naive as I am .So you need to look for them after adding the platform (android) to the ionic project or prior to that?
  • Kumar
    Kumar about 6 years
    I may sound naive as I am .So you need to look for them after adding the platform (android) to the ionic project or prior to that? Before adding platform(android) I do not see any plugin with 'com.android.support:support-v4:+' .After adding platform(android) I see following plugins has them:cordova-plugin-camera,cordova.plugins.diagnostic,de.app‌​plant.cordova.plugin‌​.local-notification . I made the changes as suggested by you but it still does not build. Any suggestion?Thanks for your help.
  • Kumar
    Kumar about 6 years
    If I remove and add android, androidmenifest file is not added again,hence leading to build failure.Any more suggestion?
  • mkimmet
    mkimmet about 6 years
    Thanks! This worked for me on an Ionic app (as stated in his answer, the key for me was removing and adding back the android platform)
  • Greg Foote
    Greg Foote about 6 years
    This worked for me as well
  • kimsal
    kimsal about 6 years
    Sorry to bug you, but where would you put this? more specifically, I'm trying to build in ionic's pro cloud-based builder. It seems making any change to any dependency's gradle files won't work, because the unmodified versions would be pulled down by the remote build system. Any one else face this issue?
  • Chris Scutt
    Chris Scutt almost 6 years
    Add straight after buildscript section closing curly brace at the top of the file.