Android studio 无法解析';的依赖项';:无法解析项目:反应本机导航 问题说明
在仔细遵循中的说明后,在完成Android的步骤4后,我发现以下错误:Android studio 无法解析';的依赖项';:无法解析项目:反应本机导航 问题说明,android-studio,react-native,gradle,synchronization,react-native-navigation,Android Studio,React Native,Gradle,Synchronization,React Native Navigation,在仔细遵循中的说明后,在完成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@debugAndr
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的实验功能
仅同步活动变量,这将导致另外两个错误:
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代理>无代理
- 将
移动到顶部google()
buildscript{ ext {...} repositories { google() mavenLocal() ... } ... } allprojects { repositories { google() ... } }
- 将gradle distributionUrl更新为5.1.1-all并删除任务包装器
- Remove.gradle,引用
- 使缓存无效/重新启动
- 关闭Android Studio
- 删除.gradle文件夹
- 重新启动Android Studio
- 在gradle.properties中同时设置http和https代理
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本机导航上打开
- 退出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插件
# 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之后产生错误
环境
- React本机导航版本:2.7.0
- React本机版本:0.57.8
- 平台(iOS、Android或两者皆有?):Android
- 安卓工作室3.3
- 格拉德尔4.10.1
- Android Gradle插件3.3.0
- Android SDK构建工具28.0.3
- 马科斯莫哈韦10.14.2
- Java 8(brew桶)
android {
defaultConfig {
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57_5"
}
}
我已经花了2周的时间尝试正确配置react native navigation v2,因此请随时尝试我的应用程序框架:
已完全设置并准备好进行开发:)我克隆了repo,安装了npm,并运行了
npm-run-android
,它构建成功,但没有在模拟器中运行应用程序。我漏了一步吗?是因为我使用的是Android Studio 3.3吗?顺便说一句,我需要按照Android Studio的建议,将Gradle插件更新为3.3.0,将Gradle插件更新为4.10.1。这与我在完成RNN文档中的所有安装步骤后遇到的问题相同,我在这里发布了一个问题:与打开仿真器的npm run ios
不同。对于android,您必须首先通过android Studio打开模拟器。然后,当你运行npm run android
时,应用程序应该安装在emulator中。我发现,当我遵循安装指南中提到的确切版本时,我能够通过android Studio的emulator毫无问题地运行应用程序。正如您所说,该应用程序确实安装在emulator中,并且需要手动启动该应用程序。这是通过我提到的另一个stackoverflow问题解决的。所以我认为我犯了一个错误,为你的回购更新了Gradle插件和Gradle。