Android Studio(Java)应用发布Google Play遇64位兼容错误求助
解决Google Play 64位架构要求错误
问题说明
该版本不符合Google Play的64位要求。以下APK或App Bundle可用于64位设备,但仅包含32位原生代码:[1] 请在应用中同时包含64位和32位原生代码。使用Android App Bundle发布格式可自动确保各设备架构仅获取所需原生代码,避免增大应用整体体积。
我用Android Studio(Java)开发应用,发布时遇到上述错误,当前build.gradle配置如下:
apply plugin: 'com.android.application' android { compileSdkVersion 33 defaultConfig { minSdkVersion 22 targetSdkVersion 33 versionCode 12 versionName "1.2.2" multiDexEnabled true ndk { abiFilters "armeabi-v7a", "arm64-v8a" } splits { abi { include "armeabi-v7a", "arm64-v8a" } } applicationVariants.all { variant -> variant.outputs.each { output -> def versionCodes = ["armeabi-v7a":1, "arm64-v8a":2] def abi = output.getFilter(com.android.build.OutputFile.ABI) if (abi != null) { output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } } testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets.main { jniLibs.srcDirs 'src/main/libs' } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') //noinspection GradleCompatible implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.firebase:firebase-storage:20.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.navigation:navigation-fragment:2.2.1' implementation 'androidx.navigation:navigation-ui:2.2.1' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //support implementation 'com.google.android.material:material:1.1.0' implementation 'com.jcodecraeer:xrecyclerview:1.6.0' implementation 'androidx.recyclerview:recyclerview:1.3.1' implementation 'androidx.cardview:cardview:1.0.0' implementation 'com.github.bumptech.glide:glide:4.9.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0' //vector,percent,palette implementation 'androidx.palette:palette:1.0.0' implementation 'androidx.percentlayout:percentlayout:1.0.0' implementation 'androidx.vectordrawable:vectordrawable:1.1.0' //equlizer implementation 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2' implementation 'com.joanzapata.iconify:android-iconify-entypo:2.2.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.github.smarteist:autoimageslider:1.1.1' //data implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.android.volley:volley:1.2.1' implementation 'org.apache.commons:commons-io:1.3.2' //youtubeplayer implementation 'com.github.PierfrancescoSoffritti:androidyoutubeplayer:7.0.1' //Ads implementation 'com.google.android.gms:play-services-ads:21.5.0' implementation 'com.henryblue.mxvideoplayer:xvideoplayer:1.2.1' implementation 'com.firebase:firebase-client-android:2.5.0' implementation 'agency.tango.android:material-intro-screen:0.0.3' implementation 'com.github.fornewid:neumorphism:0.2.1' }
解决步骤
1. 排查第三方依赖的64位支持
你的配置里已经指定了abiFilters包含32位和64位架构,但错误依然存在,大概率是某个第三方依赖只提供了32位原生库:
- 检查项目
libs目录下的jar包,若附带原生库,确认是否有对应的arm64-v8a版本的.so文件 - 逐个排查依赖库,比如
com.henryblue.mxvideoplayer:xvideoplayer:1.2.1这类带原生代码的库,替换为支持64位的版本,或联系开发者获取64位兼容库
2. 改用Android App Bundle发布(官方推荐)
App Bundle会自动为不同架构设备生成对应APK,既能满足64位要求,又能减小用户下载体积:
- 删掉
build.gradle中splits和applicationVariants相关的ABI拆分代码 - 在Android Studio中选择
Build > Generate Signed Bundle / APK,选Android App Bundle完成签名 - 上传生成的
.aab文件到Google Play Console即可
3. 确认本地原生库完整性
如果应用使用了自定义JNI代码或本地库,检查src/main/libs目录下是否同时存在armeabi-v7a和arm64-v8a文件夹,且每个文件夹内都有对应的.so文件
4. 验证APK架构支持
生成release APK后,用aapt命令验证是否包含64位代码:
aapt dump badging your-app-release.apk | grep "native-code"
正常输出应该同时包含arm64-v8a和armeabi-v7a
内容的提问来源于stack exchange,提问作者Muhammad Manzoor
相关产品推荐
相关产品推荐

