Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify the Android API Level in PhoneGap?

Tags:

cordova

The default PhoneGap app wants me to get API 17. However I have 18 and would rather use that. How do I specify which version of the API to use? I did some searching of some config files in my project but didn't see anything specifying the level to be 17.

I'm developing on Windows and want to build android locally.

I've followed the developer guide so that I have a phonegap project called hello that has the following folders:

  • .cordova
    • hooks
    • config.json
  • build (empty)
  • merges (empty)
  • platforms (empty)
  • plugins
  • www
    • css
    • img
    • js
    • res
    • spec
    • config.xml
    • icon.png
    • index.html
    • spec.html

I tried phonegap add platform android but errored saying 'platform add android' is not a node

like image 763
Anthony Elliott Avatar asked Aug 22 '13 15:08

Anthony Elliott


People also ask

What API level should I use Android?

When you upload an APK, it must meet Google Play's target API level requirements. New apps must target Android 12 (API level 31) or higher; except for Wear OS apps, which must target Android 11 (API level 30) or higher.

Where does Android studio specify the minimum API level for a project?

Step 1: Open your Android Studio, and go to Menu. File >Project Structure. Step 2: In project Structure window, select app module in the list given on left side. Step 3: Select the Flavors tab and under this you will have an option for setting “Min Sdk Version” and for setting “Target Sdk Version”.


2 Answers

Please do not modify AndroidManifest.xml in your platforms directory. With current cordova/phonegap version, this should not be necessary anymore (you can ignore platforms from version control!).

Instead set:

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

All possible configs are available here: http://docs.build.phonegap.com/en_US/2.9.0/configuring_basics.md.html (the document says, it works for phonegap build, but it works the same for cordova/phonegap cli!).

EDIT: New Link http://docs.phonegap.com/phonegap-build/configuring/preferences/#android-minSdkVersion

like image 142
DracoBlue Avatar answered Sep 18 '22 04:09

DracoBlue


You shouldn't edit AndroidManifest.xml. You can/should do it cordova config.xml file in preference:

<preference name="android-targetSdkVersion" value="14" />
<preference name="android-minSdkVersion" value="14" />
like image 35
Andres Restrepo Avatar answered Sep 20 '22 04:09

Andres Restrepo