Android Version Adaptation Guide
This skill provides a comprehensive checklist and solution guide for adapting Android applications to newer Android versions, ranging from Android 8.0 (Oreo) to Android 15.
🚀 Adaptation Strategy
- •Update
targetSdkVersion: Update incrementally and test. - •Review Changes: Check behavior changes for the specific version.
- •Test: Test on emulators or real devices running the target version.
📱 Version-Specific Changes
Android 15 (API 35)
- •Edge-to-Edge: Enforced by default for targetSDK 35.
- •Opt-out (Temporary):
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>in theme. - •Deprecated:
window.statusBarColor,window.navigationBarColor.
- •Opt-out (Temporary):
- •Audio Focus: Restricted for background apps unless they are top-level or running a specific foreground service.
- •Screen Recording: New callback
WindowManager.addScreenRecordingCallback(RequiresDETECT_SCREEN_RECORDING). - •PDFRenderer: Major improvements in API.
Android 14 (API 34)
- •Foreground Services: Must specify
android:foregroundServiceTypein Manifest.- •Types:
camera,location,mediaPlayback,dataSync,microphone,phoneCall, etc. - •Example:
<service android:name=".MyService" android:foregroundServiceType="mediaPlayback" />
- •Types:
- •Media Permissions: Partial access support via
READ_MEDIA_VISUAL_USER_SELECTED. - •Screen Capture: New permission
DETECT_SCREEN_CAPTUREfor screenshot listening. - •JobScheduler:
RUN_USER_INITIATED_JOBSpermission required for user-initiated data transfers.
Android 13 (API 33)
- •Notifications: Runtime permission
POST_NOTIFICATIONSis required to post notifications. - •Media Permissions: Granular permissions replace
READ_EXTERNAL_STORAGE:- •
READ_MEDIA_IMAGES - •
READ_MEDIA_VIDEO - •
READ_MEDIA_AUDIO
- •
- •Wifi:
NEARBY_WIFI_DEVICESpermission for local Wi-Fi scanning (no location needed).
Android 12 (API 31/32)
- •PendingIntent: Must specify
PendingIntent.FLAG_IMMUTABLEorPendingIntent.FLAG_MUTABLE. - •Exported Components: Must explicitly set
android:exported="true"or"false"for activities/services/receivers with intent filters. - •Bluetooth: New runtime permissions
BLUETOOTH_SCAN,BLUETOOTH_CONNECT,BLUETOOTH_ADVERTISE.
Android 11 (API 30)
- •Package Visibility: Apps can no longer see all installed packages. Use
<queries>in Manifest to declare packages you interact with. - •Scoped Storage: Forced enforcement.
WRITE_EXTERNAL_STORAGEis deprecated.- •Use
MANAGE_EXTERNAL_STORAGEfor file manager apps (requires Google Play review).
- •Use
- •Toast: Custom toasts from background blocked.
- •Status Bar: Use
WindowInsetsto get height instead of legacy methods.
Android 10 (API 29)
- •Scoped Storage: Introduced. Use
requestLegacyExternalStorage="true"in Manifest for temporary opt-out. - •Location:
ACCESS_BACKGROUND_LOCATIONrequired for accessing location while app is in background. - •IMEI/Serial: No longer accessible to non-system apps. Use Android ID or GUID.
Android 9.0 (API 28)
- •Network: Cleartext (HTTP) disabled by default.
- •Fix: Add
android:usesCleartextTraffic="true"in Manifest or configurenetwork_security_config.xml.
- •Fix: Add
- •Foreground Service: Requires
FOREGROUND_SERVICEpermission (normal permission, auto-granted). - •Apache HTTP: Library removed. Add
<uses-library android:name="org.apache.http.legacy" android:required="false"/>to Manifest. - •Notch Support: Use
WindowInsetsorDisplayCutoutto handle notches.
Android 8.0 (API 26)
- •Install APK: Requires
REQUEST_INSTALL_PACKAGESpermission and user authorization. - •Notifications: Notification Channels are mandatory. All notifications must be assigned to a channel.
- •Background Execution: Strict limits on background services and implicit broadcasts.
- •Translucent Activity: Crash if fixed orientation (e.g.,
screenOrientation="portrait") is set on a translucent activity. Fix: remove orientation or translucency.
🛠 Common Solutions
FileProvider Configuration (Android 7.0+)
Required for sharing files (installing APKs, taking photos).
xml
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
Network Security Config (Allow HTTP)
res/xml/network_security_config.xml:
xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
Checking Notification Permission (Android 13+)
kotlin
if (Build.VERSION.SDK_INT >= 33) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 101)
}
}