Android Studio & ProGuard: cannot resolve symbol getDefaultProguardFile?

Fadi Obaji picture Fadi Obaji · Apr 9, 2015 · Viewed 16.7k times · Source

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)

build.gradle screenshot

How to fix this and achieve ProGuard protection to my App ?

Answer

NameSpace picture NameSpace · Jan 6, 2016

I had the same trouble as shown here:

enter image description 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?"

enter image description here

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.