我添加了反应导航库。我已经安装了Package并在app / build.gradle和android / setting.gradle中添加了依赖项。但是配置大约66后我得到了错误 “任务:app:preDebugBuild失败
失败:构建失败,并出现异常。
找不到com.android.support:appcompatv7:28.0.0。 要求: 项目:app“
答案 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