Android Question Supplemental Files for Specific Android Versions

andrewj

Active Member
Licensed User
Longtime User
Hi,

I have a problem that I need to provide a different version of two large resource files for Android KitKat compared with earlier versions. I had thought about downloading them from my web site, but that's potentially tricky for the user. Then I thought about an "in app upgrade" which triggers just when the app has been upgraded and the user is running KitKat.

Is there a way to do this in B4A, and if so is there an example anywhere?
Thanks
Andrew
 

DonManfred

Expert
Licensed User
Longtime User
You get check for KitKat with this Code snippets. Or maybe i did not understand the question ;)
 
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
Sorry, you mis-understood. I know how to check the Android version. What I want to know is whether I can use something like an in-app upgrade to deliver different files, as I don't want to bloat the APK with KitKat specific versions.
Andrew
 
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
Hi Erel,
Thanks for the reply. I did think about downloading the additional files from my own web server, but I'd prefer to do it all through Google Play if possible.

If I create two versions of the APK is there a way to set up the app and Google Play account to say "use this version for Android 18 SDK or less, use that version for 19 or higher", as I can't see how to do that, so that users automatically get the right version but I appear to have one "app"?

Alternatively I'm wondering about doing this as an "add-on", using the in-app billing API. I've found the tutorial for in-app billing, but I can't find out how to create an add-on. Can you point me to the right place?

Thanks
Andrew
 
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
Thanks Erel, I think the multiple APK solution is exactly right for me.

However, I'm having a problem. I've added the following code to my manifest:
B4X:
#If NORMAL
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="19"/>
#End If
#If KITKAT
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19"/>
#End if
However it's not working. When testing the normal version I'm getting the following error which suggests that the KITKAT line is being included in the manifest:
B4X:
Installing file to device.              Error
    pkg: /data/local/tmp/stashit.apk
Failure [INSTALL_FAILED_OLDER_SDK]
Can you see what I'm doing wrong?

Thanks
Andrew
 
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
Sorry, I think you're wrong. I do not need to change the packagename - this is explicitly required to be the same for both versions by Google.
I think the problem is just with the #If syntax.

Thanks anyway
Andrew
 
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
No, I have never installed a KitKat version. The old code before I tried this change was this line:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="19"/>

Andrew
 
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
Yes, I have modified the Default config with the symbol NORMAL, and a new KitKat config with the symbol KITKAT. Do I need a separate config for Normal?

Thanks
Andrew
 
Last edited:
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
Update: I've tried creating a second config with the symbol NORMAL, but it doesn't solve the problem.
Thanks
Andrew
 
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
I have similar code in the Project Attributes section, and I can see the right lines being greyed out depending on the active config, so this is specific to the manifest. Are there any special rules for the manifest?
Thanks
Andrew
 
Upvote 0

andrewj

Active Member
Licensed User
Longtime User
Cracked it!

The conditional compilation does not work inside a section of the manifest. It does work for complete sections, as follows:
B4X:
#If NORMAL
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:hardwareAccelerated="true"
    android:anyDensity="true"/>)
#End If

Andrew
 
Upvote 0
Top