首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >任务':app:preDebugBuild‘react native android执行失败

任务':app:preDebugBuild‘react native android执行失败
EN

Stack Overflow用户
提问于 2019-07-30 19:19:47
回答 1查看 1.7K关注 0票数 0

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

代码语言:javascript
复制
npm start
react-native link
react-native run-android

它失败了,我得到了这个错误:

代码语言:javascript
复制
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')文件的样子:

代码语言:javascript
复制
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'
}
EN

回答 1

Stack Overflow用户

发布于 2019-07-30 20:33:20

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57270437

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档