安卓模拟器主要就2种类型(windows上运行),
一种是原生的sdk,真正模拟真机,如genymotion(基于virtualbox)和androidstudio(基于android sdk);
一种是把android 底层的api接口翻译成windows api,调的其实是windows系统的接口,如腾讯手游助手,夜神模拟器,雷电模拟器,蓝叠模拟器等,且特定版本都是特定android版本,不能选择android版本.
andriod studio 模拟器(android 8.0.0 X86,X86_64)安装apk报错:could not parse error string
genymotion 模拟器安装apk报错:An error orrucred while deploying the file.This probably meas that the app contains ARM native and your Genymotion device cannot run ARM instructions.You should either build your native code to x86 or install an ARM translation tool in your device.
查资料https://www.cnblogs.com/liyanli-mu640065/p/9970097.html 是因为要安装的apk限制了只能在ARM架构的CPU机器上,但是模拟器用的是X86,或X86_64架构
Device supports x86,but Apk only supports armeabi-v7a
首先了解了CPU架构:
armeabi :第5代 ARM v5TE,使用软件浮点运算,兼容所有ARM设备,通用性强,速度慢
armeabi-v7a: 第7代 ARM v7,使用硬件浮点运算,具有高级扩展功能
arm64-v8a :第8代,64位,包含AArch32、AArch64两个执行状态对应32、64bit
x86: intel 32位,一般用于平板
x86_64: intel 64位,一般用于平板
mips: RISC处理器
mips64:RISC处理器
我们可以在build.gradle中有ndk这段代码,只要在后面加上“x86”,再sync now一下,就发现可以运行了。
ndk {
abiFilters "armeabi-v7a","x86"
}
解决方法
1. 让开发打包,我们可以在build.gradle中有ndk这段代码,只要在后面加上“x86”,再sync now一下,就发现可以运行了。
ndk {
abiFilters "armeabi-v7a","x86"
}
2.在genymotion的模拟器里面安装arm translation tool,下载地址https://github.com/m9rco/Genymotion_ARM_Translation/tree/master/package
拖到模拟器里面安装,重启模拟器,即可.亲测有效
android8.0拖拽arm translation tool压缩包,无法自动识别,甚至无法放到/sdcard/Download.需要手动用adb命令实现.
参考https://www.jianshu.com/p/1db4cb031438
- 先启动模拟器(否则用adb devices -l会看不到设备)
- 再打开电脑命令行(确保可以使用adb命令)
PS D:soft-packages安卓模拟器> adb devices -l
List of devices attached
192.168.214.101:5555 device product:vbox86p model:Google_Pixel___8_0___API_26___1080x1920 device:vbox86p transport_id:4
- 把zip包放到模拟器,并解压
adb push .Genymotion-ARM-Translation_for_8.0.zip /sdcard/Download
adb shell flash-archive.sh /sdcard/Download/Genymotion-ARM-Translation_for_8.0.zip
PS D:soft-packages安卓模拟器> adb push .Genymotion-ARM-Translation_for_8.0.zip /sdcard/Download
.Genymotion-ARM-Translation_for_8.0.zip: 1 file pushed. 104.4 MB/s (39101269 bytes in 0.357s)
PS D:soft-packages安卓模拟器> adb shell flash-archive.sh /sdcard/Download/Genymotion-ARM-Translation_for_8.0.zip
uid=0(root) gid=0(root) groups=0(root),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc) context=u:r:toolbox:s0
/sdcard/Download/Genymotion-ARM-Translation_for_8.0.zip seems to be a zip archive
[flash_archive] Creating tmp dir
rm: /data/local/tmp/sanitized.zip: No such file or directory
[flash_archive] Unzip archive
Archive: /sdcard/Download/Genymotion-ARM-Translation_for_8.0.zip
creating: Genymotion-ARM-Translation_for_8.0/
creating: Genymotion-ARM-Translation_for_8.0/system/
creating: Genymotion-ARM-Translation_for_8.0/system/bin/
inflating: Genymotion-ARM-Translation_for_8.0/system/bin/houdini
......
......
......
inflating: Genymotion-ARM-Translation_for_8.0/system/lib/libhoudini.so
[flash_archive] Remount /system/ in rw
[flash_archive] Start file install
find: system/: No such file or directory
[flash_archive] Remount /system/ in ro
[flash_archive] Delete tmp directory
rm: /data/local/tmp/sanitized.zip: No such file or directory
[flash_archive] Done successfully !
{Result:OK};