最近又个客户使用 AndroID.aarch64 平台总是有问题,于是决定装一个 AndroID 的模拟器跑一下看看。因为是调试动态库,所以不需要图形界面,这样安装的东西少,启动也快,并且不需要启动桌面系统。
下面是在 Ubuntu 14 服务器版本下面,使用 ssh 远程登录,在控制台运行模拟器 (AndroID arm64),并调试动态库的基本步骤
首先增加一个源,安装并配置 openjdk-8-jdk。Ubuntu 14 原装包里面的 JDK 是 7,AndroID SDK 中的命令行工具至少要求 8 以上
sudo add-apt-repository ppa:openjdk-r/ppasudo apt-get update sudo apt-get install openjdk-8-jdksudo update-alternatives --config javasudo update-alternatives --config javac
其次下载AndorID SDK 命令行工具
https://developer.androID.Google.cn/studio?hl=zh-cn#downloads
从这里下载 linux 下面的 Command line tools only
,并解压下载好的压缩文件,例如
unzip commandlinetools-linux-7302050_latest.zipls cmdline-tools
然后使用工具里面的 sdkmanager
下载 build-tools, platform (androID 24),system images和模拟器,
cd cmdline-tools# 查看包bin/sdkmanager --sdk_root=latest --List# 安装包bin/sdkmanager --sdk_root=latest "build-tools;26.0.0" bin/sdkmanager --sdk_root=latest "platforms;androID-24" bin/sdkmanager --sdk_root=latest "system-images;androID-24;default;arm64-v8a" bin/sdkmanager --sdk_root=latest "emulator"
使用平台工具中的 avdmanager
创建 avd
latest/tools/bin/avdmanager create avd --name test24 -k "system-images;androID-24;default;arm64-v8a"
使用模拟器里面的工具 qemu-system-aarch64-headless
启动 avd, gpu 模式使用 guest
,额外指定相关动态库路径 ./latest/emulator/lib64
,这样才能成功启动,为了能上传文件,还需要指定选项 -writable-system
sudo adb start-serversudo LD_liBRARY_PATH=./latest/emulator/lib64 latest/emulator/qemu/linux-x86_64/qemu-system-aarch64-headless -gpu guest -no-audio -no-snapshot -writable-system -avd test24
重新打开一个终端,就可以使用 adb
上传文件和运行相关命令了
sudo adb devices -l# 使用 root 用户进行 *** 作sudo adb root# 上传文件到 /mntsudo adb push pyarmor-core/platforms/androID.aarch64.0/_pytransform.so /mnt# 登录模拟器sudo adb shellgeneric_arm64:/ $
常见错误@H_301_64@使用 openjdk-7 运行 AndroID 的命令行工具会报错 Unsupported major.minor version 52.0
,解决方案是安装 openjdk-8-jdk$ bin/sdkmanager Exception in thread "main" java.lang.UnsupportedClassversionError: com/androID/sdklib/tool/sdkmanager/sdkmanagerCli : Unsupported major.minor version 52.0
@H_301_64@直接运行 emulator,则报错 libdbus-1.so.3: no version information available
jondy@dashingsoft:~/androID/cmdline-tools$ latest/tools/emulator -avd test24 /home/jondy/androID/cmdline-tools/latest/emulator/qemu/linux-x86_64/qemu-system-aarch64: /lib/x86_64-linux-gnu/libdbus-1.so.3: no version information available (required by latest/emulator/lib64/qt/lib/libQt5WebEngineCoreAndroIDEmu.so.5)
@H_301_64@解决方案是使用直接使用模拟器目录下面的 qemu-system-aarch64-headless
,但是找不到动态库 libtcmalloc_minimal.so.4
jondy@dashingsoft:~/androID/cmdline-tools$ sudo latest/emulator/qemu/linux-x86_64/qemu-system-aarch64-headless -avd test24latest/emulator/qemu/linux-x86_64/qemu-system-aarch64-headless: error while loading shared librarIEs: libtcmalloc_minimal.so.4: cannot open shared object file: No such file or directory
@H_301_64@解决方案是指定 LD_liBRARY_PATH ,因为相关的动态库就在模拟器所在的目录下面。但是还是报错 EglOsGllibrary
jondy@dashingsoft:~/androID/cmdline-tools$ sudo LD_liBRARY_PATH=./latest/emulator/lib64 latest/emulator/qemu/linux-x86_64/qemu-system-aarch64-headless -avd test24emulator: WARNING: encryption is offemulator: Feeding guest with passive gps data, in headless modeEglOsGllibrary: Could not open GL library libGLESv2.so [libGLESv2.so: cannot open shared object file: No such file or directory]. Trying again with [libGLESv2.so.2]EglOsGllibrary: Could not open GL library libGLESv2.so.2 [libGLESv2.so.2: cannot open shared object file: No such file or directory]EglOsEgldispatcher: Could not open EGL library libEGL.so [libEGL.so: cannot open shared object file: No such file or directory]. Trying again with [libEGL.so.1]EglOsEgldispatcher: Could not open EGL library libEGL.so.1 [libEGL.so.1: cannot open shared object file: No such file or directory]
@H_301_64@解决方案是使用选项 -gpu guest
,指定 gpu
的模式为 guest
jondy@dashingsoft:~/androID/cmdline-tools$ sudo LD_liBRARY_PATH=./latest/emulator/lib64 latest/emulator/qemu/linux-x86_64/qemu-system-aarch64-headless -gpu guest -avd test24 emulator: WARNING: System image is writableemulator: WARNING: encryption is offemulator: Feeding guest with passive gps data, in headless modeemulator: INFO: GrpcServices.cpp:315: Started GRPC server at 127.0.0.1:8554, security: LocalWARNING. Using fallback path for the emulator registration directory.emulator: INFO: EmulatorAdvertisement.cpp:93: Advertising in: /home/jondy/.androID/avd/running/pID_2057.iniemulator: Cold boot: requested by the user
总结 以上是内存溢出为你收集整理的在 Ubuntu 14 上面使用命令行界面模拟 Android arm64全部内容,希望文章能够帮你解决在 Ubuntu 14 上面使用命令行界面模拟 Android arm64所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)