4

When I upgraded my LG Nexus 4 phone from Android 4.4.4 to 5.0.1, my App stopped working (connecting to a Arduino Adafruit EZ-Link Bluetooth shield). The only hint/idea I have right now is that the cordova build is using API 19 (Android 4.4.2) instead of API 21 (5.0.1).

I've rebuilt the App and everything else to know about API 21 (5.0.1) but I cannot get cordova to use it. It insists upon using API target 19.

Many people say do NOT change platforms/android/AndroidManifest.xml. Even if you do, it still will not work. Based on what I seen in How do I specify the Android API Level in PhoneGap? I updated my config.xml to include:

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

but that doesn't work either. I blew away the old Android virtual device in AVD (Android Virtual Device) manager, and created a new one that uses API 21 and the API 21 stuff is installed from the Android SDK Manager. But when I do a cordova build, I still get:

[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19

If I specify using the --target option, it explodes with:

server5> cordova build --target="android-21"
Running command:         /usr/local/GrayAndWhite/cordova/wounds/platforms/android/cordova/build --target=android-21
/usr/local/GrayAndWhite/cordova/wounds/platforms/android/cordova/node_modules/q/q.js:126
     throw e;
           ^
TypeError: Cannot call method 'prepEnv' of undefined

API 21 is known about. It I do a cordova info, I will get a

...
id: 3 or "android-21"
     Name: Android 5.0.1
     Type: Platform
     API level: 21
     Revision: 2
...

I know the Arduino side of things is still ok, because the phone can pair to the device, the App can see the device, get it's MAC address, but cannot connect to it any more.

I have not tried removing the API 19 stuff from the SDK. I'd rather not do that since I'll probably want to be able to install this on other phones as well.

Community
  • 1
  • 1
RJ White
  • 367
  • 5
  • 12
  • Further to this, I found that the platform/android/AndroidManifest.xml just gets updated from the config.xml. The android-targetSdkVersion in the config.xml gets ignored (I put in a really stupid value and saw no complaints), and the posting at http://stackoverflow.com/questions/24688345/cordova-wants-android-19-i-have-android-20 says that "The current Cordova (4.1.2) only wants to build against API v19" which I confirmed after removign all the API-19 stuff from the SDK. – RJ White Jan 24 '15 at 06:34
  • The problem I was having has been fixed, while still using API 19 - it was a coding issue and chance events that just happened to manifest itself right after my Android upgrade. But I'll leave this open for now because I'd still like to know if it is possible to specify a different API number to cordova. – RJ White Jan 25 '15 at 22:52
  • 1
    Did you change minSdk to 21, too? In your initial post you say: there is a line at https://github.com/apache/cordova-android/blob/master/bin/lib/create.js#L297 which will update minSdkVersion to 14, if it's less then 14. Maybe you are using a cordova version, which has another minimum? – DracoBlue Aug 12 '15 at 14:52

0 Answers0