meteor使ってみた2

meteorのサイトのtutorialに従って、いろいろいじってみると、
7.Running on mobileの
Running on an Android emulatorの

$ meteor install-sdk android

✓ Found Android bundle
✓ A JDK is installed
✓ Found Android Platform tools
✓ Found Android Build Tools
✗ 32-bit libraries not found
✓ Found Android 19 API
✓ Found suitable Android x86 image
✓ 'meteor' android virtual device (AVD) found
Android emulator acceleration is not installed
(The Android emulator will be very slow without acceleration)
Platform requirements not yet met
Please follow the instructions here:

https://github.com/meteor/meteor/wiki/Mobile-Dev-Install:-Android-on-Linux#libs32

となって、32bitライブラリが入ってないので、でつまずいた。
(マシンはCentOS 6.5 64bit)
指示されたurlをみると、JDK1.7と32bitライブラリが必要とのことなので、wikiに書いてある通りに、インストールした。
$ sudo yum install -y java-1.7.0-openjdk-devel
は成功したが
sudo yum install -y glibc.i686 zlib.i686 libstdc++.i686 ncurses-libs.i686

エラー: Multilib version problems found. This often means that the root
cause is something else and multilib version checking is just
pointing out that there is a problem. Eg.:

1. You have an upgrade for libstdc++ which is missing some
dependency that another package requires. Yum is trying to
solve this by installing an older version of libstdc++ of the
different architecture. If you exclude the bad architecture
yum will tell you what the root cause is (which package
requires what). You can try redoing the upgrade with
--exclude libstdc++.otherarch ... this should give you an error
message showing the root cause of the problem.

2. You have multiple architectures of libstdc++ installed, but
yum can only see an upgrade for one of those arcitectures.
If you don't want/need both architectures anymore then you
can remove the one with the missing update and everything
will work.

3. You have duplicate versions of libstdc++ installed already.
You can use "yum check" to get yum show these errors.

...you can also use --setopt=protected_multilib=false to remove
this checking, however this is almost never the correct thing to
do as something else is very likely to go wrong (often causing
much more problems).

Protected multilib versions: libstdc++-4.4.7-11.el6.i686 != libstdc++-4.4.7-4.el6.x86_64

となってインストールできず。原因がよく分からないので、一個ずつインストールしていくと

$ sudo yum install libgcc.i686
をおこなうと、同じエラーがでるので、こいつがインストールできないらしい。
メッセージの2番を試してみる。
現在インストールされているlibstdc++依存関係を整理する。
$ sudo yum update libstdc++ --exclude libstdc++.otherarch

...中略

依存性を更新しました:
cpp.x86_64 0:4.4.7-11.el6 gcc.x86_64 0:4.4.7-11.el6
gcc-c++.x86_64 0:4.4.7-11.el6 libgomp.x86_64 0:4.4.7-11.el6
libstdc++-devel.x86_64 0:4.4.7-11.el6

となって依存性が解決されたらしいので、再び

$ sudo yum install libgcc.i686

とやると、うまくインストールされた。

つぎに、/dev/kvm が無いので、kvmがインストールされているか調べた
$ lsmod | grep kvm

で何も表示されないので、kvmをインストールする

$ yum -y install qemu-kvm libvirt virt-install bridge-utils

kvmがロードされているか再び調べる
$ lsmod | grep kvm
kvm 317376 0

kvm_intelの表示が無いが、多分OKということで、最初の
$ meteor install-sdk android
を再びやってみる。

✓ Found Android bundle
✓ A JDK is installed
✓ Found Android Platform tools
✓ Found Android Build Tools
✓ Found Android 19 API
✓ Found suitable Android x86 image
✓ 'meteor' android virtual device (AVD) found
Android emulator acceleration is installed

でうまくいったようだ。

次にemulatorを動かしてみる

$ meteor add-platform android
ライセンス条項にYesをし、
$ meteor run android
かなり遅いが、emulatorが立ち上がる。しかし、アプリケーションはインストールされている様子はないので、

http://stackoverflow.com/questions/26533077/meteor-run-android-runs-app-and-launches-android-emulator-but-i-cannot-find

を見習って、一度ctrl-cでmeteor run androidを止めて、emulatorはそのままにしておき、再び
$ meteor run android
を行うと、見事、androidネイティブでアプリケーションが立ち上がった。

しかも、ブラウザで開いているアプリケーションと同期
している!なんとすばらしい!

次に実際のデバイスでも動かしてみる。
XperiaをUSBデバッグモードにして、USBでPCとつなぎ

$ meteor run android-device
Could not start the app on your device. Is it plugged in?
Try running again with the --verbose option.
Instructions for running your app on an Android device:
https://github.com/meteor/meteor/wiki/How-to-run-your-app-on-an-Android-device

とつながれていないというようなメッセージ。
$ /home/nabe/.meteor/android_bundle/android-sdk/platform-tools/adb devices
List of devices attached
???????????? no permissions

となっている。どうも認識されていないようだ。

指示されたURLをみて、usbの接続ルールが無いようなので、さっそく作る。

$ cd /etc/udev/rules.d
$ vi 51-android.rules

                                                        • -

UBSYSTEM=="usb", SYSFS{idVendor}=="502", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="0b05", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="413c", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="489", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="04c5", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="04c5", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="091e", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="109b", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="12d1", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="24000", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="2116", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="482", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="17ef", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="1004", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="409", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="2080", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="955", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="2257", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="10a9", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="1d4d", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="471", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="04da", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="05c6", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="1f53", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="400000000", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="04dd", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="054c", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="0fce", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="2340", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="930", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="19d2", SYMLINK+="android_adb",MODE="0666", GROUP="plugdev"

                                                                            • -

と記述。参考にしたのは
http://www.tekops.com/sub/index.php?option=com_content&view=article&id=186:anroid-sdk-and-adb-with-centos-5-and-usb-solution&catid=59:tek-articles&Itemid=100

その後
$ /home/nabe/.meteor/android_bundle/android-sdk/platform-tools/adb kill-server
$ /home/nabe/.meteor/android_bundle/android-sdk/platform-tools/adb start-server

もう一度、
$ /home/nabe/.meteor/android_bundle/android-sdk/platform-tools/adb devices
List of devices attached
???????????? no permissions

同じ結果だ。
ちなみに
$ lsusb
Bus 002 Device 034: ID 0fce:5178 Sony Ericsson Mobile Communications AB
だと、つながってる。

しかし、何度かやってるうちに
$ /home/nabe/.meteor/android_bundle/android-sdk/platform-tools/adb devices
List of devices attached
CB5A1LK24G device

認識された。時間がかかるのであろうか?

再び
$ meteor run android-device

無事Xperia上で動いた!