React-Native(Android)-任务':app:transformClassesWithMultidexlistForRelease'的执行失败 [英] React-Native (Android) - Execution failed for task ':app:transformClassesWithMultidexlistForRelease'

查看:43
本文介绍了React-Native(Android)-任务':app:transformClassesWithMultidexlistForRelease'的执行失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将库 react-native-fcm 更新到版本16(现在支持Android 8)后,出现以下错误:

After updating the library react-native-fcm to version 16 (which now supports Android 8), I have the following error:

Execution failed for task ':app:transformClassesWithMultidexlistForRelease'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list.

关于如何解决这个问题的任何想法?

Any idea on how to approach this?

project/build.gradle :

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.0.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        // Add jitpack repository (added by tipsi-stripe)
        maven { url "https://jitpack.io" }
        mavenLocal()
        jcenter()
        google()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.28.0'
                force 'com.android.support:support-v4:27.1.0'
                force 'com.android.support:design:27.1.0'
            }
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

subprojects {
    if (project.name.contains('react-native-image-picker') || 
        project.name.contains('react-native-vector-icons')) {
        buildscript {
            repositories {
                jcenter()
                maven { url "https://dl.bintray.com/android/android-tools/"  }
            }
        }
    }
}

和我的 project/app/build.gradle :

apply plugin: "com.android.application"

import com.android.build.OutputFile

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 28
buildToolsVersion "28.0.2"

    defaultConfig {
        applicationId "com.lisdoworker"
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 14
        versionName "1.0.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        manifestPlaceholders = [
            tipsiStripeRedirectScheme: "example"
        ]
        multiDexEnabled true
    }
    signingConfigs {
        release {
          storeFile file(MYAPP_RELEASE_STORE_FILE)
          storePassword MYAPP_RELEASE_STORE_PASSWORD
          keyAlias MYAPP_RELEASE_KEY_ALIAS
          keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.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
            }
        }
    }
    dexOptions {
        jumboMode true
    }
}

dependencies {
    compile project(':react-native-fast-image')
    compile ('com.google.firebase:firebase-core:10.2.1') {
        force = true;
    }
    compile ('com.google.firebase:firebase-messaging:10.2.1') {
        force = true;
    }
    compile ('com.google.android.gms:play-services-base:10.2.1') {
        force = true;
    }
    compile ('com.google.android.gms:play-services-location:10.2.1') {
        force = true;
    }
    compile ('com.google.android.gms:play-services-places:10.2.1') {
        force = true;
    }
    compile ('com.google.android.gms:play-services-maps:10.2.1') {
        force = true;
    }
    compile ('com.google.android.gms:play-services-gcm:10.2.1') {
        force = true;
    }
    compile ('com.google.android.gms:play-services-wallet:10.2.1') {
        force = true;
    }
    compile ('com.google.android.gms:play-services-identity:10.2.1') {
        force = true;
    }
    compile project(':tipsi-stripe')
    compile project(':react-native-fcm')
    compile project(':react-native-extra-dimensions-android')
    compile project(':react-native-google-places')
    compile project(':react-native-vector-icons')
    compile project(':react-native-linear-gradient')
    compile project(':react-native-image-picker')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-fbsdk')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:27.1.0"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

// 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'
}

apply plugin: 'com.google.gms.google-services'

推荐答案

我相信添加 multiDexEnabled = true 仅仅是不够的.尝试将此行添加到您的 app/build.gradle 文件中:

I believe that adding multiDexEnabled = true is just not enough. Try to add this line to your app/build.gradle file:

implementation 'com.android.support:multidex:1.0.3'

您的Application类(如果有的话)也应该像这样:

Also your Application class (if you have one) should be kinda like this:

public class App extends MultiDexApplication {
    ...
}

或类似这样:

public class App extends Application {

    @Override
        public void onCreate() {
            super.onCreate();
            MultiDex.install(this);
    }
}

希望有帮助.

这篇关于React-Native(Android)-任务':app:transformClassesWithMultidexlistForRelease'的执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆