23

Linux下进行Android环境配置与Android模拟器运行

 3 years ago
source link: https://renyugang.blog.csdn.net/article/details/103802692
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Linux下进行Android环境配置与Android模拟器运行

original.png
胖虎 2020-01-02 13:17:38 articleReadEyes.png 5142

1.Jdk环境先装

2.下载安装Android SDK
基础包:http://tools.android-studio.org/index.php/sdk 选择linux版本下载(wget url)
解压缩: tar zxvf tgz包
解压完成后,执行sdk更新下载命令
tools/android update sdk --no-ui
因为模拟器需要有system.img文件,才能创建出来
所以我们需要先通过tools/android list sdk --extended --no-ui --all 查询一下有哪些sys-img*文件,我们过滤一下
tools/android list sdk --extended --no-ui --all | grep sys-img
找到你需要的版本下载就行了
tools/android update sdk -a --no-ui --filter sys-img-armeabi-v7a-android-24,sys-img-armeabi-v7a-android-22
下载完成后,可以到 /platforms/对应的目录下,看下有没有system.img文件

3.配置环境变量

4.创建Android模拟器
查看有哪些版本的模拟器可以创建 : android list target , 把id序号记录下来
创建模拟器:android create avd -n 模拟器名字 -t 上一步的id序号 (如: android create avd -n mytest1 -t 18)

[lijiangping@alihb2c-k8s-node-4-003042 android-sdk-linux]$ ./tools/android create avd -n mytest1 -t 18

Auto-selecting single ABI armeabi-v7a
Android 7.0 is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Created AVD 'mytest1' based on Android 7.0, ARM (armeabi-v7a) processor,
with the following hardware config:
hw.cpu.model=cortex-a8
hw.lcd.density=240
hw.ramSize=512
vm.heapSize=48

这样创建出来的内存等参数配置特别差,我们需要改一下硬件配置参数。
android create avd -n mytest1 -t 18 -c 8000M -s 480x800

创建好后,通过./tools/android list avd 来查看已经创建了哪些模拟器

5.打开模拟器
./tools/emulator -avd mytest1 打开这个模拟器

可能碰到如下错误:
android-sdk-linux/tools/qemu/linux-x86_64/qemu-system-armel: error while loading shared libraries: libpulse.so.0:
cannot open shared object file: No such file or directory

碰到如上错误,输入cat /etc/redhat-release,查看当前linux系统版本为CentOS Linux release 7.4.1708 (Core) 。
到https://pkgs.org/download/libpulse.so.0 安装对应的版本
使用命令行:
yum install pulseaudio-libs

安装后再次启动虚拟机,提示
QXcbConnection: Could not connect to display

1、vim ~/.bashrc
2、加入
export QT_QPA_PLATFORM='offscreen
3、保存后执行
source ~/.bashrc


1.创建模拟器 : android create avd -n mytest -k “system-images;android-29;google_apis_playstore;x86”
2.指定自己编译的镜像:emulator –avd Android –system


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK