如何解决"The following APKs or App Bundles are available to 64-bit devices, but they only have 32-bit native code: XXX"?
How to solve "The following APKs or App Bundles are available to 64-bit devices, but they only have 32-bit native code: XXX"?
在我的 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'
构建 apk 后,我在 32 位和 64 位设备上都进行了测试,它运行良好,但是在将发布的 apk 提交到 Play 商店后,它显示以下错误-
我尝试了很多解决方案,包括以下更改-
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 并没有发生。
None 其中对我有用。所以,我需要一个完美的解决方案来构建一个 32 位和 64 位的 apk,并且在上传到 Play 商店时不会显示任何错误。
添加"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"
}
}
在我的 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'
构建 apk 后,我在 32 位和 64 位设备上都进行了测试,它运行良好,但是在将发布的 apk 提交到 Play 商店后,它显示以下错误-
我尝试了很多解决方案,包括以下更改-
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 并没有发生。
None 其中对我有用。所以,我需要一个完美的解决方案来构建一个 32 位和 64 位的 apk,并且在上传到 Play 商店时不会显示任何错误。
添加"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"
}
}