构建失败无法解析类com.android.build.output文件react-native

时间:2017-04-25 21:39:51

标签: android react-native-android

我在Android上使用React-Native运行我的应用程序,它出现了下一个错误:

“构建文件”C:\ Users ........ \ android \ app \ build.gradle':3:无法解析类com.android.build.OutputFile“

我尝试使用Android Studio和GenyMotion,但问题是一样的。

任何人都知道发生了什么?

谢谢!

2 个答案:

答案 0 :(得分:3)

我收到了类似的错误

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/mick/Codes/git/projects/alerto-balita/AlertoBalitaApp/android/app/build.gradle' line: 3

* What went wrong:
Could not compile build file '/Users/mick/Codes/git/projects/alerto-balita/AlertoBalitaApp/android/app/build.gradle'.
> startup failed:
  build file '/Users/mick/Codes/git/projects/alerto-balita/AlertoBalitaApp/android/app/build.gradle': 3: unable to resolve class com.android.build.OutputFile
   @ line 3, column 1.
     import com.android.build.OutputFile
     ^

  1 error

在我的情况下,我意外删除了项目classpath 'com.android.tools.build:gradle:2.3.3'中的build.gradle,返回它解决了编译问题

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

答案 1 :(得分:0)

确保在该部分:

<块引用>

buildscript { 依赖项 { ... } }

来自文件:

<块引用>

android / build.gradle

有线路:

<块引用>

classpath("com.android.tools.build:gradle:3.4.2")