关于Android 10版Google Play Store停止接受targetSdkVersion 28应用的咨询
Hey fellow developer, let's break down the exact rules around Google Play's target SDK restriction for Android 10 (API 29) and walk through actionable technical steps to get your app compliant.
Exact Rule Details
Google Play Store will no longer accept new apps or app updates targeting API level 28 (Android 9 Pie) when distributing to devices running Android 10 (API 29) or later. This is a mandatory enforcement to ensure apps adopt the latest security, privacy, and performance features of the Android ecosystem.
This rule isn't just a checkbox—Google's pushing this to ensure apps follow modern Android best practices, like scoped storage, refined location permissions, and background behavior restrictions that protect user privacy and device performance.
Technical Action Plan to Comply
1. Upgrade targetSdkVersion to 29 (or Higher)
First, update your module-level build.gradle file to set the target SDK to at least 29. For best practice, match it with the latest stable compileSdkVersion:
android { defaultConfig { targetSdkVersion 29 // You can go higher, like 33 or 34, for newer features compileSdkVersion 34 // Use the latest stable SDK version available } }
Note: compileSdkVersion should always be equal to or higher than targetSdkVersion to ensure you're compiling against the latest API definitions and tools.
2. Adapt to Android 10's Key Behavior Changes
Upgrading targetSdkVersion triggers Android 10's strict enforcement of new platform behaviors—here are the most critical ones to address:
- Scoped Storage: Android 10 restricts direct access to external storage (like the Downloads or DCIM folders). Instead, use the
MediaStoreAPI to access media files, or the Storage Access Framework (SAF) for user-selected files. If your app is a file manager or similar, you can apply for theMANAGE_EXTERNAL_STORAGEpermission, but this requires Google's manual review. - Location Permissions: Android 10 adds the
ACCESS_BACKGROUND_LOCATIONpermission. If your app needs location data while in the background, you must request this permission separately (alongside foreground location permissions) and clearly explain its use to users. - Background Activity Restrictions: Apps can no longer start activities from the background unless triggered by user interaction (like tapping a notification) or specific high-priority scenarios. Adjust your app's logic to avoid background activity launches.
- Privacy Enforcement: Permissions can only be requested while your app is in the foreground—background permission requests are blocked entirely.
3. Test Thoroughly
- Run full functional tests on an Android 10 (API 29) device or emulator, focusing on storage, location, and background features that are affected by the SDK upgrade.
- Use Android Studio's Lint tool to scan for deprecated APIs, compatibility issues, and violations of Android 10's rules. Lint will flag specific code snippets that need adjustment.
4. Temporary Transition (If Needed)
If your app is complex and needs more time to adapt to scoped storage, you can enable legacy storage access temporarily by adding this attribute to your AndroidManifest.xml:
<application android:requestLegacyExternalStorage="true" ...> <!-- Your app components --> </application>
Important: This attribute stops working when targetSdkVersion is set to 30 or higher, so it's only a short-term fix. You'll still need to fully adapt to scoped storage eventually.
内容的提问来源于stack exchange,提问作者user9615788

