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?
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
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.
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With