我通过“OpenJDK-8-JDK”安装了Java 8,并且可以成功构建Android软件包并将其侧载到我的手机上,没有任何问题。
在将Android SDK安装到/usr/local/android后,我做了以下操作:
Change into the tools bin dir
cd /usr/local/android/sdk/tools/bin sudo chmod +x
Install system images (must be done as root)
sudo ./sdkmanager "system-images;android-25;google_apis;x86" sudo ./sdkmanager --licenses
Say 'y' to all sudo touch ~/.android/repositories.cfg
List available Android Virtual Devices to install (done as user)
./avdmanager list
Create a test Android Virtual Device (AVD)
./avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"
custom hardware profile: no
List AVDs
Now I get the following when I list through avdmanager
./avdmanager list avd Available Android Virtual Devices: Name: test Path: /root/.android/avd/test.avd Target: Google APIs (Google Inc.) Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
Start emulator
cd /usr/local/android/sdk/emulator ./emulator -avd test
它会加载模拟器,然后我可以启动应用程序并浏览到它崩溃/关闭程序。
我尝试通过安装Android Studio并设置AVD进行解决,但是出现了同样的问题。我尝试了不同的AVD模型和Android版本,但结果相同。
更新:记录错误
我设法使用以下方法记录崩溃:
$ANDROID_HOME/emulator/emulator -avd test -gpu guest -logcat v
日志
08-22 13:50:03.169 2703 2839 V NativeCrypto: Read error: ssl=0xb0a32640: I/O error during system call, Connection reset by peer
08-22 13:50:03.170 2703 2839 V NativeCrypto: SSL shutdown failed: ssl=0xb0a32640: I/O error during system call, Broken pipe
08-22 13:50:03.195 3551 3551 W dex2oat : Unexpected CPU variant for X86 using defaults: x86
08-22 13:50:03.195 3551 3551 W dex2oat : Mismatch between dex2oat instruction set features (ISA: X86 Feature string: smp,-ssse3,-sse4.1,-sse4.2,-avx,-avx2,-lock_add,-popcnt) and those of dex2oat executable (ISA: X86 Feature string: smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2,-lock_add,-popcnt) for the command line:
08-22 13:50:03.195 3551 3551 W dex2oat : /system/bin/dex2oat --runtime-arg -classpath --runtime-arg & --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2,-lock_add,-popcnt --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/user/0/com.google.android.gms/app_fb/f.apk --oat-fd=44 --oat-location=/data/user/0/com.google.android.gms/app_fb/f.dex --compiler-filter=speed
08-22 13:50:03.195 3551 3551 I dex2oat : /system/bin/dex2oat --dex-file=/data/user/0/com.google.android.gms/app_fb/f.apk --oat-fd=44 --oat-location=/data/user/0/com.google.android.gms/app_fb/f.dex --compiler-filter=speed
08-22 13:50:03.232 3551 3551 I dex2oat : dex2oat took 36.457ms (threads: 2) arena alloc=323KB (331648B) java alloc=76KB (78168B) native alloc=966KB (989744B) free=2MB (2155984B)
08-22 13:50:03.234 2703 2839 W System : ClassLoader referenced unknown path:
08-22 13:50:03.253 2022 3550 I GoogleURLConnFactory: Using platform SSLCertificateSocketFactory
08-22 13:50:03.262 2022 3550 I GoogleURLConnFactory: Using platform SSLCertificateSocketFactory
08-22 13:50:03.387 2022 2716 W ConfigurationChimeraPro: Got null configs for com.google.android.gms.auth.account.base
08-22 13:50:03.415 2022 2716 W Conscrypt: Could not set socket write timeout:
08-22 13:50:03.416 2022 2716 W Conscrypt: java.lang.reflect.Method.invoke(Native Method)
08-22 13:50:03.416 2022 2716 W Conscrypt: com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@11743470:13)
08-22 13:50:03.552 2022 2716 W Conscrypt: Could not set socket write timeout:
08-22 13:50:03.552 2022 2716 W Conscrypt: java.lang.reflect.Method.invoke(Native Method)
08-22 13:50:03.552 2022 2716 W Conscrypt: com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@11743470:13)
08-22 13:50:03.678 2022 2716 W GLSUser : [AppCertManager] IOException while requesting key:
08-22 13:50:03.678 2022 2716 W GLSUser : java.io.IOException: Invalid device key response.
08-22 13:50:03.678 2022 2716 W GLSUser : at eyw.a(:com.google.android.gms@11743470:14)
08-22 13:50:03.678 2022 2716 W GLSUser : at eyw.a(:com.google.android.gms@11743470:65)
08-22 13:50:03.678 2022 2716 W GLSUser : at eyu.a(:com.google.android.gms@11743470:8)
08-22 13:50:03.678 2022 2716 W GLSUser : at eyq.a(:com.google.android.gms@11743470:1)
08-22 13:50:03.678 2022 2716 W GLSUser : at eyp.a(:com.google.android.gms@11743470:10)
08-22 13:50:03.678 2022 2716 W GLSUser : at com.google.android.gms.auth.account.be.legacy.AuthCronChimeraService.b(:com.google.android.gms@11743470:7)
08-22 13:50:03.678 2022 2716 W GLSUser : at edr.call(:com.google.android.gms@11743470:3)
08-22 13:50:03.678 2022 2716 W GLSUser : at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-22 13:50:03.678 2022 2716 W GLSUser : at mmu.run(:com.google.android.gms@11743470:26)
08-22 13:50:03.678 2022 2716 W GLSUser : at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
08-22 13:50:03.678 2022 2716 W GLSUser : at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
08-22 13:50:03.678 2022 2716 W GLSUser : at mse.run(:com.google.android.gms@11743470)
08-22 13:50:03.678 2022 2716 W GLSUser : at java.lang.Thread.run(Thread.java:761)
08-22 13:50:07.717 1603 1634 W ActivityManager: Unable to start service Intent { act=com.google.android.gms.drive.ApiService.RESET_AFTER_BOOT flg=0x4 cmp=com.google.android.gms/.drive.api.ApiService (has extras) } U=0: not found
emulator: Saving state on exit with session uptime 119964 ms
更新:config.ini
以下是我的config.ini文件:
PlayStore.enabled = false
abi.type = x86
avd.ini.encoding = UTF-8
hw.accelerometer = yes
hw.audioInput = yes
hw.battery = yes
hw.cpu.arch = x86
hw.dPad = no
hw.device.hash2 = MD5:fc85b2d34337b54227366eb43de4cfef
hw.device.manufacturer = Generic
hw.device.name = 5.4in FWVGA
hw.gps = yes
hw.lcd.density = 160
hw.lcd.height = 854
hw.lcd.width = 480
hw.mainKeys = yes
hw.sdCard = yes
hw.sensors.orientation = yes
hw.sensors.proximity = yes
hw.trackBall = no
image.sysdir.1 = system-images/android-24/google_apis_playstore/x86/
sdcard.size = 2048M
tag.display = Google Play
tag.id = google_apis_playstore
disk.dataPartition.size = 6442450944
hw.ramSize=3072
更新:另一个崩溃日志
这次它没有抱怨缺少关键字。
08-28 09:48:58.109 12476 12476 W art : Unexpected CPU variant for X86 using defaults: x86
08-28 09:48:58.114 12476 12476 D ICU : No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
08-28 09:48:58.129 12476 12476 E memtrack: Couldn't load memtrack module (No such file or directory)
08-28 09:48:58.129 12476 12476 E android.os.Debug: failed to load memtrack module: -2
08-28 09:48:58.130 12476 12476 I Radio-JNI: register_android_hardware_Radio DONE
08-28 09:48:58.139 12476 12476 D AndroidRuntime: Calling main entry com.android.commands.settings.SettingsCmd
08-28 09:48:58.144 12476 12476 D AndroidRuntime: Shutting down VM
emulator: emulator_window_fb_update
emulator: emulator_window_fb_update
emulator: emulator_window_fb_update
emulator: emulator_window_fb_update
08-28 09:49:03.851 1602 2032 D AlarmManagerService: Kernel timezone updated to -600 minutes west of GMT
08-28 09:49:03.852 1602 2030 D AlarmManagerService: Setting time of day to sec=1566949744
08-28 09:49:04.002 1602 2030 W AlarmManagerService: Unable to set rtc to 1566949744: No such device
[ 8042.781849] healthd: battery l=100 v=0 t=0.0 h=2 st=2 chg=a
emulator: emulator_window_fb_update
emulator: emulator_window_fb_update
emulator: emulator_window_fb_update
emulator: emulator_window_fb_update
emulator: Saving state on exit with session uptime 73706 ms
解决方法
创建一个别名,每当模拟器崩溃时重新启动它。
alias tnsa="tns run android --device emulator-5554" # Run in emulator
alias em="$ANDROID_HOME/emulator/emulator -avd samsung_galaxy_s8 -gpu guest -no-audio -verbose"
alias eml="while true; do pkill -f android; sleep 2; tnsa &; em &> ~/emulator.log; done"
这很糟糕,但这是我目前正在处理的内容。