phonegap 3.0 wants android 17, but I want android 18

user2776896 picture user2776896 · Sep 13, 2013 · Viewed 29.5k times · Source

While experienced with phonegap and xcode, I'm new to android. I have installed phonegap 3.0 ...

npm install phonegap
phonegap --version
3.0.0-0.14.3

I've installed adt-bundle-mac-x86_64-20130729. The command line tools (eg: android) seem to work fine. When I try to add android as a platform ..

phonegap local build android

I get ...

[error] Please install Android target 17 (the Android 4.2 SDK). Make sure you have the latest Android tools installed as well. Run `android` from your command-line to install/update any missing SDKs or tools.

I see similar questions still unanswered ... Phonegap 3.0 CLI issue android target number in build app

When I do install android-17 it works fine, which is cool, but I need to use android-18 so I can use BLE.

I see that Fil Maj apparently fixed this issue on Jul 31 ... https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=commitdiff;h=c2c5f710

.. but I don't appear to have that fix in the version of phonegap I downloaded. I thought perhaps it was only in cordova, so I installed that too, but ran into the same issue.

I tried hacking the four js files in the npm directories that contain the check directly, but that didn't take (ie: the error persisted).

Can anyone please suggest either ...

1) how to download a version of phonegap/cordova with the problem fixed, or

2) how to tell phonegap/cordova which version of android I'd like to target

Thanks so much ...

Answer

bumerang picture bumerang · Nov 8, 2013

Find file android_parser.js in Windows it is undr path:

C:\Users\USER_NAME\AppData\Roaming\npm\node_modules\cordova\src\metadata

change in file android_parse.js

OR if You are makking application from PhoneGap not Cordova:

C:\Users\USER_NAME\AppData\Roaming\npm\node_modules\phonegap\node_modules\cordova\src\metadata\android_parser.js

go to line: 57

if (output.indexOf('android-17') == -1) {

and change it for:

if (output.indexOf('android') == -1) {

This will let You not to wory about future :)

But then You can occur this Error

[Error: An error occured during creation of android sub-project.
]

To fix it You will have to goto this path:

C:\Users\USER_NAME\.cordova\lib\android\cordova\3.1.0\framework\project.properties

And change this line:

target=android-17

To this:

target=android-19

Or whatever is Your Android SDK version

What to do if You want to use Android 2.2 ?

Just simple go to:

Your_Project_Folder/platforms/android/AndroidManifest.xml

And change:

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />

To:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="19" />

And after that import Your project to Your IDE

Enjoy :)