I have programmed extensively using Android Studio in the past, but I have encountered an issue when trying to create a simple "Empty Views Activity" using Android Studio Ladybug 2024.2.1 Patch 2 (the latest version available at the time of this writing). In file build.gradle.kts, I see a warning that I am not targeting the latest version of Android.
However, if I change the value of targetSdk to 35 to match the value of compileSdk, it shows that I have an error.
But … The app appears to build and to run correctly with either value for targetSdk. Any suggestions as to how to get rid of this warning/error?
2
Answers
To distribute on the Play Store, you will need to target API Level 35 by sometime in the fall of 2025. Hence, the warning.
The error is that Google thinks that you don’t know what you’re doing. 🙃 If you hover your mouse over the error, the popup should read:
Choose "Override warning: I know what I’m doing" to suppress the "error". You can get the same option via a quick-fix context action (e.g., Option-Enter with your text cursor in the error).
The warning: Android studio is asking your app to consider supporting the latest version of Android, ie, Android 15 (API Level 35). Once a new version of Android is released, typically there’s a grace period of 1 year for new apps and 2 years for existing apps to update the targetSdk to the latest android version. After that if you don’t update to the latest version,
You won’t be able to publish new apps. Google play will reject it
If you don’t update your existing app to latest targetSdk, your app will become undiscoverable on Google play store. People won’t be able to find your app, but your existing users will be able to
The error: Probably a false positive. Try cutting that line and pasting it again. Sometimes Android studio do this and error will go away once you remove the line of code and reinsert. Sometimes it’ll go away after compiling. Sometimes it requires us to close and open the file. If it’ still there, try restarting Android Studio
Now, if you’re able to compile, you’re good to go but that doesn’t mean your app will work fine on Android 15. Simply changing targetSdk to suggested/required version is not a fool-proof way to update the app to the latest version of Android. Some features may not work as expected when you run the app on devices with latest Android. You need to test it and if anything’s broken, update your code accordingly. If everything’s fine on an actual device with latest version of android, there’s nothing to worry about