React Native Android :app:compileDebugJava 错误 [英] React Native Android :app:compileDebugJava error

查看:43
本文介绍了React Native Android :app:compileDebugJava 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行 react-native run-android 时,出现以下错误;我正在将其设置为在设备上运行.

When I run react-native run-android, i get the following error; I am setting it up to run on a device.

:app:compileDebugJava
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:6: error: cannot find symbol
import com.facebook.react.ReactApplication;
                         ^
  symbol:   class ReactApplication
  location: package com.facebook.react
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:8: error: cannot find symbol
import com.facebook.react.ReactNativeHost;
                         ^
  symbol:   class ReactNativeHost
  location: package com.facebook.react
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:15: error: cannot find symbol
public class MainApplication extends Application implements ReactApplication {
                                                            ^
  symbol: class ReactApplication
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:17: error: cannot find symbol
  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
                ^
  symbol:   class ReactNativeHost
  location: class MainApplication
/Users/hello/MediaFire/apps/v/android/app/src/main/java/com/test2/MainApplication.java:32: error: cannot find symbol
  public ReactNativeHost getReactNativeHost() {
         ^
  symbol:   class ReactNativeHost
  location: class MainApplication
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainActivity.java:6: error: MainActivity is not abstract and does not override abstract method getPackages() in ReactActivity
public class MainActivity extends ReactActivity {
       ^
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:17: error: cannot find symbol
  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
                                                       ^
  symbol:   class ReactNativeHost
  location: class MainApplication
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:31: error: method does not override or implement a method from a supertype
  @Override
  ^
8 errors
:app:compileDebugJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJava'.
> 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.

BUILD FAILED

Total time: 10.738 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/android-setup.html

推荐答案

查看android中的build.gradle(Project)文件:

Check the build.gradle(Project) file in android :

    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }

这行可能会丢失,在 repositories 下添加它,它应该是这样的:

This line may be missing, add this under the repositories , it should look like this :

allprojects {

    repositories {
        mavenLocal()
        jcenter()
        google()


        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }

    }
}

这篇关于React Native Android :app:compileDebugJava 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆