如何解决“以下APK或应用捆绑包可用于64位设备,但它们只有32位本机代码:XXX”?

时间:2019-09-10 06:12:46

标签: android react-native google-play-console

在我的react-native项目中,在android 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"

def enableSeparateBuildPerCPUArchitecture = false


def enableProguardInReleaseBuilds = false

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

    defaultConfig {
        applicationId "XXXX"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode XXX
        versionName "XXX"

        ndk {
            abiFilters "armeabi-v7a", "x86"
        }

        packagingOptions {
            exclude "lib/arm64-v8a/librealm-jni.so"
        }


    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release

        }
    }


    applicationVariants.all { variant ->
        variant.outputs.each { output ->


            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(project(':react-native-firebase')){
        exclude group: 'com.google.android.gms'
    }

    implementation(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }

    //implementation project(':react-native-firebase')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-svg')

    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.android.gms:play-services-basement:16.2.0'
    implementation 'com.google.android.gms:play-services-maps:16.0.0'

    implementation "com.google.firebase:firebase-core:16.0.6"
    implementation "com.google.firebase:firebase-messaging:17.3.4"



    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 'me.leolin:ShortcutBadger:1.1.21@aar'
    implementation project(':react-native-splash-screen')
}


apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"


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

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

构建了我已经在32位和64位设备上测试过的apk之后,它运行良好,但是在将发布的apk提交给播放存储后,它显示了以下错误-

enter image description here

我尝试了许多解决方案,包括以下更改-

How to Include 64-bit and 32-bit native code in my app

我也尝试了以下解决方案-

64 bit version issue in react-native android app by google play store

但是我没有将本机升级到0.59。

他们都没有为我工作。因此,我需要一个完美的解决方案来构建一个既可以32位又可以64位的apk,并且在上传到Play商店时不会显示任何错误。

1 个答案:

答案 0 :(得分:1)

添加"arm64-v8a", "x86_64"

在splits.abi.include中 喜欢

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }

source