android-targetSdkVersion doesn't have any influence on generated apk

  • 1
  • Problem
  • Updated 5 years ago
  • Acknowledged
Hi,

i pushed the hello world app to my github repository ( https://github.com/lategoodbye/testApp ) and now i want to configure the android api version to 16. Unfortunately the setting android-targetSdkVersion in config.xml doesn't have any effect and the result will always have api version 22.

What's wrong with my config?
Photo of Stefan Wahren

Stefan Wahren

  • 5 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of jcesarmobile

jcesarmobile

  • 283 Posts
  • 40 Reply Likes
how do you know it's not set to 16?
Photo of Stefan Wahren

Stefan Wahren

  • 5 Posts
  • 0 Reply Likes
From the build log:


-build-setup:
[getbuildtools] Using latest Build Tools: 23.0.1
[echo] Resolving Build Target for .HelloWorld...
[gettarget] Project Target: Android 5.1.1
[gettarget] API level: 22
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: /project/CordovaLib/res
[mkdir] Created dir: /project/CordovaLib/libs
[mkdir] Created dir: /project/CordovaLib/bin
[mkdir] Created dir: /project/CordovaLib/bin/res
[mkdir] Created dir: /project/CordovaLib/bin/rsObj
[mkdir] Created dir: /project/CordovaLib/bin/rsLibs
[mkdir] Created dir: /project/CordovaLib/gen
[mkdir] Created dir: /project/CordovaLib/bin/classes
[mkdir] Created dir: /project/CordovaLib/bin/dexedLibs
[echo] ----------
[echo] Resolving Dependencies for .HelloWorld...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
Photo of ColinBau

ColinBau

  • 730 Posts
  • 18 Reply Likes
hi Stefan
according to this (you can search "What is API Level" keyword)
http://developer.android.com/guide/to...
API level: 22 means Android 5.1

I guess for now the PGB's "android-targetSdkVersion" is 22,so...the build log will always show 22
default value => <preference name="android-targetSdkVersion" value="22" />

but now you set "android-targetSdkVersion" manually,could you try to set the "android-minSdkVersion" or "android-maxSdkVersion" too ?
In most cases,we should just set "android-minSdkVersion"
Photo of Vratislav

Vratislav

  • 12 Posts
  • 0 Reply Likes
Hi all,
I have in my config.xml this:

<preference name="android-minSdkVersion" value="14" />
<preference name="android-targetSdkVersion" value="14" />


LOG stil shows the API level 22 :-(
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
Acknowledged. We'll update you when this is fixed here: https://github.com/phonegap/build/issues/476

-yiming
Photo of Stefan Wahren

Stefan Wahren

  • 5 Posts
  • 0 Reply Likes
Thanks

It would be nice to know about a workaround in the meantime.
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
No fix unfortunately. There shouldn't be a problem using the default targetSdkVersion though.

Is there a reason to use a custom targetSdkVersion in particular (due to plugin support, etc)?

-yiming
Photo of Stefan Wahren

Stefan Wahren

  • 5 Posts
  • 0 Reply Likes
I want to deploy my application to a tablet with Android 4.1 (API version 16) support.

Unfortunately the resulting apk file (extract from AndroidManifest.xml) seems to require Android 5.1:


<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" android:windowSoftInputMode="adjustPan" package="com.phonegap.helloworld" platformBuildVersionCode="22" platformBuildVersionName="5.1.1-1819727">


I tried android-minSdkVersion and android-targetSdkVersion, but none of them has an influence.
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
targetSdkVersion only chooses the SDK version to use for compiling. This doesn't affect the minimum SDK version, unless a plugin you're using uses a feature that's not present in API16.

Can you post your PhoneGap Build app id so I can check the full manifest?

-yiming
Photo of Stefan Wahren

Stefan Wahren

  • 5 Posts
  • 0 Reply Likes
Sorry, it was my fault. Now the application works on the tablet. The issue can be closed.