16

I’m trying to use the new Google Glass Development kit with Android Studio. Unfortunately I'm not having much success.

I get the error: "Gradle: package com.google.android.glass.touchpad does not exist"

I've added uses-library to the manifest as follows:

<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>

Then I've added the gdk.jar to the libs directory. And I've added the following to the dependency section of my build.gradle.

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

Any help with this would be very appreciated.

Smalesy
  • 571
  • 1
  • 7
  • 20
  • This is not an answer but how did you compile this? I have no glass, no way to compile. any idea please? – PeakGen Nov 21 '13 at 04:45
  • 2
    You don't need a glass (or any device for that matter) to compile and build an app. You just need one for running/testing your app. – Smalesy Nov 29 '13 at 01:52

4 Answers4

29

Change the compileSdkVersion in your build.gradle file to refer directly to the GDK add-on:

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

    // other stuff...
}

(The buildToolsVersion can be newer than 19.0.2 if you have a higher version of the SDK installed, as long as it's at least 19.0.2.)

mimming
  • 13,706
  • 3
  • 39
  • 73
Tony Allevato
  • 6,369
  • 1
  • 27
  • 33
  • Thanks, I tried this but I get an error of "project refresh failed: Cause: failed to find target Google Inc.:Google Glass SDK:15" Could I be missing a step? – Smalesy Nov 20 '13 at 23:59
  • I've edited my answer with the correct compileSdkVersion -- can you try it again? – Tony Allevato Nov 21 '13 at 00:54
  • Awesome that fixed it! Thanks for your help, much appreciated. – Smalesy Nov 21 '13 at 02:39
  • 2
    This no longer works with KitKat. I changed the string to "Google Inc.:Glass Development Kit Preview:19" and updated minSdkVersion and targetSdkVersion to 19. Gradle complains that it cannot find my platform. – Yevgeniy Apr 16 '14 at 21:47
  • 2
    Change "Google Inc.:Glass Development Kit Preview:19" to 19 and drop gdk.jar into your lib dir, just did that and it worked for me. – Ryan Apr 21 '14 at 21:05
  • As per user2914091 's comment below, you'll need to change buildToolsVersion to "19.1.0". Also, make sure minSdkVersion 19 and targetSdkVersion 19. BTW, in AndroidStudio, if you try to enter 19.0.2 it will complain and automatically resync to 19.1.0. – ATutorMe Oct 12 '15 at 06:53
1

Today is 1/10/2015, and from now on, the best option becomes:

Change the compileSdkVersion in your build.gradle file to refer directly to the GDK add-on:

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

    // other stuff...
}

You should install 19.1.0 build tools first.

0

did you try right clicking on the jar in the libs folder and hitting "add as library"?

EDIT: I've found that you have to do that in addition to adding it in module settings and the build.gradle. Also a clean/rebuild with gradle may make it work as well.

adefran83
  • 653
  • 7
  • 10
  • Instead of Add as Library, you can click on the Sync Projects with Gradle button. In the next release, the Add as Library command will add to your build.gradle, so everything will work properly in one step. – Scott Barta Nov 20 '13 at 23:19
  • Thanks for the help guys. I've tried both your suggestions but I'm still getting the package does not exist error. – Smalesy Nov 21 '13 at 00:03
0

After KitKat, changing compileSdkVersion to "Google Inc.:Glass Development Kit Preview:19" worked for me. Note: I also had to restart Android Studio after installing the GDK Preview from it's built in SDK Manager. The GDK Preview wasn't recognized by Android Studio until I restarted.

Nate
  • 120
  • 8