← Back to context

Comment by ploxiln

1 day ago

You do need a newer SDK to update the target-sdk-version though. And you may find that libraries you used are not compatible, unless you update them, and updating them may break things. Maybe for a minimal app in pure java or kotlin this won't be a problem.

There was an open-source app that hasn't been updated in a few years that was delisted from the store. I decided to try my hand at recompiling to target latest required sdk "target" or whatever. It used Xamarin / C# and some additional libraries. It does not talk to the internet, it's just a minimal remote-control and data-logger for a bluetooth multimeter. If you can find a copy of the last APK published and sideload it, it works. But if you try to update the SDK so you can target the required SDK version for the Play Store, compile fails, misc cryptic errors due to libraries. Updating libraries was tricky for me because while I'm quite familiar with C, C++, Python, Go (etc), I'm not at all familiar with Android, Java, Kotlin, nor C#, visual-studio, etc. After a few days of struggle I managed to update libraries and fix the build, but the app's layout was totally broken, only one button appears (and again I'm not familiar with any of this stuff).

This app really didn't need any updates. It's a < 20MB app to control a local device, and it still works. At least you can still side-load it. Sheesh.

> You do need a newer SDK to update the target-sdk-version though.

No you don't.

You probably should just use an older version of Android Studio for your case which supports the original compileSdkVersion from the original gradle build. Then update the targetSdkVersion in the manifest and that's it.

  • While you are technically correct (the best kind of correct), official guidance is to use support libraries that are at least as new as the targetSdkLevel, so if you follow that recommendation you still have to update.

    Also, I try to at least do the bare minimum level of testing the app still works after rebuilding by launching the app in the emulator once (I don't usually have a phone that runs the newest API level), which means downloading at least a new emulator image.

    In practice it's just easier to update the entire platform.

  • > If your app barely uses any permissions (like TFA's apps), you just need to update the targetSdkVersion in the manifest

    And what if you do use permissions for stuff like, say, external storage access, don't you need a recent SDK so you can use the APIs for things like the run-time permission requests now mandatory? But I believe the Android SDK removed support for building with ant years ago. And lets say I'm using a legacy framework with an incredibly contrived ant- (and bash-)based build system which there's no way I'm rewriting. Therefore, I'm in big trouble, am I not? Honest question.

    • Runtime permissions where introduced in 2015 with Android 6.0 (SDK 23).

      So you indeed need to use a new enough Android Studio and compile against SDK 23. You need to use the new API, I think the easiest way is to add a button and call requestPermissions() [1], you can leave the rest of the code unmodified.

      Also, note that Google Play does not allow the external storage access permission except if it's a file manager app. It's better to use the SAF API (since Android 4.4 SDK 19) instead. Depending on your app, that may need bigger changes.

      By the way, I'm working on a syscall interception framework[2] that could in theory intercept the file io syscalls and redirect them to use the SAF API. That would need only minimal changes to your app and also would allow to run things like syncthing unmodified.

      You need to make these changes anyway, because Android 14+ can not install apps with targetSdkVersion < 23.

      [1] https://developer.android.com/training/permissions/requestin...

      [2] https://github.com/lukasstraub2/intercept-anything