微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

React-native 问题 - 任务 ':app:compileDebugJavaWithJavac'

如何解决React-native 问题 - 任务 ':app:compileDebugJavaWithJavac'

所以我正在与我的团队合作进行项目。起初我有两个问题,你可以在这页面上找到:

React-native problem with launching the app

我不知道这两个问题是否消失了,或者我只是在它们上面放了另一个问题,但它就在这里。如果您有任何线索,请写信给我,我一直在努力解决这个问题。起初,当我将我的分支与其他队友合并时,一切都很好,但是在第二次合并后发生了这种情况:

PS C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013> npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1114 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...

> Configure project :react-native-firebase_app
:react-native-firebase_app package.json found at C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\@react-native-firebase\app\package.json
:react-native-firebase_app:firebase.bom using default value: 26.0.0
:react-native-firebase_app:play.play-services-auth using default value: 18.1.0
:react-native-firebase_app package.json found at C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\@react-native-firebase\app\package.json
:react-native-firebase_app:version set from package.json: 10.1.0 (10,1,0 - 10001000)
:react-native-firebase_app:android.compileSdk using custom value: 29
:react-native-firebase_app:android.targetSdk using custom value: 29
:react-native-firebase_app:android.minSdk using custom value: 16
:react-native-firebase_app:reactNativeAndroidDir C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\react-native\android

> Configure project :react-native-firebase_auth
:react-native-firebase_auth package.json found at C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\@react-native-firebase\auth\package.json
:react-native-firebase_app package.json found at C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\@react-native-firebase\app\package.json
:react-native-firebase_auth:firebase.bom using default value: 26.0.0
:react-native-firebase_auth package.json found at C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\@react-native-firebase\auth\package.json
:react-native-firebase_auth:version set from package.json: 10.1.0 (10,0 - 10001000)
:react-native-firebase_auth:android.compileSdk using custom value: 29
:react-native-firebase_auth:android.targetSdk using custom value: 29
:react-native-firebase_auth:android.minSdk using custom value: 16
:react-native-firebase_auth:reactNativeAndroidDir C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\react-native\android

> Task :react-native-community_google-signin:compileDebugJavaWithJavac

> Task :react-native-firebase_app:compileDebugJavaWithJavac

> Task :react-native-gesture-handler:compileDebugJavaWithJavac

> Task :react-native-firebase_auth:compileDebugJavaWithJavac

> Task :react-native-reanimated:compileDebugJavaWithJavac

> Task :react-native-screens:compileDebugJavaWithJavac

> Task :app:compileDebugJavaWithJavac 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.2/userguide/command_line_interface.html#sec:command_line_warnings
133 actionable tasks: 133 executed
Note: C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\@react-native-community\google-signin\android\src\main\java\co\apptailor\googlesignin\RNGoogleSigninModule.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\@react-native-firebase\auth\android\src\main\java\io\invertase\firebase\auth\ReactNativeFirebaseAuthModule.java uses or overrides a deprecated API. 
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\android\app\src\main\java\com\mrent\MainApplication.java:5: error: cannot find symbol
import com.facebook.react.PackageList;
                         ^
  symbol:   class PackageList
  location: package com.facebook.react
C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\android\app\src\main\java\com\mrent\MainApplication.java:84: error: class MainApplication is already defined in package com.mrent
  public class MainApplication extends MultiDexApplication implements ReactApplication {
         ^
C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\android\app\src\main\java\com\mrent\MainApplication.java:29: error: cannot find symbol
          List<ReactPackage> packages = new PackageList(this).getPackages();
                                            ^
  symbol: class PackageList
Note: C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\android\app\src\debug\java\com\mrent\ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors

FAILURE: Build Failed with an exception.

Execution Failed for task ':app: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 46s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command Failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013\node_modules\@react-native-community\google-signin\android\src\main\java\co\apptailor\googlesignin\RNGoogleSigninModule.java uses unchecked or unsafe operations.       
npm ERR! code 1
npm ERR! path C:\Users\sven\Desktop\FAKS\MRENT projekt\AIR2013
npm ERR! command Failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c "react-native "run-android""

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\sven\AppData\Local\npm-cache\_logs\2020-12-24T20_37_47_564Z-debug.log

解决方法

你安装 android-platform-tools 了吗?

如果已经连接,请检查您的设备是否已连接运行:

$ adb devices

它会显示您的设备 ID

如果您的设备已连接,但仍然出现错误,请尝试以下操作:

$ adb -s 反向 tcp:8081 tcp:8081

然后再次运行。如果仍然出错,试试这个:

$ npx react-native run-android --deviceId

,

我认为您在升级版本或安装新软件包时犯了一些错误。

请检查这个。

https://github.com/facebook/react-native/issues/25787

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。