Is there any way to run glassware in an emulator?

2020-02-19 08:50发布

问题:

Today Google just released the GDK Sneak Peak for Google Glass. I have tried to run the samples they have hosted in GitHub with no success:

  • gdk-stopwatch-sample
  • gdk-compass-sample
  • gdk-timer-sample

I am targetting against Android 4.0.3 Glass Development Kit Sneaky Preview and trying to run it in an AVD that also targets it with the following other specs:

  • 640x360 hdpi
  • For the CPU I tried both ARM & Intel Atom

When I run the app and the dialog to choose the device is shown I do see the virtual device as non compatible.

If I skip it and try to run it I see the following error output:

Installing com.google.android.glass.sample.compass
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.google.android.glass.sample.compass"
pkg: /data/local/tmp/com.google.android.glass.sample.compass
Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY]

I have tried to force not to require the glass library (setting the requirement to false) in the AndroidManifest.xml:

<uses-library
    android:name="com.google.android.glass"
    android:required="false" />

... but obviously doesn't run properly, it's being shown in kind of an overlay:

I have also tried using Genymotion, but it doesn't run either.

Is there any way to run successfully glassware in an emulator?

EDIT:

Adding the gdk.jar as a library doesn't work.

回答1:

Only a small percentage of the sample code seems to be using the GDK libraries. For example, the Compass example has a CompassService that is in charge of attaching the CompassRenderer into the Glass Live Card. It also has a CompassMenuActivity, that basically has calls to standard Android menu rendering. Those could be called a "glue" that wrap the compass-functionality into the Glass experience. Major parts of the compass code are just standard Android libraries.

Assuming that the emulator currently does not have a way to run glass libraries (and no-one has hacked them into it yet), and if you want to run the Compass example without actual Glass hardware, you need to implement the Service & MenuActivity in your own "standard Android" way. Basically, create an activity that implements the CompassRenderer in a surfaceview.

Have a look at these commits for an example (tested on Galaxy S4, views are being rendered and menu items are functional):

https://github.com/blaind/gdk-stopwatch-sample/commit/26e9801af983b9fc931d6dfe5ce1fcb80766fd10 https://github.com/blaind/gdk-compass-sample/commit/0d89e922a167c0fac6890684c514b9028e7bfea8