Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you build and deploy to an older version of android for ionic / cordova

Tags:

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:

.... -post-build:      [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  debug:  BUILD SUCCESSFUL 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...  /home/admin/code/projects/myapp/ionic/platforms/android/cordova/node_modules/q/q.js:126                     throw e;                           ^ ERROR: Failed to launch application on device: ERROR: Failed to install apk to device:  pkg: /data/local/tmp/HelloCordova-debug-unaligned.apk Failure [INSTALL_FAILED_OLDER_SDK]  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. Exiting. 

How do I make the build work in ionic/cordova for android 4.x.x phones as well as android 2.2 phones?

like image 845
Derek Avatar asked Jul 02 '14 04:07

Derek


People also ask

How to run ionic Cordova app on iOS?

Run a production build of your app with ionic cordova build ios --prod Open the.xcodeproj file in platforms/ios/ in Xcode Connect your phone via USB and select it as the run target Click the play button in Xcode to try to run your app

Can I deploy ionic native to an Android device?

Not only is it the only way to accurately test how your app will behave and perform, many Ionic Native plugins will only work when they are run on actual hardware. Deploying to an Android device is a fairly straightforward process. If you have a working Android development environment, you’re ready to go.

How do I debug an ionic app on Android?

Available through Android Studio’s SDK Manager To run your app, all you have to do is enable USB debugging and Developer Mode on your Android device, then run ionic cordova run android --device from the command line. This will produce a debug build of your app, both in terms of Android and Ionic’s code

How do I specify a minimum version of the Android platform?

If your app requires a specific minimum version of the Android platform, you can specify that version requirement as API level settings in the app's build.gradle file. During the build process, these settings are merged into your app's manifest file.


2 Answers

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).

like image 177
vdj4y Avatar answered Oct 09 '22 16:10

vdj4y


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.

like image 23
Paullo Avatar answered Oct 09 '22 14:10

Paullo