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!
Related
I got this error while react-native run-android. I tried ./gradlew clean ./gradlew -stop and wipe data, remove build folder, .gradle folder etc... But can't solve the problem.
Here is the error code I got.
Does anyone has an idea to solve that problem?
$ react-native run-android
warn Package #svgr/webpack has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in (...)/node_modules/#svgr/webpack/package.json
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1888 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon, 1 incompatible and 3 stopped Daemons could not be reused, use --status for details
> Configure project :lottie-react-native
WARNING:: The specified Android SDK Build Tools version (29.0.3) is ignored, as it is below the minimum supported version (30.0.2) for Android Gradle Plugin 4.2.2.
Android SDK Build Tools 30.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '29.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
> Task :app:packageDebug FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
495 actionable tasks: 5 executed, 490 up-to-date
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
(...)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageDebug'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
> com.android.ide.common.signing.KeytoolException: Failed to read key androiddebugkey from store "(...)/android/app/debug.keystore": keystore password was incorrect
* 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 14s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
(...)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageDebug'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
> com.android.ide.common.signing.KeytoolException: Failed to read key androiddebugkey from store "(...)/android/app/debug.keystore": keystore password was incorrect```
Im using react navigation v5.. installed all the dependencies.. now Im getting above error..
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-screens:compileDebugJavaWithJavac'.
> java.lang.reflect.UndeclaredThrowableException
* 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
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.5/userguide/command_line_interface.html#sec:command_line_warnings
Run this command in your terminal
cd android
// to check if there are any deamon running.
./gradlew --status or .\gradlew --status
./gradlew --stop
./gradlew clean
cd ..
// then restart the server
I think this issue is still open on GitHub issues -> View
If your React Native Version < 0.60 then you can use Jetifier to solve this issue
How to use Jetifier to solve ?
yarn add --dev jetify
Then in your package.json scripts add:
"postinstall": "jetify"
yarn jetify
If your React Native Version 0.60 > then try this
cd android && ./gradlew clean
it do it when you upgrade your react-native version to 0.69.1 or higher insert the kotlin classpath to build.gradle of app(android\build.gradle) :
dependencies {
.....
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") ----- this line
.....
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
sorry for my english
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 get this error when I try to run my react native app I manually changed the version to 2.5.6 but I got different error here below:
[CIRCULAR REFERENCE:com.android.tools.r8.ApiLevelException: Invoke-customs ae only supported starting with Android O (--min-api 26)]
FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.dexing.DexrchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Faile to process C:\Users\Dell.gradle\caches\transforms-1\files-1.1\lottie-2.5.6.aar\adddb5cebf38e2804a0cb857e5cf364\jars\classes.jar
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug optin to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 21s
147 actionable tasks: 1 executed, 146 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Here is my dependency
dependencies {
compile project(':lottie-react-native')
implementation project(':lottie-react-native')
implementation('com.airbnb.android:lottie:2.5.5') {
exclude group: 'com.android.support'
}
It looks like you have added an additional dependency to your dependencies.
Looking at the example project in the lottie-react-native repo they only add the compile project(':lottie-react-native')
Here are the dependencies that they have for their example project. (Note that compile should be replaced with implementation)
dependencies {
compile project(':lottie-react-native')
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:support-annotations:26.1.0'
compile "com.facebook.react:react-native:+" // From node_modules
}
Notice that they do not have
implementation('com.airbnb.android:lottie:2.5.5') {
exclude group: 'com.android.support'
}
In any project that I have used Lottie I have never added
implementation('com.airbnb.android:lottie:2.5.5')
If you remove that line, you should solve your problem.
Invoke-customs are only supported starting with Android O (--min-api 26)]
This error is caused by the fact that the Lottie dependency requires Java 8 bytecode. So to get it to work we need to enable desugaring in the app/build.gradle. So we need to tell it to use Java 8. We do this by updating the android section.
android {
defaultConfig {
...
}
// add the following
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
I just got a react native project and I am trying to run it. When I run:
react-native run-android
, this is my output.
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Checking the license for package Android SDK Platform 27 in C:\Users\oriont\AppData\Local\Android\Sdk\licenses
Warning: License for package Android SDK Platform 27 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-27 Android SDK Platform 27
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: C:\Users\oriont\AppData\Local\Android\Sdk
* 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 1s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:637:11)
at Object.execFileSync (child_process.js:655:13)
at runOnAllDevices (C:\Users\oriont\dev\proj\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\Users\oriont\dev\proj\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (C:\Users\oriont\dev\proj\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
I have followed all of the directions on the facebook getting started page, but this error keeps popping up. When I run it, I have my AVD running, which is on Android 9. From there, I tried to accept the licenses.
C:\Users\oriont\AppData\Local\Android\Sdk\tools\bin>sdkmanager.bat --licenses
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 5 more
And I don't know what to do from here. I tried expo and it was another rabbit hole... Someone please help! Thanks!
Android Studio > Preferences > Appearance & Behavior > System Settings > Android SDK
Tick the latest Android versions, click Apply.
It's at this point where Android will ask you to agree to its license(s) and the updated version(s) will be installed.
From Here GitHub
I read an answer (Thank you) but it sadly didn't work. I now think that the licenses aren't the problem anymore. I had realized that the project wanted android 27 and I had android 28 installed, so I tried downgrading to android 27. That didn't work, so I just upgraded (I think) the project to android 28 by changing ext in android/build.gradle to:
ext {
buildToolsVersion = "28.0.0"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 26
supportLibVersion = "28.0.0"
}
and add this to android in android/app/build.gradle
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
I also had java 10.0.2 installed and I downgraded to java 8. (not sure if that made a difference)
Anyways I hope this helps people get their old projects up to date!