I'm trying to upgrade an application to React Native 0.57.1. I think I've followed all the steps, upgraded all the right files, yet I'm still getting an error that I cannot understand:
:react-native-document-picker:compileReleaseSources UP-TO-DATE
:react-native-document-picker:mergeReleaseResources UP-TO-DATE
:react-native-document-picker:verifyReleaseResourcesC:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\b3b5480809d523e6f8b8de92faafbcda\res\values-v26\values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.
C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\b3b5480809d523e6f8b8de92faafbcda\res\values-v26\values-v26.xml:13:5-16:13: AAPT: error: resource android:attr/colorError not found.
C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\b3b5480809d523e6f8b8de92faafbcda\res\values-v26\values-v26.xml:17:5-93: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\b3b5480809d523e6f8b8de92faafbcda\res\values\values.xml:251:5-69: AAPT: error: resource android:attr/fontStyle not found.
C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\b3b5480809d523e6f8b8de92faafbcda\res\values\values.xml:251:5-69: AAPT: error: resource android:attr/font not found.
C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\b3b5480809d523e6f8b8de92faafbcda\res\values\values.xml:251:5-69: AAPT: error: resource android:attr/fontWeight not found.
error: failed linking references.
:react-native-document-picker:verifyReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-document-picker:verifyReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
I can't really make sense of these errors, any idea what they mean? How can I find out how to fix this?
I've tried various things, including deleting the .cache directory, changing the gradle version but nothing seems to help. Any idea?
You need to add following code in your project's android/build.gradle:
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
}
}
}
}
For me, what fixed the issue was prefixing with app
./gradlew app:assembleRelease
Reason for the error:
You have installed react-native-document-picker as a dependency, And the reason for this error is that the configurations of your android/app/build.gradle and node_modules/react-native-document-picker/android/build.gradle mismatch.
Solution
Navigate to node_modules/react-native-document-picker/android/build.gradle
Edit and keep the compileSdkVersion buildToolsVersion minSdkVersion
targetSdkVersion same as you have in android/app/build.gradle
Sync the project again.
Run ./gradlew assembleRelease from the terminal.
Had another reason for this issue, I had previously modified minSdkVersion.
All you need to do is to remove /node_modules/ folder, /android/build and /android/app/build folders, re npm install and perform ./gradlew assembleRelease again.
The command cd android && ./gradlew app:assembleRelease do the magic.
I've found a github link where a command help in almost every type of verifyReleaseResource errors. Ref: https://github.com/luggit/react-native-config/issues/330#issuecomment-494915023
Reason for the error:
In my case, I had installed react-native-thermal-receipt-printer as a dependency, And the reason for this error is that the configurations of your android/build.gradle and node_modules/react-native-thermal-receipt-printer/android/build.gradle mismatch.
Solution
Navigate to node_modules/react-native-thermal-receipt-printer/android/build.gradle
Edit and keep the compileSdkVersion buildToolsVersion minSdkVersion targetSdkVersion same as you have in android/build.gradle
Save it and change dir cd android.
Run ./gradlew clean
Run ./gradlew assembleRelease
Related
I install Notifee package using yarn,
yarn add #notifee/react-native
After I run it,
yarn start
yarn run android
Throws an error like this,
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':notifee_react-native:compileDebugJavaWithJavac'.
I'm struggling to implement notifications in my React Native project. Really appreciate it if somebody could help me. Thanks.
As in v 6.0.0 added Android 13 support the compiledSdkVersion and targetSdkVersion should be changed to 33.
In your project android/build.gradle change,
compileSdkVersion = 33
targetSdkVersion = 33
More reference,
https://www.youtube.com/watch?v=Fxzi8Ug9NUA&ab_channel=CodewithMishen
In case if someone doesn't want to change the compileSdkVersion (maybe because other library will have compileDebugJavaWithJavac error) then they can try:
npm install --save #notifee/react-native#5.7.0
and keep the compileSdkVersion the same as before
react-native run-android failed after linking with react-native-ble-plx
Task :react-native-ble-plx:compileDebugJavaWithJavac FAILED
This is a newly created app with react-native init, didn't change anything except the min sdk.
Already tried to clean project, set min sdk to 18, tried to build with android studio to get more specific error but still can't understand where is the problem coming from.
The Error i get:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
12 actionable tasks: 2 executed, 10 up-to-date
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
/Users/oriamd/Documents/MyDev/DudeWheresMyCar/node_modules/react-native-ble-plx/android/src/main/java/com/polidea/reactnativeble/converter/RxBleScanResultConverter.java:3: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
/Users/oriamd/Documents/MyDev/DudeWheresMyCar/node_modules/react-native-ble-plx/android/src/main/java/com/polidea/reactnativeble/wrapper/Characteristic.java:5: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
full logs here :
https://pastebin.com/NJAmjUJm
Can supply more information if needed.
Thank you
This issue is similar to this issue.
As mentioned in #Kreator answer it is related to some packages that are not converted to AndroidX.
To fix this issue you can use jetifier.
I have the same issue mentioned in the question and these steps solved it and application run again.
First, use Android Studio's refactoring tool to convert your app re: the Android developer docs
npm install --save-dev jetifier
npx jetify
npx react-native run-android (your app should correctly compile and work)
Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again)
Problem was that i was using Android Studio Preview, and with that AndroidX and more unsupported packages.
I HAD THIS SAME ISSUE.
"Task :react-native-ble-plx:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task
':react-native-ble-plx:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 54s
error Failed to install the app. Make sure you have the Android
development environment set up:
https://reactnative.dev/docs/environment-setup.
Solution
this was my build.gradle project:
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"
kotlin_version = "1.6.0" // Update this to your version
}
repositories {
google()
mavenCentral()
}
...
}
I changed the some version to as following:
compileSdkVersion = 29
targetSdkVersion = 29
And now the Build is successful!
When I run react-native run-android --variant=release it is continuously crashing without any errors on both the simulator and mobile phone.
I tried the suggestions in this article but when I run ./gradlew clean && ./gradlew assembleRelease it gives this error:
> Task :react-native-navigation:verifyReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-navigation:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/balwindersingh/Desktop/WEBSITETOON/teamwallpaper/node_modules/react-native-navigation/android/app/build/intermediates/res/merged/release/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
/Users/balwindersingh/Desktop/WEBSITETOON/teamwallpaper/node_modules/react-native-navigation/android/app/build/intermediates/res/merged/release/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
/Users/balwindersingh/Desktop/WEBSITETOON/teamwallpaper/node_modules/react-native-navigation/android/app/build/intermediates/res/merged/release/values/values.xml:3083: error: resource android:attr/fontVariationSettings not found.
/Users/balwindersingh/Desktop/WEBSITETOON/teamwallpaper/node_modules/react-native-navigation/android/app/build/intermediates/res/merged/release/values/values.xml:3084: error: resource android:attr/ttcIndex not found.
error: failed linking references.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 59s
180 actionable tasks: 168 executed, 12 up-to-date
The issue is probably that you are building your app with sdkVersion 28 while react-navigation uses an older version.
You could overwrite the version in your android/build.gradle file:
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion compileSdkVersion
buildToolsVersion "$buildToolsVersion"
}
}
}
}
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
}
(I am not sure whether this is the best way though...)
Alternatively you could fork react-navigation and change the version in their android/app/build.gradle file to 28.
Don't delete the drawable folders in your res folder. if you followed that article then deleting those drawable folders causing the error. try without deleting drawable folders.
In my case I had left a console.log() statement in app therefore it was running completely fine on debug mode but crashed on release mode. After digging my mind in, I realized that it was this small problem.
So do check your app pages as well for such minor problems.
I have a react native application ready for the release, after following the android documentation and have added flavors to the product
flavorDimensions "version"
productFlavors {
free {
dimension "version"
applicationId 'com.my-app.free'
}
}
The command react-native run-android fails the gradle build with the following error:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':react-native-appboy-sdk:transformClassesWithDexForDebugAndroidTest'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
Considerations
If I comment the flavor in the gradle file the command runs without any problem.
Even with this error, I can assemble the apk without any errors using the command ./gradlew assembleRelease.
I can run the app using the android studio run configuration without any errors, this seems to be related to adding flavors and running with the react-native command
Please add below code in your android/build.gradle file, hope it will help you:
android {
dexOptions {
preDexLibraries = false
}
}
Also try below command if above not working:
react-native run-android --variant=developmentDebug
I check already all similar answers from Stack and also I lookup on GitHub Issues but without any luck.
Problem occur when I install react-native-maps plugin, during a build I receive gradlew exception
:react-native-maps:processReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-maps:processReleaseResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.3\aapt.exe'' finished with non-zero exit value 1
Google Maps API is correctly added into AndroidManifest file.
One additional remark I see also many warnings like
...\node_modules\react-native-maps\android\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\9.8.0\res\drawable\common_google_signin_btn_text_light_focused.xml:14:29-81 : No resource found that matches the given name (at 'drawable' with value '#drawable/common_google_signin_btn_text_light_normal').
However in build.gradle I add dependencies for
compile 'com.google.android.gms:play-services-base:10.0.1'
Any ideas how to resolve a problem?
I had the same error recently and should have paid more attention to the error message. Message clearly states it out. Failure to execute aapt
Short Answer:
Make aapt executable
Slightly Longer Answer:
1) Run cd android && ./gradlew clean && ./gradlew assembleDebug --stacktrace. The output will show the build-tool version where you will locate the right aapt to make executable and the path to it. e.g Cannot run program "/home/user/Android/Sdk/build-tools/25.0.3/aapt" (in directory "/home/user/testproject/node_modules/react-native-maps/lib/android"): error=13, Permission denied
2) Right click on file 'aapt', click on permissions, click the checkbox marked 'Execute'
3) Run ./gradlew clean && ./gradlew assembleDebug again and you should be good to go!!!
Problem solved.
An issue is a to long file path and npm not properly install react-native-maps module (there wasn't all required resource files).
During "compilation"
react-native run-android
gradlew task fails du to missing resources in maps module
I experienced a similar issue with this error response:
:react-native-maps:processReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-maps:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
The way I was able to resolve this error was by going into folder node_modules/react-native-maps/lib/android and editing the build.gradle file with the corresponding compileSdkVersion, buildToolsVersion, minSdkVersion, and targetSdkVersion from my {root}/android/app level build.gradle versions.
This fix worked in various other newly installed packages which caused an error upon attempting to react-native run-android. Hope this helps!