Reputation: 1494
IDE: Android Studio 1.1.0
Subject: ProGuard
Problem: ProGuard files or tools not recognized by Android Studio, getDefaultProguardFile
can not be resolved and there's no proguard-android.txt
and proguard-rules.txt
files in the app, see the image below: (from build.gradle)
How to fix this and achieve ProGuard protection to my App ?
Upvotes: 29
Views: 17815
Reputation: 44
I fixed the issue of Android Studio not recognising the method by using double quotes instead of the single. The below is what I ended up using:
release{
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile("proguard-android.txt"),
"proguard-rules.pro"
}
Upvotes: 0
Reputation: 26841
Try:
proguardFiles.add(file('proguard-android.txt'))
proguardFiles.add(file('proguard-rules.txt'))
This structure works in the gradle-experimental plugin.
Upvotes: 1
Reputation: 10177
I had the same trouble as shown here:
The error message makes it seem as if the file is not being found, and therefore not read. However, I went to into sdk/tools/proguard folder to find the file, and at the top added a statement to test if the file was actually being read. I put at the top "Will this crash it?"
As you can see from the error, the file was indeed found during the build process and the statement I added crashed it. Thus, it appears the "can't resolve symbol" error is giving a false positive.
Upvotes: 8
Reputation: 157
In my case:
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
replace runProguard false
with minifyEnabled false
works.
Upvotes: -7
Reputation: 12627
I really had the same issue. So here is what made my project working:
release {
minifyEnabled true
proguardFile 'proguard-rules.pro'
}
Tested by this code:
Log.d(TAG, "TEST!");
Log.i(TAG, "INFO!");
Log.e(TAG, "ERROR!");
In proguard.pro I placed this snippet (which removes all Log.d
-Statements in the byte-code)
-assumenosideeffects class android.util.Log {
public static int d(...);
}
And the cat says:
MainAct﹕ INFO!
MainAct﹕ ERROR!
-> exactly what I tried to achieve :)
PS: This assumes that you have the proguard.pro
file in the module (aka 'app') folder.
Upvotes: 4
Reputation: 5951
Try to change into -
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Upvotes: 7