你如何为 ionic/cordova 构建和部署到旧版本的 android [英] How do you build and deploy to an older version of android for ionic / cordova
问题描述
使用 Ionic 1.0.0 beta-8
创建新应用后,我构建并部署到 Nexus 5 模拟器,它运行良好.但是当我尝试在我的 Android 2.2 手机上调试它时,我收到了这个错误:
<代码>....- 构建后:[移动] 将 1 个文件移动到/home/admin/code/projects/myapp/ionic/platforms/android/ant-build[移动] 将 1 个文件移动到/home/admin/code/projects/myapp/ionic/platforms/android/CordovaLib/ant-build调试:建造成功总时间:6秒警告:未指定目标,正在部署到设备I8972b56ddac".使用apk:/home/admin/code/projects/myapp/ionic/platforms/android/ant-build/HelloCordova-debug-unaligned.apk在设备上安装应用程序.../home/admin/code/projects/myapp/ionic/platforms/android/cordova/node_modules/q/q.js:126扔e;^错误:无法在设备上启动应用程序:错误:无法将 apk 安装到设备:pkg:/data/local/tmp/HelloCordova-debug-unaligned.apk失败 [INSTALL_FAILED_OLDER_SDK]错误:/home/admin/code/projects/myapp/ionic/platforms/android/cordova/run:命令失败,退出代码为 8在 ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)在 ChildProcess.emit (events.js:98:17)在maybeClose (child_process.js:755:16)在 Process.ChildProcess._handle.onexit (child_process.js:822:5)错误:无法在 android 平台上运行应用程序.请参阅控制台了解更多信息.退出.
如何使构建在 ionic/cordova 中适用于 android 4.x.x 手机和 android 2.2 手机?
这个问题和你的类似.堆栈溢出
去你的AndroidManifest.xml,找到这些来控制你的sdk buildversion.
//value 是 API LEVEL<preference name="android-targetSdkVersion" value="XX">
*targetSdk = 告诉 phonegap 使用哪个 android build 版本,
*MinSdk 是限制想要下载它的用户.
在这里检查Android构建的API级别.
在您的情况下:对于 android 2.2,使用 value= 8(API 级别 8)
//安卓2.2<preference name="android-targetSdkVersion" value="17">//安卓4.2
注意:我怀疑 android 2.2(API 级别 8)能否运行 API 级别 17(android 4.2).
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?
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).
这篇关于你如何为 ionic/cordova 构建和部署到旧版本的 android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!