skip to Main Content

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.
partial screen image showing warning

However, if I change the value of targetSdk to 35 to match the value of compileSdk, it shows that I have an error.
partial screen image showing 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


  1. I see a warning that I am not targeting the latest version of Android

    To distribute on the Play Store, you will need to target API Level 35 by sometime in the fall of 2025. Hence, the warning.

    However, if I change the value of targetSdk to 35 to match the value of compileSdk, it shows that I have an error.

    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:

    It looks like you just edited the targetSdkVersion from 34 to 35 in the editor. Be sure to consult the documentation on the behaviors that change as result of this. The Android SDK Upgrade Assistant can help with safely migrating…

    error popover

    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).

    Login or Signup to reply.
  2. 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,

    1. You won’t be able to publish new apps. Google play will reject it

    2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search