pcplayer99 11 Posted November 23, 2021 I have installed Delphi 10.4.2 CE version. All configurations is default by delphi installer. My phone is OPPO and its Android version is Android 11. New a FireMonkey project, connected my phone to my PC, and run it, everythiing is OK. But if I upload this APP to Google play APP store, it says APP's API level is 29, it must be API level 30. I run "C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.40680.4203\SDK Manager.exe“, it is installed by Delphi. And there are Android 10 (API 29), Android 9(API 28) ... etc. There are no API 30. So, I run "C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.40680.4203\tools\bin\sdkmanager.bat" to download API 30 and its done. And then re-start "SDK Manager.exe", I can see "Android 11(API 30)" in it. And in this directroy "C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.40680.4203\platforms", there was added a directory named "android-30". So it seems I have API 30 in my system. In Delphi IDE menu: Tools - Options - Deployment - SDK Manager, SDK API-level location option is set by Delphi, it is "C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.40680.4203\platforms\android-29", I changed it to "C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.40680.4203\platforms\android-30"; And then re-deploy this APP and upload to Google play, it still says my APP is on API 29. I can not find any tips in IDE menu to change API level, so I check "AndroidManifest.xml" under "D:\MyProjectFile\Android64\Release", there is: <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="29" /> I try to modify "D:\MyProjectFile\AndroidManifest.template.xml" from default: <uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="%targetSdkVersion%" /> to: <uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="30" /> to force it be API-30. And re-build, deploy, and then upload to Google play, it works. No warning messages. But, if I set project's "Configuration" to "Development" in IDE and press F9 to let it run in my phone, when it is installing in my phone, it is failed, and Delphi shows error message: adb: failed to install D:\MyProjectFile\Android64\Debug\testAndroid_11\bin\testAndroid_11.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES] And then I change "AndroidManifest.template.xml" to default, and re-build and deploy and press F9, it has installed in my phone success and worked fine. And then I check "AndroidManifest.xml", it is "<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="29" /> " again. Repeat modify "AndroidManifest.template.xml" again and again, I'm sure if I set targetSDKVersion=29, it can install in my phone successed, if I changed it to targetSDKVersion=30, it install in my phone will be failed and the error message is: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]. If I change targetSDKVersion=29 to targetSDKVersion=30, and then set my project Configuration to "Application Store" build and deploy then I got my AAB file and can upload Google play successed, but I am not sure if it can installing success when a phone install it from Google play. I have searched on internet, but no any message about this. Share this post Link to post
Dave Nottage 557 Posted November 23, 2021 7 hours ago, pcplayer99 said: Repeat modify "AndroidManifest.template.xml" again and again, I'm sure if I set targetSDKVersion=29, it can install in my phone successed, if I changed it to targetSDKVersion=30, it install in my phone will be failed and the error message is: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]. It's because Delphi 10.4.2 is using Jarsigner instead of APKSigner, which is required for APKs with a target SDK of 30 or higher. There are ways around it, however you are just delaying the inevitable. The bottom line is: If you want to stay current with Android development (or iOS, especially if deploying to the app stores), stay current with Delphi. Share this post Link to post
pcplayer99 11 Posted November 24, 2021 Thanks Vave. According to your tips, I googled on line and got this: xamarin.android - Xamarin App - Can't deploy to Android 11 emulator - Stack Overflow Its says that: "Apps that target Android 11 (API level 30) that are currently only signed using APK Signature Scheme v1 must now also be signed using APK Signature Scheme v2 or higher. Users can't install or update apps that are only signed with APK Signature Scheme v1 on devices that run Android 11." Share this post Link to post
Dmitry Sh. 8 Posted November 24, 2021 (edited) For sign apk by Jarsigner ( APK Signature Scheme v2 ) you need: 1. Edit CodeGear.Deployment.Targets add section <Target Name="_AndroidApkSigner" Condition="('$(Platform)'=='$(cAndroid32ArmPlatform)' Or '$(Platform)'=='$(cAndroid64ArmPlatform)') And '$(KeyStoreFile)'!='' And '$(AndroidAppBundle)'=='false'"> <Message Text="Start Apk Signer."/> <Exec Command=""$(ApkSigner)" sign --ks $(KeyStoreFile) --ks-pass pass:$(KeyStorePass) $(SIGNED_APK_FILENAME)" ContinueOnError="True"> <Output TaskParameter="ExitCode" PropertyName="ErrorCode"/> <Output TaskParameter="StdOutEncoding" PropertyName="StdOut"/> </Exec> </Target> 2. add line _AndroidApkSigner; in section <DeployDependsOnTargets> <PropertyGroup> <DeployDependsOnTargets> ... _CheckKeyStore; _AndroidSign; _AndroidZipAlign; _AndroidApkSigner; _CheckAPKFileOutputResult; _CheckAABFileOutputResult; _DeleteAndroidAssetsInfoFile; ... </DeployDependsOnTargets> 3. Create New IDE Environment Variable ApkSigner with value (SDK path)\android-sdk-windows\build-tools\29.0.2\apksigner.bat Thanks to Stas for this solution diff for file CodeGear.Deployment.Targets Edited November 24, 2021 by Dmitry Sh. 2 1 Share this post Link to post
pcplayer99 11 Posted November 24, 2021 Thanks Dmitry. It works! A little update: <Exec Command=""$(ApkSigner)" sign --ks $(KeyStoreFile) --ks-pass pass:$(KeyStorePass) $(SIGNED_APK_FILENAME)" ContinueOnError="True"> when open project, it shows a error message, and then fail. I look through carefully the CodeGear.development.Targets file, found that: <Exec Command=""$(BDS)\bin\convert.exe" -b -e.fsx "%(ConvertForm.BaseName)"" ContinueOnError="True"> <Exec Command=""$(BDS)\bin\convert.exe" -b -e.fsx "%(ConvertForm.BaseName)"" ContinueOnError="True"> So, I update the above line to: <Exec Command=""$(ApkSigner)" sign --ks $(KeyStoreFile) --ks-pass pass:$(KeyStorePass) $(SIGNED_APK_FILENAME)" ContinueOnError="True"> And open project successed. And then I can install APK to my phone after I update android:targetSdkVersion="30" Thanks a lot. Share this post Link to post
pcplayer99 11 Posted November 25, 2021 Hi Dmitry, My new progress: Yesterday I have tested Android API-level 30 at a new blank FMX project, it's OK. And then I have tested a old project at release mode, it still report the same error message: INSTALL_PARSE_FAILED_NO_CERTIFICATES But if I selected debug mode, the same old project can install successed at API-level 30. I compared all XML files of release mode and debug mode but can not find anything. But if I change API-level 30 to 29 at release mode, it can installed successed. Finally, I created a new project and added all files of the old project into it, and then at Android release mode, changed API-level to 30, builded and deployed to my phone, it was successed. thanks Dmitry. Share this post Link to post
davornik 4 Posted February 6, 2022 Thank you for yours post, this also helped me to upload app to Google store. Just to make things clearer to download android-30 you must: - run cmd.exe - type cd [path] to go to location where sdkmanager.bat is (usually it is: C:\Users\Public\Documents\Embarcadero\Studio\21.0\PlatformSDKs\android-sdk-windows\tools\bin or C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.40680.4203\tools\bin) - type sdkmanager "platforms;android-30" - answer y on question, and wait until it says "done" Everything else is straightforward... Share this post Link to post
aetsmith 0 Posted May 18, 2022 Hi pcplayer99, I am battling with trying to publish to playstore using delphi community edition but hit the api 30 barrier. Tried following your "fix" but get lost at the codegear file. Where do I find this? Thanks Andy Share this post Link to post
Dave Nottage 557 Posted May 18, 2022 9 hours ago, aetsmith said: but get lost at the codegear file. Where do I find this? It's in the bin folder of your Delphi installation, e.g. C:\Program Files (x86)\Embarcadero\Studio\21.0\bin Share this post Link to post
aetsmith 0 Posted May 19, 2022 Thanks Dave I edited the file as required however it does not seem to make any difference at all and setting target SDK version to 30 causes a fail in installation on my cell phone whereas with 29 it works fine. Any assistance will be most appreciated. Share this post Link to post
aetsmith 0 Posted May 19, 2022 15 hours ago, Dave Nottage said: It's in the bin folder of your Delphi installation, e.g. C:\Program Files (x86)\Embarcadero\Studio\21.0\bin Thanks Dave I edited the file as required however it does not seem to make any difference at all and setting target SDK version to 30 causes a fail in installation on my cell phone whereas with 29 it works fine. Any assistance will be most appreciated. Share this post Link to post