Using Ionic 1.0.0 beta-8
After creating a new app, I built and deployed it to a Nexus 5 emulator and it worked fine. But when I tried to debug it on my Android 2.2 phone, I got this error:
[move] Moving 1 file to /home/admin/code/projects/myapp/ionic/platforms/android/ant-build
[move] Moving 1 file to /home/admin/code/projects/myapp/ionic/platforms/android/CordovaLib/ant-build
Total time: 6 seconds
WARNING : No target specified, deploying to device 'I8972b56ddac'.
Using apk: /home/admin/code/projects/myapp/ionic/platforms/android/ant-build/HelloCordova-debug-unaligned.apk
Installing app on device...
ERROR: Failed to launch application on device: ERROR: Failed to install apk to device: pkg: /data/local/tmp/HelloCordova-debug-unaligned.apk
Error: /home/admin/code/projects/myapp/ionic/platforms/android/cordova/run: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Process.ChildProcess._handle.onexit (child_process.js:822:5)
ERROR: Unable to run app on platform android. Please see console for more info.
How do I make the build work in ionic/cordova for android 4.x.x phones as well as android 2.2 phones?
this question is similar to yours. stackoverflow
go to your AndroidManifest.xml, find these to control your sdk buildversion.
<preference name="android-minSdkVersion" value="XX"> // value is the API LEVEL <preference name="android-targetSdkVersion" value="XX">
*targetSdk = tell phonegap which android build version to use,
*MinSdk is to limit user who want to download it.
check the API LEVEL of android build here.
In Your case: for android 2.2, use value= 8(API level 8)
<preference name="android-minSdkVersion" value="8"> //android 2.2 <preference name="android-targetSdkVersion" value="17"> //android 4.2
NOTE: I doubt android 2.2(API level 8) can run API level 17(android 4.2).
According to Ionic Platform notes, Ionic targets iPhone and Android devices (currently). It also support iOS 6+, and Android 4.0+ (though 2.3 should work). However, since there are a lot of different Android devices, it's possible certain ones might not work. Ionic did not guaranty for Android 2.3 hence Android 2.2 will be out of scope.
Hence, I think that is the reason why you are having challenges.
FYI, Google back-ported features from Honeycomb and again from later versions of Android into a "compatibility" library. You might be able to install that and get your app working on older versions of Android. You would need to update your Android SDK and install this library.
See Android Support Library docs.
If you're using Ionic, you could add a hook script that copies the library into your project when you add Android as a platform or start a build.
Change value of
config.xml of your ionic project. It should look like below:
<preference name="android-minSdkVersion" value="14"/>