升级至Target SDK 35后Google Play内部测试提示适配旧版Android
问题
为解决Google Play政策问题,将旧Android应用升级至Target SDK 35,已处理废弃代码。通过adb install可在模拟器和Pixel真机正常安装APK,但通过Google Play内部测试链接访问时,页面提示"应用适配旧版Android",无下载入口。相关配置文件如下:
模块build.gradle
apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' android { compileSdk 35 // Updated to SDK 35 namespace 'com.ushc.mobile.PersonalHealthDashboard' compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } tasks.withType(JavaCompile).configureEach { options.compilerArgs << "-Xlint:deprecation" } defaultConfig { minSdkVersion 30 targetSdkVersion 35 targetSdk 35 // Updated to SDK 35 versionCode 57 versionName "1.0" // vectorDrawables.useSupportLibrary = true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' signingConfig signingConfigs.debug } debug { debuggable true } } // androidResources { // noCompress 'property' // } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'androidx.biometric:biometric:1.1.0' // Or latest implementation 'androidx.preference:preference:1.2.1' // Testing testImplementation 'junit:junit:4.13.2' // AndroidX support // implementation 'androidx.appcompat:appcompat:1.7.0' // Or latest // External JAR dependencies implementation files('lib/PhotoUtil.jar') implementation files('lib/GenAsync.1.2.jar') // Firebase dependencies implementation platform('com.google.firebase:firebase-bom:33.10.0') // Or latest implementation 'com.google.firebase:firebase-analytics:22.3.0' implementation 'com.google.firebase:firebase-appindexing:20.0.0' implementation 'com.google.firebase:firebase-messaging:24.1.0' }
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" <uses-feature android:name="android.hardware.screen.portrait" android:required="false" /> <uses-feature android:name="android.hardware.camera2" android:required="false" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="35" />--> <!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />--> <uses-permission android:name="android.permission.USE_BIOMETRIC" /> <application android:usesCleartextTraffic="true" android:allowBackup="true" android:icon="@drawable/heart_logo_2" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name="com.ushc.mobile.<hidden>.Login" android:exported="true" <intent-filter> <action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.ushc.mobile.<hidden>.MainMenu" android:exported="true" /> <activity android:name="com.ushc.mobile.<hidden>.WebView" android:configChanges="orientation|screenSize" android:exported="true" /> <activity android:name="com.ushc.mobile.<hidden>.NotificationHome" android:exported="true" /> <activity android:name="com.ushc.mobile.<hidden>.CampaignList" android:exported="true" /> <activity android:name="com.ushc.mobile.<hidden>.EventDetails" android:exported="true" /> <activity android:name="com.ushc.mobile.<hidden>.UploadPhoto" android:exported="true" /> <service android:name="com.ushc.mobile.<hidden>.Notification" android:enabled="true" android:exported="true" /> <activity android:name="com.ushc.mobile.<hidden>" android:exported="true" android:theme="@style/AppTheme.CustomPopupTheme" /> <activity android:name="com.ushc.mobile.<hidden>" android:exported="true" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <service android:name=".FirebaseMessageReceiver" android:exported="true" android:permission="TODO" <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> </application> </manifest>
项目根目录build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() mavenCentral() // Replacing jcenter() as it is deprecated } dependencies { classpath 'com.android.tools.build:gradle:8.6.0' classpath 'com.google.gms:google-services:4.4.2' // Updated Google Services Plugin // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() mavenCentral() } } //tasks.register('clean', Delete) { // delete rootProject //}
解决方案
以下是针对性的排查和修复步骤:
- 使用正式签名的Release包上传:当前模块build.gradle的release构建配置使用
signingConfig signingConfigs.debug,Google Play不接受debug签名的APK,必须替换为正式的上传密钥签名。生成正式签名包后重新上传至内部测试轨道。 - 检查Google Play控制台的版本映射:确认内部测试轨道中,versionCode 57的APK已成功上传并被正确解析,没有旧版本的APK仍处于活跃状态。可以在控制台的"版本管理"->"应用版本"中查看APK的targetSdk信息。
- 清理Gradle配置冗余:模块build.gradle的defaultConfig中同时存在
targetSdkVersion 35和targetSdk 35,保留其中一个即可(推荐标准的targetSdkVersion),避免Gradle解析歧义。 - 修复Manifest的无效配置:Firebase消息服务的
android:permission="TODO"是无效值,需删除该属性或替换为正确权限(如com.google.android.c2dm.permission.SEND),否则会导致Manifest合法性校验失败,Play可能判定应用配置异常。 - 验证APK的实际targetSdk值:使用命令
aapt dump badging your-release-apk.apk查看输出中的targetSdkVersion字段,确认实际打包的APK确实为35。若不符,执行./gradlew clean清理缓存后重新构建。 - 确认测试设备的兼容性:确保用于测试的设备系统版本≥minSdkVersion 30,若设备版本低于30,会看不到下载入口。
内容的提问来源于stack exchange,提问作者Larry
相关产品推荐
相关产品推荐

