问题
Issue Description
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
What I've tried
- Invalidate Cache/Restart
Update dependencies in
build.gradle file
dependencies { classpath 'com.android.tools.build:gradle:3.1.4' classpath 'com.google.gms:google-services:4.2.0' }
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
Preferences > Appearance & Behavior > System Settings > HTTP Proxy > No Proxy
Move
google()
to the topbuildscript{ ext {...} repositories { google() mavenLocal() ... } ... } allprojects { repositories { google() ... } }
Update the gradle distributionUrl to 5.1.1-all and remove task wrapper
- Remove .gradle, referenced here
- Invalidate caches / restart
- Shutdown Android Studio
- Remove .gradle folder
- Restart Android Studio
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
- Open an issue on wix/react-native-navigation
- Exit Android Studio, delete *.iml file and .idea directory, and rebuild
- Disable Instant Run
Steps to Reproduce
Step 1
Add the following
# android/settings.gradle
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
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
Step 3
Update 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")
}
Step 4
Update project dependencies
# 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')
}
Sync project as necessary confirming that after step 4 the errors are produced
Environment
- React Native Navigation version: 2.7.0
- React Native version: 0.57.8
- Platform(s) (iOS, Android, or both?): Android
- Android Studio 3.3
- Gradle 4.10.1
- Android Gradle plugin 3.3.0
- Android SDK Build Tools 28.0.3
- macOS Mojave 10.14.2
- Java 8 (brew cask)
回答1:
Proceeding to follow step 7 has gotten rid of the error
Step 7
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"
}
}
回答2:
I spent already 2 weeks trying to configure properly the react-native-navigation v2 so feel free to try my app-skeleton: https://github.com/Cicko/react-native-app-skeleton
which is fully set up and ready for development :)
来源:https://stackoverflow.com/questions/54231555/unable-to-resolve-dependency-for-could-not-resolve-project-react-native