react-native run-android遇到问题总结

澹台庆
2023-12-01

【1】、Task :react-native-fetch-blob:compileDebugJavaWithJavac FAILED
Putting task artifact state for task ':react-native-fetch-blob:compileDebugJavaWithJavac' into context took 0.0 secs.
file or directory 'F:\rn\GMP\node_modules\react-native-fetch-blob\android\src\debug\java', not found
Up-to-date check for task ':react-native-fetch-blob:compileDebugJavaWithJavac' took 0.057 secs. It is not up-to-date because:
  Task ':react-native-fetch-blob:compileDebugJavaWithJavac' class path has changed from 4d18537a3ca81329370d543419aae0e2 to b0f52611f5597d6cb85961d4dda0a22a.
All input files are considered out-of-date for incremental task ':react-native-fetch-blob:compileDebugJavaWithJavac'.
Compiling with source level 1.7 and target level 1.7.
:react-native-fetch-blob:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
file or directory 'F:\rn\GMP\node_modules\react-native-fetch-blob\android\src\debug\java', not found
Compiling with JDK Java compiler API.
错误: 读取F:\rn\GMP\node_modules\react-native-fetch-blob\android\build\generated\source\r\debug\org\webkit\android_jsc\R.java时出错; F:\rn\GMP\node_modules\react-native-fetch-blob\android\build\generated\source\r\debu
g\org\webkit\android_jsc\R.java (系统找不到指定的文件。)
-------------------------------------------------------------------------------------------------
* What went wrong:
Execution failed for task ':react-native-fetch-blob:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':react-native-fetch-blob:compileDebugJavaWithJavac'.

***********************************************************************
安装react-native-fetch-blob之后不报错了,应该是没有安装问题。
C:\Users\Administrator>npm install --save react-native-fetch-blob
***********************************************************************

 

 

【2】Error:Execution failed for task ':app:generateDebugBuildConfig'.
java.io.FileNotFoundException: ..\app\build\generated\source\buildConfig\..\BuildConfig.java
-------------------------------------------------------------------------------------------------
This problem might be caused by incorrect configuration of the daemon.  
For example, an unrecognized jvm option is used.  
Please refer to the user guide chapter on the daemon at http://gradle.org/docs/4.4/userguide/gradle_daemon.html

***********************************************************************
可能是JDK版本问题,安装了最新版JDK、并且重装了android studio解决
***********************************************************************


【3】
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:
***********************************************************************
使用以下指令查看详细日志
gradlew compileDebug --stacktrace -info 

gradlew compileDebugSources --stacktrace -info
***********************************************************************


【4】
* Exception is:
org.gradle.execution.TaskSelectionException: Task 'compileDebug' is ambiguous in root project 'android'. Candidates are: 'compileDebugAidl', 'compileDebugAndroidTestAidl', 'compileDebugAndroidTestJavaWithJavac', 'comp
ileDebugAndroidTestNdk', 'compileDebugAndroidTestRenderscript', 'compileDebugAndroidTestShaders', 'compileDebugAndroidTestSources', 'compileDebugJavaWithJavac', 'compileDebugNdk', 'compileDebugRenderscript', 'compileD
ebugShaders', 'compileDebugSources', 'compileDebugUnitTestJavaWithJavac', 'compileDebugUnitTestSources'.
        at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:116)
        at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:81)
        at org.gradle.execution.commandline.CommandLineTaskParser.parseTasks(CommandLineTaskParser.java:42)
***********************************************************************
修改android/gradle.properties文件,增加下面配置
org.gradle.configureondemand=true
(##按需配置## 配置有一种方式是按需配置,目前还在试验孵化阶段,所以默认是关闭的,可以通过在gradle.properties加入这样一句来开启)
***********************************************************************

 

 类似资料: