繁体   English   中英

如何在设备上运行Google Glass GDK示例?

[英]How to run a Google Glass GDK sample on the device?

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

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

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

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

谷歌眼镜(版本XE12)已连接,但没有任何显示。 然后,我在线阅读另一个教程 ,使用adb命令手动启动App:

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

但结果是权限拒绝:

$ ./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示例的应用程序。 在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中找到了答案 我应该在哪里放置以下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的调试模式为ON(是的,我可以在Eclipse中看到该设备)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM