【问题标题】:How to solve "The following APKs or App Bundles are available to 64-bit devices, but they only have 32-bit native code: XXX"?如何解决“以下 APK 或 App Bundle 可用于 64 位设备,但它们只有 32 位原生代码:XXX”?
【发布时间】:2020-01-11 20:47:33
【问题描述】:

在我的 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 提交到 play store 后,它显示以下错误-

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

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

但我的 react-native 升级到 0.59 并没有发生。

它们都不适合我。所以,我需要一个完美的解决方案来构建一个 32 位和 64 位的 apk,并且在上传到 Play 商店时不会显示任何错误。

【问题讨论】:

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


【解决方案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

【讨论】:

  • 我是否需要在 ndkdef versionCodes = ["armeabi-v7a":1, "x86":2] 中进行任何更改?
  • 是的,最好的解决方法是生成android app buldle
  • 这对我有用,我用过 android app buldle
  • 我的 react-native 版本是 0.57.8 。这个版本有什么问题吗?
  • 我觉得那个版本不支持,更新到0.59以上,github.com/facebook/react-native/issues/…
猜你喜欢
  • 2020-02-03
  • 1970-01-01
  • 2019-12-28
  • 2020-05-03
  • 2020-03-07
  • 2020-09-21
  • 1970-01-01
  • 2012-02-10
相关资源
最近更新 更多