【问题标题】:How to run a Google Glass GDK sample on the device?如何在设备上运行 Google Glass GDK 示例?
【发布时间】:2014-01-06 11:47:56
【问题描述】:

我开始使用 GDK 开发 Google Glass 应用程序。

我使用 Eclipse 和 Android SDK Manager 来安装 GDK。

之后,我按照here 提到的步骤导入 Google Glass 项目:

  1. 点击文件>新建项目>Android示例项目
  2. 选择Glass Development Kit作为构建目标,然后点击下一步。
  3. 选择Timer示例并点击Finish
  4. 在 Eclipse Package Explorer 中,右键单击示例并选择 Run as > Android Application,并将 Glass 连接到您的开发系统。

Google Glass(XE12 版)已连接,但没有任何显示。然后,我跟随另一个tutorial在线使用adb命令手动启动应用程序:

./adb shell am start -n com.google.android.glass.sample.timer/.MenuActivity

但结果是 Permission Denial:

$ ./adb shell am start -n com.google.android.glass.sample.timer/.MenuActivity
Starting: Intent { cmp=com.google.android.glass.sample.timer/.MenuActivity }
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.google.android.glass.sample.timer/.MenuActivity } from null (pid=2938, uid=2000) not exported from uid 10032
    at android.os.Parcel.readException(Parcel.java:1327)
    at android.os.Parcel.readException(Parcel.java:1281)
    at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1631)
    at com.android.commands.am.Am.runStart(Am.java:441)
    at com.android.commands.am.Am.run(Am.java:108)
    at com.android.commands.am.Am.main(Am.java:81)
    at com.android.internal.os.RuntimeInit.finishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:238)
    at dalvik.system.NativeStart.main(Native Method)

如何解决问题?

另一方面,我使用 Eclipse 制作了一个类似于 Android 示例的 App。我在 Eclipse 菜单栏中单击 Run as > Android Application 后,控制台说:

[2014-01-06 18:55:10 - Glass001] Android Launch!
[2014-01-06 18:55:10 - Glass001] adb is running normally.
[2014-01-06 18:55:10 - Glass001] No Launcher activity found!
[2014-01-06 18:55:10 - Glass001] The launch will only sync the application package on the device!
[2014-01-06 18:55:10 - Glass001] Performing sync
[2014-01-06 18:55:10 - Glass001] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2014-01-06 18:55:17 - Glass001] Uploading Glass001.apk onto device '015DBXXXXXX701C'
[2014-01-06 18:55:17 - Glass001] Installing Glass001.apk...
[2014-01-06 18:55:20 - Glass001] Success!
[2014-01-06 18:55:20 - Glass001] /Glass001/bin/Glass001.apk installed on device
[2014-01-06 18:55:20 - Glass001] Done!
[2014-01-06 18:56:48 - Glass001] ------------------------------

这是否与错误消息“未找到启动器活动!”有关? ?提到这个错误,我在 Stack Overflow 中找到了一个answer。我应该把下面AndroidManifest.xml中的行放在哪里?

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android.glass.sample.timer"
    android:versionCode="2"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="15" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_timer"
        android:label="@string/app_name" >

        <activity
            android:name="com.google.android.glass.sample.timer.MenuActivity"
            android:label="@string/app_name"
            android:theme="@style/MenuTheme"
            android:enabled="true" >
        </activity>

        <activity
            android:name="com.google.android.glass.sample.timer.SetTimerActivity"
            android:label="@string/app_name"
            android:enabled="true" >
        </activity>

        <activity
            android:name="com.google.android.glass.sample.timer.SelectValueActivity"
            android:label="@string/app_name"
            android:enabled="true" >
        </activity>

        <service
            android:name="com.google.android.glass.sample.timer.TimerService"
            android:icon="@drawable/ic_timer"
            android:label="@string/app_name"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
            </intent-filter>
            <meta-data
                android:name="com.google.android.glass.VoiceTrigger"
                android:resource="@xml/voice_trigger_start" />
        </service>

    </application>

</manifest>

Google Glass 的调试模式已开启(是的,我可以在 Eclipse 中看到该设备)

【问题讨论】:

    标签: java android eclipse google-glass google-gdk


    【解决方案1】:

    您需要设置一个适用于此的调试配置。最初,如果没有用户交互,此应用程序将无法启动。如果您转到调试下拉菜单并说配置,您可以让它自动启动您选择的活动。因此,在顶部选择项目,然后当它询问要做什么时,使用旁边的下拉框说自动启动活动。使用下拉菜单选择要自动启动的活动。然后尝试调试应用程序,它应该会在您的玻璃上自动推送和启动。

    【讨论】:

    • 调试下拉菜单并说配置,您可以让它自动启动您选择的活动它在哪里?在 Glass 菜单/Eclipse 中?我是 Google Glass 新手。
    • 这个选项在eclipse中。它应该在错误按钮旁边的顶部,您将有一个下拉菜单,其中一个选项是调试配置或编辑配置。
    • 此外,如果您想对活动进行硬编码以启动,我只需将意图行添加到服务中,因为这通常是您从“ok glass”命令屏幕执行语音命令时启动的内容。这就是您在服务中看到意图过滤器的原因。
    • 有效!奇怪的是,默认情况下,没有要启动的默认活动。
    • 这是因为对于谷歌眼镜,您的活动不是默认情况下从语音意图触发的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-28
    相关资源
    最近更新 更多