作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
问题描述
仔细按照 https://wix.github.io/react-native-navigation/#/docs/Installing 中的说明操作后, 在完成 Android 的第 4 步后,我收到这些错误:
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :react-native-navigation.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :react-native-navigation.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :react-native-navigation.
Show Details
Affected Modules: app
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Affected Modules: app
build.gradle file
中的依赖项dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.2.0'
}
Only sync the active variant
,这会导致另外两个错误:ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :react-native-navigation.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :react-native-navigation.
Show Details
Affected Modules: app
google()
到顶部buildscript{
ext {...}
repositories {
google()
mavenLocal()
...
}
...
}
allprojects {
repositories {
google()
...
}
}
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyPort=12345
org.gradle.jvmargs=-Xmx1234m
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=12345
# android/settings.gradle
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
# android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
android/build.gradle
# android/build.gradle
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 19
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "28.0.0"
}
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://jitpack.io' }
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
# android/app/build.gradle
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {...}
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:+" // From node_modules
implementation project(':react-native-navigation')
}
最佳答案
继续执行步骤 7 已消除错误
第 7 步
通过在 android/app/build.gradle 中指定 RNN 构建风格来定位项目所需的 React Native 版本
android {
defaultConfig {
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57_5"
}
}
关于android-studio - 无法解析 '...' : Could not resolve project :react-native-navigation 的依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54231555/
我是一名优秀的程序员,十分优秀!