0

I am using Embarcadero Delphi 10.4 for Android mobile development. I have installed Android SDK 25.2.5 32 and 64 bit installed under Target Platforms. I think, that is the default SDK for Delphi 10.4, I have not removed the default SDK and installed something different. That is fine.

Now Google Play Store requires every new app to target Android API level 31 and I am considering installing Android SDK 31.* inside my Delphi application. This can be quite hard, but nonetheless I am trying to follow Target Android API 29 on Delphi 10.3.3 and links provided there.

But before doing this I am observing strange thing. I have SDK 25 installed and appartenly I am doing build, compile against it. I have default AndroidManifest.template.xml in my source folder (and I have double checked by deleting it, that it is the default one) which has placeholders for the Android versions:

<uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="%targetSdkVersion%" />

Nonetheless, the final apk or aab packages contain completely different version numbers in their AndroidManifest.xml (as can be viewed by Android Studio 'Build - Analyze APK'):

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="..."
    platformBuildVersionCode="29"
    platformBuildVersionName="10"
    android:compileSdkVersion="29"
    android:compileSdkVersionCodename="10"
    android:installLocation="internalOnly"
    android:versionCode="19"
    android:versionName="1.0.19" >

    <uses-sdk
        android:minSdkVersion="23"
        android:targetSdkVersion="29" />

I am expecting that compile and target SDK versions would be 25, but they are 29 by some unknown reason!

So - if something inside Delphi Studio writes different compile and target SDK versions in the final AndroidManifest.xml, then there is no sense for me to add additionl Android SDK to the installed Target Platforms of my Delphi Studio.

So - why the SDK version of the Target Platform is different from the compile/target API level/Sdk version that is written into final AndroidManifest.xml?

TomR
  • 2,696
  • 6
  • 34
  • 87
  • 1
    "I am expecting that compile and target SDK versions would be 25, but they are 29 by some unknown reason!" Target SDK Version bears no relation to what the version of the base SDK is "there is no sense for me to add additional Android SDK to the installed Target Platforms of my Delphi Studio" Correct "why the SDK version of the Target Platform is different from the compile/target API level/Sdk version that is written into final AndroidManifest.xml?" See my first comment, and [this](https://developer.android.com/guide/topics/manifest/uses-sdk-element) – Dave Nottage Dec 07 '22 at 19:25

1 Answers1

0

OK, things are very tricky. It appears that under the SDK Manager and under particular SDK version there are particular build tools. E.g.

SDK base path may be:

C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.38860.1461

And ZipAlign location can point to specific build tools (one should scroll to the right end to see the essence of this string):

C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.38860.1461\build-tools\29.0.3\ZipAlign.exe

And SDK API-Level location has value (one should scroll to the right end to see the essence of this string):

C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.38860.1461\platforms\android-29

This is not the full answer, but this is some hint where to look further. Currently I have no idea how SDK 25 can have special build tools for 29 and yet produce fully API level 29 compatible source and how to installa such build tools? E.g. are there build tools for API 31 for SDK 25? Or should I install more recent SDK (not necessarily 31) and it can have build tools for API 31?

Note - API 31 is the level required by Google Play Store are of 2022.12.

TomR
  • 2,696
  • 6
  • 34
  • 87
  • 1
    Delphi 11.2 inserts a value of 32 for targetSdkVersion by default, 11.1 inserts 31. You can "hard-code" the value yourself by modifying `%targetSdkVersion%` in `AndroidManifest.template.xml`, however you need to ensure that the manifest, and your app, is compliant with that API level. See [here](https://developer.android.com/about/versions/12/behavior-changes-12#exported), for example. – Dave Nottage Dec 07 '22 at 19:32