Categories
Programming Technology

Gradle from behind a proxy, part deux

In July I wrote a post documenting how to build a project in Android Studio from behind a proxy. Essentially you need to tell Gradle Studio your proxy settings.

As of updating to Android Studio 1.0, the issue has come back! After a combination of swearing and research I’ve found the missing necessary steps.

So the new definitive steps for getting Gradle working from behind a proxy

  1. Navigate to the “.gradle” folder in your user directory (e.g. C:\Users\bob\.gradle)
  2. Create a “gradle.properties” file
  3. Edit the file to have the following contents (replacing your own values)
    systemProp.http.proxyHost=<proxy_host> 
    systemProp.http.proxyPort=<port> 
    systemProp.http.proxyUser=<user> 
    systemProp.http.proxyPassword=<password> 
    systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
  4. Go to Files > Settings > HTTP Proxy
  5. Select “Manual proxy configuration”
  6. Enter the same details you filled into the grade.properties file above: host, port, etc
  7. Tick “Proxy authentication”
  8. Fill in your username and password

Tadaa. This should get you back up and running again.

Categories
Google Glass

Android Studio – Fix sudden unresolved symbols

Android Studio is a fickle beast. At times surprisingly clever and useful, and other times a flaky nightmare.

The most recent issue I came across was when a Google Glass project suddenly stopped building with unresolved symbol errors. This manifests itself as all your “com.google.android.glass.*” imports failing, and the resulting use of any object from those libs causing compilation errors.

What the hell, Android Studio??
What the hell, Android Studio??

How to fix it

Eventually I checked my project dependencies and explicitly added the GDK as a library. Bingo, that sorted it out.

  1. Copy the gdk.jar

    This will be in your Android SDK directory, under /add-ons/addon-google_gdk-google-19/libs

  2. Paste it into the libs folder in your project directory

    e.g. C:\Projects\MyProject\app\libs

  3. Go to File > Project Structure
  4. Select your module (default name is app)
  5. Click the Dependencies tab
  6. Click the “+” sign
  7. Navigate to the libs folder and select the gdk.jar file
  8. OK through everything

I have zero idea why the issue suddenly arose. As with so many other issues I’ve come across in my short time developing for Android, I’ve learned to FDM: fix, document, and move on.