任务':app:preDebugBuild'的执行失败,无法响应本机android

时间:2019-07-30 11:19:46

标签: android react-native gradle

我正在尝试使用以下命令在android模拟器上运行我的react-native应用程序:

npm start
react-native link
react-native run-android

失败,并且出现此错误:

Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.slidingpanelayout:slidingpanelayout' has different version for the compile (1.0.0-rc01) and runtime (1.0.0) classpath. You should manually set the same version via DependencyResolution.

我试图删除node_modules和android / app / build文件夹并重复命令,但效果不佳

这是我的build.gradle(文件路径: 'someProject / android / 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"
apply from: "../../node_modules/react-native-sentry/sentry.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.someProject"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a"
        }
    }
    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, "arm64-v8a": 3]
            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 project(':rn-fetch-blob')
    implementation project(':react-native-svg')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-sentry')
    implementation project(':react-native-image-resizer')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-i18n')
    implementation project(':react-native-firebase')
    implementation project(':react-native-device-info')
    implementation project(':react-native-camera')
    implementation project(':react-native-blur')
    implementation project(':lottie-react-native')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

1 个答案:

答案 0 :(得分:0)

尝试删除'\ android \ app \ build'文件夹,然后再次删除react-native run-android