labunix's blog

labunixのラボUnix

debian busterにAndroid Emulatorを導入してみる。

■debian busterにAndroid Emulatorを導入してみる。
 Android-SDKとAndroid Studioを導入、AVD(仮想デバイス)を作成、起動する。

$ lsb_release -d
Description:	Debian GNU/Linux 10 (buster)

■android-sdkを探す。

$ apt-cache search android-sdk
android-sdk-platform-23 - Android SDK Platform for API Level 23 (6.0 Marshmallow)
adb - Android Debug Bridge
android-sdk-libsparse-utils - Android sparse image creation tool
android-sdk-ext4-utils - Android ext4-utils tools
android-sdk - Software development kit for Android platform
android-sdk-build-tools - Tools for building Android applications
android-sdk-build-tools-common - Tools for building Android applications - Common files
android-sdk-common - Common files of Android SDK base toolset
android-sdk-platform-tools - Tools for interacting with an Android platform
android-sdk-platform-tools-common - Tools for interacting with an Android platform - Common files

■依存関係の確認。oracle-jdkを除く。

$ apt-cache show android-sdk | \
  awk -F\, '/Depends/{for(a=2;a<=NF;a++){gsub("oracle.*dk|oracle.*er","",$a);print $a}}'
 android-sdk-common (>= 25.0.0+11+deb10u1)
 android-sdk-platform-tools (>= 20)
 default-jdk-headless (>= 2:1.8) | default-jdk (>= 2:1.8) | 
 proguard-cli

$ echo "android-sdk-common android-sdk-platform-tools default-jdk-headless default-jdk proguard-cli" | \
  awk '{for(a=1;a<=NF;a++){print "echo \042["$a"]\042;apt-cache show "$a" | ./myscripts/lsec Version" | "sh"}}'
[android-sdk-common]
Version: 25.0.0+11+deb10u1
[android-sdk-platform-tools]
Version: 27.0.0+11+deb10u1
[default-jdk-headless]
Version: 2:1.11-71
[default-jdk]
Version: 2:1.11-71
[proguard-cli]
Version: 6.0.3-1

■もう2階層ほど依存関係を探ってみる。

$ echo "android-sdk-common android-sdk-platform-tools default-jdk-headless default-jdk proguard-cli" | \
  awk '{for(a=1;a<=NF;a++){print "echo \042["$a"]\042;apt-cache show "$a | "sh"}}' | \
  awk -F\, '{if($0 ~ /\[/){print $0}else{if($0 ~ /Depends/){for(a=2;a<=NF;a++){gsub("oracle.*dk|oracle.*er","",$a);print $a}}}}'
[android-sdk-common]
[android-sdk-platform-tools]
 android-sdk-platform-tools-common (>= 27.0.0~)
 e2fsprogs
 f2fs-tools
 dmtracedump (>= 8.1.0+r23~)
 etc1tool (>= 8.1.0+r23~)
 fastboot (>= 1:8.1.0+r23~)
 hprof-conv (>= 8.1.0+r23~)
 sqlite3
[default-jdk-headless]
 openjdk-11-jdk-headless
[default-jdk]
 default-jdk-headless (= 2:1.11-71)
 openjdk-11-jdk
[proguard-cli]
 libproguard-java

$ echo " android-sdk-platform-tools-common e2fsprogs f2fs-tools dmtracedump etc1tool \
  fastboot hprof-conv sqlite3 openjdk-11-jdk-headless default-jdk-headless openjdk-11-jdk libproguard-java"
  awk '{for(a=1;a<=NF;a++){print "echo \042["$a"]\042;apt-cache show "$a | "sh"}}' | \
  awk -F\, '{if($0 ~ /\[/){print $0}else{if($0 ~ /Depends/){for(a=2;a<=NF;a++){gsub("oracle.*dk|oracle.*er","",$a);print $a}}}}'
[android-sdk-platform-tools-common]
[e2fsprogs]
 libc6 (>= 2.14)
 libcom-err2 (>= 1.43.9)
 libext2fs2 (= 1.44.5-1+deb10u3)
 libss2 (>= 1.38)
 libuuid1 (>= 2.16)
 libc6 (>= 2.14)
 libcom-err2 (>= 1.43.9)
 libext2fs2 (= 1.44.5-1+deb10u2)
 libss2 (>= 1.38)
 libuuid1 (>= 2.16)
[f2fs-tools]
 libf2fs-format4 (= 1.11.0-1.1)
 libblkid1 (>= 2.17.2)
 libc6 (>= 2.14)
 libselinux1 (>= 2.0.65)
 libuuid1 (>= 2.16)
[dmtracedump]
 libc6 (>= 2.4)
 libgcc1 (>= 1:3.0)
 libstdc++6 (>= 5)
[etc1tool]
 libc6 (>= 2.14)
 libgcc1 (>= 1:3.0)
 libpng16-16 (>= 1.6.2-1)
 libstdc++6 (>= 4.1.1)
[fastboot]
 android-libbase
 android-libcutils
 android-libf2fs-utils
 android-libsparse
 android-libutils
 android-libziparchive
 libc6 (>= 2.15)
 libgcc1 (>= 1:3.0)
 libstdc++6 (>= 5.2)
[hprof-conv]
[sqlite3]
 libreadline7 (>= 6.0)
 zlib1g (>= 1:1.2.0)
 libsqlite3-0 (= 3.27.2-3)
[openjdk-11-jdk-headless]
 libc6 (>= 2.2.5)
 zlib1g (>= 1:1.1.4)
 libc6 (>= 2.2.5)
 zlib1g (>= 1:1.1.4)
[default-jdk-headless]
 openjdk-11-jdk-headless
[openjdk-11-jdk]
 openjdk-11-jdk-headless (= 11.0.8+10-1~deb10u1)
 libc6 (>= 2.2.5)
 zlib1g (>= 1:1.1.4)
 openjdk-11-jdk-headless (= 11.0.6+10-1~deb10u1)
 libc6 (>= 2.2.5)
 zlib1g (>= 1:1.1.4)
[libproguard-java]

■javaは「openjdk-11-jre-headless:amd64」が導入済み。

$ dpkg -l | awk '$1 ~ /ii/&&$2 ~ /jdk/{print $2,$3}'
openjdk-11-jre:amd64 11.0.8+10-1~deb10u1
openjdk-11-jre-headless:amd64 11.0.8+10-1~deb10u1

$ java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Debian-1deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Debian-1deb10u1, mixed mode, sharing)

$ whereis java
java: /usr/bin/java /etc/java /usr/share/java /usr/share/man/man1/java.1.gz

$ apt-file search man1/java.1.gz
openjdk-11-jre-headless: /usr/lib/jvm/java-11-openjdk-amd64/man/ja_JP.UTF-8/man1/java.1.gz
openjdk-11-jre-headless: /usr/lib/jvm/java-11-openjdk-amd64/man/man1/java.1.gz

$ dpkg -L openjdk-11-jre-headless:amd64 | grep bin\/java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java

■「android-sdk」を導入。
 予想するまでもなく待たされるので、気長に待つ。

$ sudo apt-get install -y android-sdk

■「snap」の導入。

$ apt-cache show snapd | ./myscripts/lsec Desc
Description-en: location of genes from DNA sequence with hidden markov model
 SNAP is a general purpose gene finding program suitable for both eukaryotic
 and prokaryotic genomes. SNAP is an acroynm for Semi-HMM-based Nucleic Acid
 Parser.
Description-md5: 6d9a04153222c1b616dbca686c88945d

$ sudo apt-get install -y snapd

$ sudo snap install android-studio --classic

$ snap list
Name            Version    Rev   Tracking       Publisher     Notes
android-studio  4.0.1.0    91    latest/stable  snapcrafters  classic
core            16-2.45.2  9665  latest/stable  canonical✓    core

$ mount | grep snap
/var/lib/snapd/snaps/core_9665.snap on /snap/core/9665 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/android-studio_91.snap on /snap/android-studio/91 type squashfs (ro,nodev,relatime,x-gdu.hide)

$ find /snap/ -type f 2>/dev/null | grep "/bin/studio.sh"
/snap/android-studio/91/android-studio/bin/studio.sh

$ sudo ln -s /snap/android-studio/91/android-studio/bin/studio.sh /usr/local/bin/studio.sh
$ studio.sh

■AVD(仮想デバイス)は特にこだわりは無いので適当に作成する。

 AVD(Android仮想デバイス)の作成とエミュレータの起動
 https://www.javadrive.jp/android/emulator/

 AVD ManagerからAVD(仮想デバイス)を作成する
 https://www.javadrive.jp/android/emulator/index7.html

Name: Nexus_One_API_26
CPU/ABI: Google APIs Intel Atom (x86)
Path: /home/labunix/.android/avd/Nexus_One_API_26.avd
Target: google_apis [Google APIs] (API level 26)
Skin: nexus_one
SD Card: 512M
fastboot.chosenSnapshotFile: 
runtime.network.speed: full
hw.accelerometer: yes
hw.device.name: Nexus One
hw.lcd.width: 480
hw.initialOrientation: Portrait
image.androidVersion.api: 26
tag.id: google_apis
hw.mainKeys: yes
hw.camera.front: None
avd.ini.displayname: Nexus One API 26
hw.gpu.mode: auto
hw.ramSize: 512
PlayStore.enabled: false
fastboot.forceColdBoot: no
hw.cpu.ncore: 2
hw.keyboard: yes
hw.sensors.proximity: yes
hw.dPad: no
hw.lcd.height: 800
vm.heapSize: 48
skin.dynamic: yes
hw.device.manufacturer: Google
hw.gps: yes
hw.audioInput: yes
image.sysdir.1: system-images/android-26/google_apis/x86/
showDeviceFrame: yes
hw.camera.back: virtualscene
AvdId: Nexus_One_API_26
hw.lcd.density: 240
hw.arc: false
hw.device.hash2: MD5:ef39e456bf2cab397201c2ac251f35fc
fastboot.forceChosenSnapshotBoot: no
fastboot.forceFastBoot: yes
hw.trackBall: yes
hw.battery: yes
hw.sdCard: yes
tag.display: Google APIs
runtime.network.latency: none
disk.dataPartition.size: 800M
hw.sensors.orientation: no
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes

■日本語入力できるように設定。

 Androidエミュレーターの起動と言語や日本語入力の設定
 https://www.javadrive.jp/android/emulator/index4.html

■iOSとのクロスコンパイル向けには「flutter」を導入する。

 Snap(Snappy) コマンドの使い方
 https://mekou.com/linux-magazine/snapsnappy-%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E4%BD%BF%E3%81%84%E6%96%B9/

$ snap find flutter
Name                   Version             Publisher      Notes    Summary
flutter                0+git.142868f       flutter-team✓  classic  Flutter SDK
flutter-gallery        v2.4-7-g576217a682  flutter-team✓  -        Flutter Gallery
flutter-ui-challenges  1.0.0               dlohani48      -        Flutter UI Challenges
flutter-calculator     1.0.0               almejo         -        A simple calculator written in dart and flutter.
counter                1.0.10              navoki         -        Flutter Demo Counter Application
navoki-notes           1.0.3               navoki         -        Take notes and sync on all your devices Mobile, Web, Desktop
flokk-contacts         1.0.1               gskinner-apps  -        Flokk Contacts
color-match            1.0.2               mivoligo       -        Very hard game with no rewards
lizard-game            0.5                 fede-106       -        Jump with the lizard to get the highest score.
raspberrymonitor       1.0.2+teamcity      pspgt          -        raspberry system monitor
opentrivia             1.0.1               dlohani48      -        Flutter Opentrivia
battalion              1.4c                cmatsuoka      -        Monsters, explosions, senseless destruction

$ snap search flutter
Name                   Version             Publisher      Notes    Summary
flutter                0+git.142868f       flutter-team✓  classic  Flutter SDK
flutter-gallery        v2.4-7-g576217a682  flutter-team✓  -        Flutter Gallery
flutter-ui-challenges  1.0.0               dlohani48      -        Flutter UI Challenges
flutter-calculator     1.0.0               almejo         -        A simple calculator written in dart and flutter.
counter                1.0.10              navoki         -        Flutter Demo Counter Application
navoki-notes           1.0.3               navoki         -        Take notes and sync on all your devices Mobile, Web, Desktop
flokk-contacts         1.0.1               gskinner-apps  -        Flokk Contacts
color-match            1.0.2               mivoligo       -        Very hard game with no rewards
lizard-game            0.5                 fede-106       -        Jump with the lizard to get the highest score.
raspberrymonitor       1.0.2+teamcity      pspgt          -        raspberry system monitor
opentrivia             1.0.1               dlohani48      -        Flutter Opentrivia
battalion              1.4c                cmatsuoka      -        Monsters, explosions, senseless destruction