1

After I run Cordova on android "cordova run android / cordova build" I I got the following error :

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:processDebugResources'. Failed to execute aapt

any thought how we can fix this I tried build/clean didn't work.

Thanks in Advance.

Mohammad Bitar
  • 48
  • 1
  • 10

3 Answers3

1

I'm having the same problem, on Friday I did the build normally and on Monday when trying to perform again I get the error 'Execution failed for task': app: processDebugResources'" plus some stacktrace on Aapt2Exception: AAPT2 error.

Apparently this has to do with Google launching new versions of support-v4 and api-level update

this link say that installing the cordova-android-support-gradle-release plugin solves the problem.

add the code below in build.gradle in the platforms/android directory

configurations.all {
    resolutionStrategy.force 'com.android.support:support-v4:27.1.0'
}

In my case it did not solve, but I may have done something wrong, I hope it will solve.

--- UPDATE 1

Google has released an update of Google Play service libraries and Firebase on June 17, 2019, I believe our problem is directly related to this. They recommend the following settings:

  • Upgrade com.android.tools.build:gradle to v3.2.1 or later.
  • Upgrade compileSdkVersion to 28 or later.
  • Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.

In the case of Cordova applications I still do not know exactly how to reflect these changes and I'm in the middle of a release cycle of an update of my app, without being able to build, it's really sad :(

--- UPDATE 2

I have found a solution for now by editing the project.properties file that is inside the platforms/android directory.

I changed all the libs that are in this file as "+" to a fixed version number prior to the version number released in the release on the 17th, you can check this here but this is still not an optimal solution since this file can be deleted if you need to remove and reinclude the platform.

--- UPDATE 3

As Leonardo explained this problem occurs because of the update of the firebase and play service libraries and the auto update of the cordova dependencies. It is possible to fix this using the configurations.all code in a build-extras.gradle file in the root directory of the project + hooks to automate the copy of the setup to within platform/android as explained in that link

PS:Sorry for my bad English.

  • I agree with you, I am in the middle of the release and I don't know how to solve this issue, I will try your answer. maybe it will solve my problem – Mohammad Bitar Jun 18 '19 at 18:51
  • 1
    I tried you solution but still giving other error : Dependency failing: com.google.firebase:firebase-messaging:17.0.0 -> com.google.firebase:firebase-iid@[16.0.0], but fire base-iid version was 19.0.0. – MR Gharibeh Jun 20 '19 at 11:26
1

Add in the build-extras.gradle, inside the platform/android folder of your project:

configurations.all {
    resolutionStrategy {
         force 'com.android.support:support-v4:27.1.1'
         force 'com.google.android.gms:play-services-tagmanager:16.0.8'
         force 'com.google.android.gms:play-services-base:16.1.0'
         force 'com.google.android.gms:play-services-tasks:16.0.1'
         force 'com.google.android.gms:play-services-basement:16.2.0'
         force 'com.google.android.gms:play-services-gcm:16.1.0'
         force 'com.google.android.gms:play-services-stats:16.0.1'
         force 'com.google.android.gms:play-services-location:16.0.0'
         force 'com.google.android.gms:play-services-auth:16.0.1'
         force 'com.google.android.gms:play-services-identity:16.0.0'
    }
}

In this way you will force the build to ignore the updates of specific services, and to use the previous versions.

And you don't need to change any plugin (nor the android platform version) :)

PS Every time firebase's libs are updated this happens.. very annoying. I'd love to be able to turn off the auto dependency update on build command, but I don't think it is possible.

Leonardo T
  • 61
  • 3
  • Thank you for your response, but when I check platforms/android folder there is no build-extras.gradle file!!! – Mohammad Bitar Jun 21 '19 at 06:56
  • You can create a new file named build-extras.gradle (with exactly this extension) and copy the code above inside (without additional code or syntax). – Leonardo T Jun 22 '19 at 08:13
  • @MohammadBitar the folder should be platforms/android if you have a v6 or v7. I think with v8 and v9 there is an additional subfolder /app – Leonardo T Jun 22 '19 at 08:14
  • Sometimes it's worth doing the sequence: remove the android platform, then Cordova clean, add the platform@desired version, Cordova prepare, override the gradle, build – Leonardo T Jun 22 '19 at 08:18
1

After Two days of struggling in this Issues because of last update for "android X " for firebase libraries :

https://developer.android.com/jetpack/androidx/migrate

solutions is following : make sure the following :

  • Upgrade com.android.tools.build:gradle to v3.2.1 or later.
  • Upgrade compileSdkVersion to 28 or later. . Update your app to use
  • Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.

For Cordova project just add the following plugins:

Those plugins will fix build error. and everything will work fine :)..

MR Gharibeh
  • 344
  • 2
  • 11