问题描述
在仔细遵循 https://wix.github中的说明之后.io/react-native-navigation/#/docs/Installing ,在完成Android的第4步后,我遇到了以下错误:
After carefully following the instructions in https://wix.github.io/react-native-navigation/#/docs/Installing, I am getting these errors after completing step 4 for Android:
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文件
dependencies { classpath 'com.android.tools.build:gradle:3.1.4' classpath 'com.google.gms:google-services:4.2.0' }
-
为Gradle禁用实验功能
仅同步活动版本
,这会导致另外两个错误: Disable experimental feature for Gradle
Only sync the active variant
, which leads to two more errors: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
-
首选项>外观和行为>系统设置> HTTP代理>无代理
Preferences > Appearance & Behavior > System Settings > HTTP Proxy > No Proxy
将
google()
移至顶部buildscript{ ext {...} repositories { google() mavenLocal() ... } ... } allprojects { repositories { google() ... } }
-
将gradle distributionUrl更新为5.1.1-all,并删除任务包装器
Update the gradle distributionUrl to 5.1.1-all and remove task wrapper
- 使缓存无效/重新启动
- 关闭Android Studio
- 删除.gradle文件夹
- 重新启动Android Studio
-
在gradle.properties中设置代理HTTP和https
Set proxy both http and https in gradle.properties
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
- 在wix/react-native-navigation上打开问题
- 退出Android Studio,删除* .iml文件和.idea目录,然后重新构建
- 禁用即时运行
添加以下内容
# android/settings.gradle
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
步骤2
确保您正在使用新的gradle插件
Step 2
Make sure you're using the new gradle plugin
# android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
步骤3
更新 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")
}
步骤4
更新项目依赖项
# 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')
}
根据需要同步项目,确认在第4步之后产生了错误
Sync project as necessary confirming that after step 4 the errors are produced
- 反应本机导航版本:2.7.0
- 反应本机版本:0.57.8
- 平台(iOS,Android还是两者都使用):Android
- Android Studio 3.3
- 4.10.1级
- Android Gradle插件3.3.0
- Android SDK Build Tools 28.0.3
- macOS Mojave 10.14.2
- Java 8(酒桶)
推荐答案
按照步骤7进行操作已摆脱错误
Proceeding to follow step 7 has gotten rid of the error
通过在android/app/build.gradle中指定RNN构建风格来定位项目所需的React Native版本
Target the React Native version required by your project by specifying the RNN build flavor in android/app/build.gradle
android {
defaultConfig {
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57_5"
}
}
这篇关于无法解决"..."的依赖项:无法解决项目:react-native-navigation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!