1

我一直在尝试使用 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' 并找到兼容的值“调试”。- 需要 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)
                    }
                }
            }
        }
    }
}

应用程序/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'
}

设置.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/')

我在这些错误上花了两天时间,但是对于这个特定的错误,无法在网上找到帮助。任何帮助将不胜感激,

4

0 回答 0