apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.67k stars 1.54k forks source link

Execution failed for task ‘:app:mergeDebugResources’. com.android.build.gradle.internal.res.ResourceCompilerRunnable #1399

Closed bhandaribhumin closed 2 years ago

bhandaribhumin commented 2 years ago

Bug Report

Problem

After updating Cordova-android to 10.1.1 and SDK version 31 build error

What is expected to happen?

Build should work

What does actually happen?

> Task :app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
   > Resource compilation failed. Check logs for details.

config.xml

<preference name="android-minSdkVersion" value="25" />
    <preference name="android-targetSdkVersion" value="31" />
    <preference name="android-compileSdkVersion" value="31" />
    <preference name="android-buildToolsVersion" value="31" />
 <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity[@android:name='MainActivity']">
            <activity android:exported="true" />
        </edit-config>
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/receiver[@android:name='nl.xservices.plugins.ShareChooserPendingIntent']">
            <activity android:exported="false" />
        </edit-config>

Version information

Ionic:

Ionic CLI : 6.18.1 (/) Ionic Framework : ionic-angular 3.9.10 @ionic/app-scripts : 3.2.4

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1) Cordova Platforms : android 10.1.1 Cordova Plugins : cordova-plugin-ionic-webview 5.0.0, (and 22 other plugins)

Utility:

cordova-res : 0.15.4 native-run : 1.5.0

System:

Android SDK Tools : 26.1.1 (/Users/) ios-deploy : 1.11.4 ios-sim : 8.0.2 NodeJS : v12.21.0 (/Users/) npm : 6.14.11 OS : macOS Monterey Xcode : Xcode 13.2.1 Build version 13C100

Checklist

Screenshot 2022-02-17 at 6 12 31 PM

https://discuss.gradle.org/t/execution-failed-for-task-mergedebugresources-com-android-build-gradle-internal-res-resourcecompilerrunnable/39962

breautek commented 2 years ago

cordova isn't compatible with build tools 31. Use build tools 30.0.3 instead.

I understand the error message regarding compatible build tools version that cordova gives is misleading, that issue is tracked at https://github.com/apache/cordova-android/issues/1391.

Closing as duplicate (https://github.com/apache/cordova-android/issues/1288)

bhandaribhumin commented 2 years ago

@breautek Nope after changed buildToolsVersion to 30.0.3 issue remain same, shared few more details with you

  <preference name="android-targetSdkVersion" value="31" />
    <preference name="android-compileSdkVersion" value="31" />
    <preference name="android-buildToolsVersion" value="30.0.3" />

CDV-gradle-config.json

{
  "MIN_SDK_VERSION": 25,
  "SDK_VERSION": 31,
  "GRADLE_VERSION": "7.1.1",
  "MIN_BUILD_TOOLS_VERSION": "30.0.3",
  "AGP_VERSION": "4.2.2",
  "KOTLIN_VERSION": "1.5.21",
  "ANDROIDX_APP_COMPAT_VERSION": "1.4.1",
  "ANDROIDX_WEBKIT_VERSION": "1.4.0",
  "GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.10",
  "IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": true,
  "IS_GRADLE_PLUGIN_KOTLIN_ENABLED": false,
  "BUILD_TOOLS_VERSION": "30.0.3"
}

Plugin list:

adobe-mobile-services 4.19.4 "ADBMobile"
cordova-android-support-gradle-release 3.0.1 "cordova-android-support-gradle-release"
cordova-plugin-androidx-adapter 1.1.1 "cordova-plugin-androidx-adapter"
cordova-plugin-androidx 2.0.0 "cordova-plugin-androidx"
cordova-plugin-app-event 1.2.2 "Application Events"
cordova-plugin-badge 0.8.8 "Badge"
cordova-plugin-camera 3.0.0 "Camera"
cordova-plugin-device 2.0.0 "Device"
cordova-plugin-file-opener2 2.2.1 "File Opener2"
cordova-plugin-file-transfer 1.7.2-dev "File Transfer"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-geolocation 3.0.0 "Geolocation"
cordova-plugin-globalization 1.11.0 "Globalization"
cordova-plugin-inappbrowser 4.1.0 "InAppBrowser"
cordova-plugin-ionic-webview 5.0.0 "cordova-plugin-ionic-webview"
cordova-plugin-local-notification 0.9.0-beta.2 "LocalNotification"
cordova-plugin-localization-strings 3.2.1 "Localization"
cordova-plugin-media 5.0.3 "Media"
cordova-plugin-network-information 2.0.0 "Network Information"
cordova-plugin-settings-hook 0.2.7 "Cordova Settings Hooks"
cordova-plugin-splashscreen 6.0.0 "Splashscreen"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-streaming-media 2.3.0 "StreamingMedia"
cordova-plugin-x-socialsharing 5.6.8 "SocialSharing"
cordova-sqlite-storage 5.1.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
cordova.plugins.diagnostic 5.0.1 "Diagnostic"
es6-promise-plugin 4.2.2 "Promise"
ionic-plugin-keyboard 2.2.1 "Keyboard"
urbanairship-cordova 12.0.1 "Urban Airship"

Project.properties

arget=android-31
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.gradle.include.1=cordova-android-support-gradle-release/AppName-cordova-android-support-gradle-release.gradle
cordova.gradle.include.2=cordova-plugin-badge/AppName-badge.gradle
cordova.system.library.1=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.2=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.3=androidx.legacy:legacy-support-v4:1.0.0
cordova.gradle.include.3=cordova-plugin-local-notification/AppName-localnotification.gradle
cordova.system.library.4=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.5=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.6=androidx.appcompat:appcompat:1.0.0 // **tried all versions**
cordova.gradle.include.4=urbanairship-cordova/AppName-build-extras.gradle
breautek commented 2 years ago

Cordova doesn't support API 31 as I alluded to in my last message.

Generally speaking, SDK API levels and build tools versions all need to match, so if you're attempting to build/compile against API 31, you'll need build tools 31+. However, cordova-android@10 only supported/tested up to API 30, and like I said, there are known incompatibilities with API 31 tooling.

Therefore, you'll need to remove <preference name="android-targetSdkVersion" value="31" /> or set it to 30. cordova-android@10 will use target SDK 30 by default. Also note that the android-compileSdkVersion preference is obsolete in cordova-android@10 and no longer does anything. compile SDK version is always set to the target SDK version.

massimilianocom commented 2 years ago

I have the exact same problem I use SKB Build-Tool 30.0.3 and Android Platofrm 11.

Venegrad commented 7 months ago

Im not undestanding what to do. Clear install cordova, adding android platform, try to build clean app, and im getting that error, how i can resolve it?