rasheedk / react-native-disable-battery-optimizations-android

A react native library for checking battery optimization and whitelisting in Android
29 stars 46 forks source link

Android resource linking failed #6

Open jcmlumacad opened 4 years ago

jcmlumacad commented 4 years ago

Steps to Reproduce:


ERROR FOUND

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

FAILURE: Build failed with an exception.

HyopeR commented 3 years ago

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
poliahrameshkumar commented 2 years ago

@HyopeR But, how to handle in CI?

zoobibackups commented 2 years ago

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.

HyopeR commented 2 years ago

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