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!
Related
I'm having a problem with React Native and Android licenses.
My Android knowledge is dated, I do write React but have no experience with React Native. Which is why I hired someone to turn a progressive web app I made into a native one. But due to circumstances I now have to finish the final thing myself.
The app was created on a mac, I'm trying to run it on pc.
The app does build for both IOS and Android from the Microsoft Appcenter. So I know it works, but I want it to run locally as well.
After doing all the installing and running react-native run-android the build starts but halts due to unaccepted licenses.
I already had Android Studio installed. I have checked the SDK Manager for the correct package versions (with 'show package details').
Updated everything I can think of including reinstalling Android Studio for the nth time. After the first uninstall/reinstall it would put it into a directory suffixed with '1' probably because the original directory couldn't be deleted. Yet the environment variables still pointed to the one without the suffix.
Accepting the licenses through cli with sdkmanager --licenses did opt me to accept a couple of times, but it didn't match the number of unaccepted packages I get from the react-native run-android error and the error remained the same afterwards (forgot to pay attention to which packages I was accepting though).
Two curious things:
- the error seems to be looking for licenses in a folder licenses yet my Android Studio folder only contains a folder license
- the error states Using Android SDK: C:\Program Files\Android\Android Studio but during the install of Android Studio I put mine in C:\AndroidSDK because it was whining about spaces.
Here is the error I get after running react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 905 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
> Configure project :app
Checking the license for package Android SDK Platform-Tools in C:\Program Files\Android\Android Studio\licenses
Warning: License for package Android SDK Platform-Tools not accepted.
Checking the license for package SDK Patch Applier v4 in C:\Program Files\Android\Android Studio\licenses
Warning: License for package SDK Patch Applier v4 not accepted.
Checking the license for package Android Emulator in C:\Program Files\Android\Android Studio\licenses
Warning: License for package Android Emulator not accepted.
Checking the license for package Android SDK Tools in C:\Program Files\Android\Android Studio\licenses
Warning: License for package Android SDK Tools not accepted.
Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Program Files\Android\Android Studio\licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in C:\Program Files\Android\Android Studio\licenses
Warning: License for package Android SDK Platform 28 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.
patcher;v4 SDK Patch Applier v4
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
emulator Android Emulator
tools Android SDK Tools
platforms;android-28 Android SDK Platform 28
platform-tools Android SDK Platform-Tools
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:\Program Files\Android\Android Studio
* 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 4s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
error Failed to install the app. Please accept all necessary SDK licenses using SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses". Run CLI with --verbo
se flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
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.
patcher;v4 SDK Patch Applier v4
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
emulator Android Emulator
tools Android SDK Tools
platforms;android-28 Android SDK Platform 28
platform-tools Android SDK Platform-Tools
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:\Program Files\Android\Android Studio
* 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 4s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
at checkExecSyncError (child_process.js:611:11)
at execFileSync (child_process.js:629:15)
at runOnAllDevices (C:\Users\foo\bar\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAl
lDevices.js:74:39)
at buildAndRun (C:\Users\foo\bar\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:15
8:41)
at C:\Users\foo\bar\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Command.handleAction (C:\Users\foo\bar\node_modules\#react-native-community\cli\build\cliEntry.js:160:7)
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!
I am trying to run a hello world application using the steps clarified hear. I am pretty sure I have done all the steps. but when I try to react-native run-android I get the below error.
react-native run-android ouput
C:\Users\Mike-laptop\AwesomeProject>react-native run-android
Scanning folders for symlinks in C:\Users\Mike-laptop\AwesomeProject\node_modules (43ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\Mike-laptop\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
Failed to download any source lists!
java.io.FileNotFoundException: https://dl.google.com/android/repository/repository2-1.xml
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find Build Tools revision 26.0.3
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.602 secs
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
Please note that I am running everything behind proxy... it is most likely due to the fact that react-native is not using proxy I have setup. I have tried to configure things in different ways.
Internet options
yarn config set proxy http://host:port
yarn config set h t t p s-proxy h t t p://host:port
npm config set proxy h t t p://host:port
npm config set h t t p s-proxy h t t p://host:port
set environment variable
set h t t p s_proxy=h t t p s://127.0.0.1:8123
set h t t p _proxy=h t t p://127.0.0.1:8123
set proxy=h t t p://127.0.0.1:8123
Still no luck :(
Much appreciate any comments.
First, you need to configure your Android env to run Android apps.
Please, take the steps in this link, in the Building Projects with Native Code tab, choose Windows and Android.:
https://facebook.github.io/react-native/docs/getting-started.html
Make sure you install Android SDK build tools 26.0.3 inside Android Studio.
node 6.11.2
npm 4.6.1
react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory (???)
macOS 10.12.6
Used React Native to create a new app from scratch. npm start works like a charm when using the expo app on my Android and iOS Devices. I'm having troubles to build a release apk for Android. (iOS will be next step.)
I did eject the app and followed the instructions to create a keystore file etc. Everything like it is documented here: https://facebook.github.io/react-native/docs/signed-apk-android.html
In android folder: running ./gradlew assembleRelease results to:
...
:app:bundleReleaseJsAndAssets
Scanning 748 folders for symlinks in /Users/xy/myApp_ReactNative/node_modules (13ms)
Scanning 748 folders for symlinks in /Users/xy/myApp_ReactNative/node_modules (16ms)
Loading dependency graph, done.
Cannot find entry file index.android.js in any of the roots: ["/Users/xy/myApp_ReactNative"]
:app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'node'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 26.813 secs
After days of trying out different versions and going back and forward, using commands with sudo and looking up alternatives, I'm getting completly lost. Also wondering why it scans twice... how to solve this?
Solved it myself like so: after trying on a Windows10 machine I realized that I might not have setup NDK. Started Android Studio on my mac and in the SDK Manager installed "NDK". Add a local.properties file in the 'app' folder with sdk.dir=pathtoyourSDK. After that: it worked!
I am running a React-Native app but when I try to gradlew installDebug in the android directory I get a build failure. Here is the info I get when I use:
gradlew installDebug --info
`BUILD FAILED
Total time: 1.118 secs
Stopped 0 compiler daemon(s).
Received result CommandFailure[value=org.gradle.launcher.exec.ReportedException: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring project ':app'.] from daemon DaemonInfo{pid=4326, address=[4c8a3b8f-5957-4911-b262-0e36824d2139 port:54258, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], idle=true, context=DefaultDaemonContext[uid=dbec8c34-89ba-4872-9077-12b4b3ff38a0,javaHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home,daemonRegistryDir=/Users/d0ntg0m0ng/.gradle/daemon,pid=4326,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]}.`
This is the error I get when I run gradlew installDebug without --info
`android [router] :> ./gradlew installDebug
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':app'.
Cannot evaluate module react-native-couchbase-lite : Configuration with name 'default' not found.`
"react-native": "^0.15.0", is the version of react-native I am using.
this is the repo that the project is fork from
I am trying to setup the app to my genymotion emulator but the build never finishes.
I have already run the commands to react-native start and set up the sync to the couchbase lite server. Not sure if this is relevant info. I am fairly new to native development and I have no idea where to start with trying to debug this.
include ':app'
include ':react-native-couchbase-lite'
project(':react-native-couchbase-lite').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-couchbase-lite/android')
check the file path