在react-native中导入com.android.build.OutputFile错误

Are*_*eza 6 android android-gradle-plugin react-native react-native-android

首先,我运行一个新项目

react-native init AwesomeProject --version 0.58.6
Run Code Online (Sandbox Code Playgroud)

(0.59.1有一个错误,但我对此进行了测试)

react-native run-android我可以运行它。

在android studio中,当我同步它时,出现错误:

app / build.gradle

import com.android.build.OutputFile
Run Code Online (Sandbox Code Playgroud)

错误:无法解析符号“ build”

我使用以下版本:

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 27
    supportLibVersion = "28.0.0"
}
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
Run Code Online (Sandbox Code Playgroud)

pan*_*ahm 0

我认为在 android studio 中你只能导入 android 部分。

转到:文件 -> 打开 -> 选择项目 -> 选择名为 android 的文件夹。

此处给出链接

这对我有用。