react-native-disable-battery-optimizations-android icon indicating copy to clipboard operation
react-native-disable-battery-optimizations-android copied to clipboard

Android resource linking failed

Open jcmlumacad opened this issue 5 years ago • 4 comments

Steps to Reproduce:

  • Run ./gradlew assembleRelease

ERROR FOUND

Task :react-native-disable-battery-optimizations-android:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':react-native-disable-battery-optimizations-android:verifyReleaseResources'.

java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found. error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.

jcmlumacad avatar Sep 04 '20 17:09 jcmlumacad

Hello, you can temporarily do the following regarding this issue.

Solution:

  1. Navigate to node_modules/react-native-disable-battery-optimizations-android/android/build.gradle
  2. Edit and keep the compileSdkVersion buildToolsVersion minSdkVersion targetSdkVersion same as you have in android/app/build.gradle
  3. from terminal in android directory -> gradlew clean
  4. from terminal in android directory -> gradlew assembleRelease

HyopeR avatar Jun 02 '21 09:06 HyopeR

@HyopeR But, how to handle in CI?

poliahrameshkumar avatar Nov 09 '21 09:11 poliahrameshkumar

Hello, you can temporarily do the following regarding this issue.

Solution:

  1. Navigate to node_modules/react-native-disable-battery-optimizations-android/android/build.gradle
  2. Edit and keep the compileSdkVersion buildToolsVersion minSdkVersion targetSdkVersion same as you have in android/app/build.gradle
  3. from terminal in android directory -> gradlew clean
  4. from terminal in android directory -> gradlew assembleRelease

+1. This works but need a permanent fix.

zoobibackups avatar Mar 09 '22 11:03 zoobibackups

@zoobibackups I think the package is no longer updated. Therefore, you might consider patching the package as a more permanent solution. Read on if you don't know how to apply it.

// We use these two packages for patching. 1- yarn add -D patch-package postinstall-postinstall

// Add it to the top of the scripts object in the package.json. 2- in package.json scripts: { "prepare": "patch-package", ... }

// We will make changes to the package in node_modules directory. 3- Navigate to node_modules/react-native-disable-battery-optimizations-android/android/build.gradle

// Now let's make the necessary corrections. 4- Edit and keep the compileSdkVersion buildToolsVersion minSdkVersion targetSdkVersion same as you have in android/app/build.gradle

// After making the above change // While in the project home directory from the command line. 5- yarn patch-package react-native-disable-battery-optimizations-android

// If these operations are successful. 6- Patches folder is created in the project main directory and you have your patch in it. After running the npm install or yarn command, the patches under this folder work and the relevant packages are edited.

You and your teammates can use collaborative edits while working on a project.

HyopeR avatar Mar 09 '22 13:03 HyopeR