16

我正在尝试将新的 Google Glass 开发套件与 Android Studio 一起使用。不幸的是,我没有取得太大的成功。

我收到错误:“Gradle:com.google.android.glass.touchpad 包不存在”

我已将 uses-library 添加到清单中,如下所示:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme" >

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


    <activity
        android:name="com.glass.test.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

然后我将 gdk.jar 添加到 libs 目录中。我已将以下内容添加到我的 build.gradle 的依赖项部分。

dependencies {
    compile files('libs/gdk.jar')
}

对此的任何帮助将不胜感激。

4

4 回答 4

29

更改文件compileSdkVersion中的build.gradle以直接引用 GDK 插件:

android {
    compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
    buildToolsVersion "19.0.2"

    // other stuff...
}

buildToolsVersion如果您安装了更高版本的 SDK,则可以高于 19.0.2,只要它至少为 19.0.2。)

于 2013-11-20T23:07:08.037 回答
1

今天是 2015 年 1 月 10 日,从现在开始,最好的选择变成:

更改 build.gradle 文件中的 compileSdkVersion 以直接引用 GDK 附加组件:

android {
    compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
    buildToolsVersion "19.1.0"

    // other stuff...
}

您应该首先安装 19.1.0 构建工具。

于 2015-01-10T08:00:08.917 回答
0

您是否尝试右键单击 libs 文件夹中的 jar 并点击“添加为库”?

编辑:我发现除了在模块设置和 build.gradle 中添加它之外,您还必须这样做。使用 gradle 进行清理/重建也可以使其正常工作。

于 2013-11-20T21:07:45.370 回答
0

在 KitKat 之后,更改compileSdkVersion为“Google Inc.:Glass Development Kit Preview:19”对我有用。注意:从内置的 SDK 管理器安装 GDK 预览后,我还必须重新启动 Android Studio。在我重新启动之前,Android Studio 无法识别 GDK 预览版。

于 2014-04-29T00:02:14.643 回答