今天我刚创建了我的第一个React Native项目,但当我尝试在我的avd上运行它时就像;
react-native run-android
但它总是给出这个:
info JS server already running.
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:bundleDebugJsAndAssets SKIPPED
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
> Task :app:javaPreCompileDebug
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:mergeDebugResources
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugResources
> Task :app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /usr/lib/jvm/java-8-openjdk/jre contains a valid JDK installation.
* 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.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 26s
12 actionable tasks: 5 executed, 7 up-to-date
error 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
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.
我不知道该怎么办,我完全需要你的帮助。
感谢您的关注。
查看JRE文件夹的系统存在问题,即/ usr / lib / jvm / java-8-openjdk / jre。如果我们查看那里,没有Tools.jar,因此错误。
您可以创建环境变量JAVA_HOME:
在Variable value
里面添加你的JDK来代替jdk1.8.0_11
现在编辑你的PATH变量来添加JAVA_HOME:qazxsw poi
现在尝试再次运行该命令。 要么
检查此路径如果您在那里找到C:\Program Files\Android\Android Studio\jre\lib
然后尝试在上面的环境变量中设置JAVA_HOME = tools.jar
。
对于Linux用户 -
编辑系统路径文件/ etc / profile
C:\Program Files\Android\Android Studio\jre
最后添加以下行
sudo gedit /etc/profile
代替jdk1.7.0添加JDK版本。 然后注销并登录ubuntu以设置路径...
希望它有效!
你好。您需要检查JDK是否已正确安装,并验证是否已添加环境变量JAVA_HOME和JDK_HOME。