构建失败,react-native-navigation程序包中出现异常

时间:2019-05-08 09:30:24

标签: react-native

我添加了反应导航库。我已经安装了Package并在app / build.gradle和android / setting.gradle中添加了依赖项。但是配置大约66后我得到了错误 “任务:app:preDebugBuild失败

失败:构建失败,并出现异常。

  • 出了什么问题: 无法解析配置':app:debugCompileClasspath'的所有文件。
      

    找不到com.android.support:appcompatv7:28.0.0。   要求:     项目:app“

1 个答案:

答案 0 :(得分:0)

build.gragle(项目)上添加/替换以下代码:

buildscript {
    repositories {
        google()
        mavenLocal()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}


allprojects {
    repositories {
        google()
        mavenCentral()
        mavenLocal()
        jcenter()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        maven { url 'https://jitpack.io' }
    }
}
ext {
    buildToolsVersion = "27.0.3"
    minSdkVersion = 19
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

更新android/app/build.gradle中的项目依赖项:

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.yourproject"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}


dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+" 
    implementation project(':react-native-navigation')
}

然后运行:

cd android && ./gradlew clean

最后回到您的项目,然后:

react-native run-android