16

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

Anthony Elliott
  • 2,941
  • 5
  • 29
  • 42

5 Answers5

22

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

DracoBlue
  • 491
  • 3
  • 10
  • 2
    It's been a long time since my original question and I am no longer using PhoneGap so I can't verify this, but I do now know that modifying the `AndroidManifest.xml` is not good. I've accepted this answer instead in case other people find this post. – Anthony Elliott Jan 13 '15 at 17:50
  • New link: http://docs.phonegap.com/phonegap-build/configuring/preferences/#android-minSdkVersion – Mart Jun 18 '18 at 15:13
8

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" />
João Pimentel Ferreira
  • 14,289
  • 10
  • 80
  • 109
Andres Restrepo
  • 389
  • 5
  • 6
4

For Android 6.0 (API 23) , Android version is specified in project.properties file. It is placed just close AndroidManifest.xml in ProjectDir/platforms/android directory. If it can help.

3

The way I handle platform customizations is to create a separate directory called config with this structure:

   config
       android
           AndroidManifest.xml
           images
       ios
           images

Then I write a hook to copy the files from config to platforms/android/... (either after_prepare or after_platform_add depending on how often I want to copy over the files).

That way you can modify AndroidManifest.xml and still keep the platforms directory totally under control of Cordova CLI.

mooreds
  • 4,932
  • 2
  • 32
  • 40
2

You need to set it in the AndroidManifest.xml within your Android project

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

Change the minSdkVersion, targetSdkVersion and maxSdkVersion according to your requirements.

Keshav
  • 171
  • 1
  • 11
  • 1
    right, but since im using PhoneGap I don't have an Android project yet as it is cross-platform. – Anthony Elliott Aug 22 '13 at 15:44
  • You will still need to create a project for each of the platforms. Have you setup your project as detailed in [Phonegap getting started](http://docs.phonegap.com/en/2.9.0/guide_getting-started_android_index.md.html#Android%20Platform%20Guide) documentation? – Keshav Aug 22 '13 at 15:46
  • I edited my above answer with my current state of the project – Anthony Elliott Aug 22 '13 at 16:06
  • Same issue here - I would expect phonegap to use the infos in the config.xml inside the www directory. What is this file for otherwise? Only for the Phonegap-Build-Service? http://docs.build.phonegap.com/en_US/2.9.0/configuring_basics.md.html – Toubey Oct 07 '14 at 09:05