Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

cannot resolve symbol 'getDefaultProguardFile'

Note: I'm using Android Studio 1.0.2.

  1. Error in build.gradle: cannot resolve symbol 'getDefaultProguardFile'
  2. before I changed it, this is what it looked like (note use of minifyEnabled instead of runProguard in the video):
  minifyEnabled false
  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

The error is ignored unless I try to build an APK.

snippet of build.gradle below for release:

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }

proguard-rules.pro file (ignoring comments) below:

-assumenosideeffects class android.util.Log {
    public static boolean isLoggable(java.lang.String, int);
    public static int v(...);
    public static int i(...);
    public static int w(...);
    public static int d(...);
    public static int e(...);
}

If I comment out the proguardFiles line, then it lets me build an APK. I assume it just doesn't do any of the cool cleanup stuff.

Is this an Android Studio bug? Are others having this problem?

1 Answer

This worked for me Android Studio 1.3

    buildTypes {
        release {
            minifyEnabled false
           // This was not working
           //  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            proguardFiles 'proguard-rules.pro'
        }