我一直在尝试使用react-native-navigation v2来启动并运行, 但是一直接连发生错误。 下面是错误
出了什么问题: 无法确定任务':app:compileDebugJavaWithJavac'的依赖关系。
无法解决配置':app:debugCompileClasspath'的所有任务依赖关系。 无法解决项目:react-native-navigation。 要求: 项目:app 无法在以下项目配置之间进行选择:react-native-navigation: -reactNative56DebugApiElements -reactNative57DebugApiElements -reactNative57WixForkDebugApiElements 它们都符合使用者属性: -配置“ reactNative56DebugApiElements”: -必需的RNN.reactNaltiveVersion'reactNative56',但未提供任何值。 -找到RNN.reactNativeVersion'reactNative56',但不是必需的。 -必需com.android.build.api.attributes.BuildTypeAttr'debug',并找到兼容值'debug'。 -必需com.android.build.gradle.internal.dependency.AndroidTypeAttr'Aar',并找到兼容值'Aar'。 -找到com.android.build.gradle.internal.dependency.VariantAttr'reactNative56Debug',但这不是必需的。 -必需的org.gradle.usage'java-api'和找到兼容的值'java-api'。 -配置“ reactNative57DebugApiElements”: -必需的RNN.reactNaltiveVersion'reactNative56',但未提供任何值。 -找到RNN.reactNativeVersion'reactNative57',但不是必需的。 -必需com.android.build.api.attributes.BuildTypeAttr'debug',并找到兼容值'debug'。 -必需com.android.build.gradle.internal.dependency.AndroidTypeAttr'Aar',并找到兼容值'Aar'。 -找到com.android.build.gradle.internal.dependency.VariantAttr'reactNative57Debug',但这不是必需的。 -必需的org.gradle.usage'java-api'和找到兼容的值'java-api'。 -配置“ reactNative57WixForkDebugApiElements”: -必需的RNN.reactNaltiveVersion'reactNative56',但未提供任何值。 -找到了RNN.reactNativeVersion'reactNative57WixFork',但这不是必需的。 -必需com.android.build.api.attributes.BuildTypeAttr'debug',并找到兼容值'debug'。 -必需com.android.build.gradle.internal.dependency.AndroidTypeAttr'Aar',并找到兼容值'Aar'。 -找到com.android.build.gradle.internal.dependency.VariantAttr'reactNative57WixForkDebug',但这不是必需的。 -必需的org.gradle.usage'java-api'和找到兼容的值'java-api'。
我的android / build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
jcenter()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
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' }
}
}
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 19
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
}
subprojects { subproject ->
afterEvaluate {
if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("reactNative51") || names.contains("reactNative55")) {
setIgnore(true)
}
}
}
}
}
}
app / build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
dexOptions {
javaMaxHeapSize "2048M"
}
defaultConfig {
applicationId "com.turb"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
missingDimensionStrategy "RNN.reactNaltiveVersion", "reactNative56"
ndk {
abiFilters "armeabi-v7a", "x86"
}
multiDexEnabled true
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
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')
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
settings.gradle
rootProject.name = 'turb'
include ':app'
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
我已经花了两天时间解决这些错误,但是由于这个特定的错误,无法在网络上找到帮助。 任何帮助将不胜感激,