无法解析"..."的依赖关系:无法解析项目 :反应本机导航



问题描述

在仔细遵循中的说明后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'
    }
    
  • 禁用GradleOnly 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
    
  • 首选项>外观&行为>系统设置>HTTP代理>无代理

  • google()移动到顶部

    buildscript{
    ext {...}
    repositories {
    google()
    mavenLocal()
    ...
    }
    ...
    }
    allprojects {
    repositories {
    google()
    ...
    }
    }
    
  • 将gradle distributionUrl更新为5.1.1-全部并删除任务包装

  • Remove.gradle,此处引用
    1. 使缓存无效/重新启动
    2. 关闭Android Studio
    3. 删除.gradle文件夹
    4. 重新启动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文件和.inidea目录,然后重建
  • 禁用即时运行

复制步骤

步骤1

添加以下

# 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

确保您使用的是新的渐变插件

# 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 Native Navigation版本:2.7.0
  • React Native版本:0.57.8
  • 平台(iOS、Android或两者兼有?):Android
  • Android Studio 3.3
  • 4.10.1级
  • 安卓Gradle插件3.3.0
  • Android SDK构建工具28.0.3
  • macOS Mojave 10.14.2
  • Java 8(酿造桶)

继续执行步骤7已消除错误

步骤7

通过在android/app/build.gradle 中指定RNN构建风格,以您的项目所需的React Native版本为目标

android {
defaultConfig {
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57_5"
}
}

我已经花了两周时间尝试正确配置react原生导航v2,所以可以尝试我的应用程序骨架:https://github.com/Cicko/react-native-app-skeleton

已完全建立并准备开发:)

相关内容

  • 没有找到相关文章

最新更新