Skip to content

Instantly share code, notes, and snippets.

@thechaudharysab
Last active November 25, 2023 14:57
Show Gist options
  • Save thechaudharysab/63f642ecbc71262f57c96b9440ebd398 to your computer and use it in GitHub Desktop.
Save thechaudharysab/63f642ecbc71262f57c96b9440ebd398 to your computer and use it in GitHub Desktop.
Common errors while building Android app for release/debug in React native

About the document

While building for android, sometimes there are errors. I've been working on react-native (these solutions will also work the same for flutter and other android dev languages) for quite sometime now and have faced errors throughtout but I have been documenting them locally so I'm creating this gist which I'll keep up-to-date as I face any new errors. Please note that all the solutions given here worked for me and they might not necessarily work for you so move with caution. Feel free to add your own solution that worked for you,


Task :react-native-gradle-plugin:compileKotlin FAILED

This occurs when your JDK version is not the same as mentioned in your project. To solve open the project in Android studio, make it finish its processing first then go to Preferences > Build, Execution, Deployment > Build Tools > Gradle and then Gradle Settings and select the correct JDK version i.e. it was JDK 8 in my case. Then try cleaning and building again.

Clean project, clean any build related file on github.

SENSITIVE: For JVM see the there is a folder inside android named .idea > modules > -1032735254(some number like that) > react-native-gradle-plugin.iml or in VSCode search for jvmTarget and only one result will show. In this file there will be a line <option name="jvmTarget" value="11" /> is where you can set your JVM version.

If there is an output of OutPut file you can replace that line with import com.android.build.*

Task :app:processReleaseResources FAILED

In the styles.xml file inside android > app > src > main > res > values make sure all is ok syntax-wise. Compare it with earlier version of this file in your code, because I don't remember what exactly was wrong but there was some problem with the syntax of this file.

Task :app:mergeReleaseNativeLibs FAILED

This error happened because there was not enough space left on my Mac. So, I did a restart of my laptop to clean up some cached space and then build the app and the error was gone.

Task :app:bundleDebugJsAndAssets FAILED

To fix do cd android and then do ./gradlew clean to make it work. For some reason fbsdk was causing it for me.

Task :app:lintVitalRelease FAILED

In AndroidManifest.xml file there should be a android:debuggable="true" comment it and build again.

Task :app:mergeDebugResources FAILED

Look for <style name="SplashTheme" parent="AppTheme"> in styles.xml and change its item to <item name="android:windowBackground">@android:drawable/splash_screen</item> ensure that you have splash_screen.xml file in /res/drawable.

Task: :app:mergeDexDebug FAILED

It happend when I configured firebase for react native project. We have to enable Multidex for android and here is a link that might help: https://rnfirebase.io/enabling-multidex

Task :app:processDebugResources FAILED

Just restarting the app build process works sometimes. But also try doing ./gradlew clean inside android folder it helps.

Task :app:installDebug FAILED

On Windows do: cd android then ./gradlew clean then cd .. and then npm cache clean --force
On MacOS do: cd android then ./gradlew clean and then cd ..

Task :app:packageDebug FAILED

Deleting all AVDs (Android Virtual Devices) and adding a new one helps in the launching of the simulator at least and there will be a new error and this one will be gone. Then close android studio and delete manually \app\build and \app\release and \app\debug folders. Runn again!

Task :app:mergeExtDexRelease FAILED

Occurs when deleted the build folder in the /android folder, so check for that.

Task :app:processReleaseManifest FAILED

From StackOverflow the given solution is:

The error happened to me while installing the React-Native-Image-Picker library. I was able to solve it like this: Error:

Task :app:processDebugManifest FAILED

I accessed this path which appeared to me in the complete error:

..\node_modules\react-native-image-picker\android\build\intermediates\library_manifest\debug\AndroidManifest.xml

When reviewing the file I identified the versions requested by the library:

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />

I modified in /android/app/build.gradle the following lines of code: android { ... defaultConfig { ... minSdkVersion 21 targetSdkVersion 29 } }

Task :app:mergeReleaseResources FAILED

The solution is on the path android/app/src/main/res/ delete all directory with start name drawable_* as well as raw folder. You can use the commands below inside cd android as well: rm -rf ./app/src/main/res/drawable-* and then rm -rf ./app/src/main/res/raw

Task :app:mergeDexRelease FAILED

Try by removing both build folders in /android and /android/app.. If this doesn't work do cd android && ./gradlew clean

Task :app:processDebugGoogleServices

This occurs when I installed firebase in react-native project. To fix open /android/app/build.gradle comment the line apply plugin: 'com.google.gms.google-services' and it'll work. This is because com.android.application package already has the same package.

Task :app:compileDebugJavaWithJavac

This error started appearing after I updated the Java. To solve it check the following:

  • Check if the android studio has any updates pending. Update android studio.

  • Open your android project in updated android studio and wait for it to load it might take some time to load. It'll show you a popup that an update is required either click. It'll show if there is an update. In the popup, click Begin Upgrade as shown in the images below: 1 2

  • Next, open SDK manager from the android studio the go-to SDK tools, and see if there is anything left to update.

  • Finally, note that the compile, runtime, testCompile, and testRuntime configurations introduced by the Java plugin have been deprecated since Gradle 4.10 (Aug 27, 2018), and were finally removed in Gradle 7.0 (Apr 9, 2021). The aforementioned configurations should be replaced by implementation, runtimeOnly, testImplementation, and testRuntimeOnly, respectively.

  • Then just open your project in android studio and from the file meun select the highlighted one in the image below: 3

This should fix this error.

Task :app:packageRelease FAILED

This error occurred when building for release .apk and here is how to fix it:

  • Delete the apk folder in /app/build/outputs/apk (if building .apk) or bundle folder (if building .abb)
  • Make sure you are cd android
  • Do rm -rf ./app/src/main/res/drawable-*
  • Then rm -rf ./app/src/main/res/raw
  • and finally ./gradlew assembleRelease OR If the above doesn't work, goto <your-project-path>/android and Press Command + Shift + . (period) to show the hiden files. There will be a hidden .gradle folder, delete that. Then open terminal do cd android and ./gradlew clean Then when you build or run the error will go away.

Task :app:signReleaseBundle FAILED

Check if in /android/gradle.properties or whereever you have it the MYAPP_UPLOAD_STORE_FILE & MYAPP_UPLOAD_KEY_ALIAS is correct.

Task :app:validateSigningRelease FAILED

Check if you have mis-spelled or mis-placed keystore file.

CocoaPods could not find compatible versions for pod "Firebase/Auth":

[!] CocoaPods could not find compatible versions for pod "Firebase/Auth":
  In Podfile:
    RNFBAuth (from `../node_modules/@react-native-firebase/auth`) was resolved to 18.6.2, which depends on
      Firebase/Auth (= 10.18.0)

None of your spec sources contain a spec satisfying the dependency: `Firebase/Auth (= 10.18.0)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.
error Command failed with exit code 31.

Solution

Try to run this cd ios && pod repo update

The following Swift pods cannot yet be integrated as static libraries

[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `FirebaseFirestore` depends upon `FirebaseCoreExtension` and `FirebaseFirestoreInternal`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
error Command failed with exit code 1.

Solution

Add the following in your podfile:

target 'APP_NAME' do
  config = use_native_modules!

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseFirestore', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseFirestoreInternal', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  
  # other code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment