26

Using gradle wrapper 2.10, and Android Gradle build tools 2.0.0-beta7 2.1.0

From my build.gradle:

buildTypes {
        all{
            minifyEnabled  true
            proguardFiles = [getDefaultProguardFile("proguard-android.txt"), 'proguard-project.pro'];
        }
    }

This works. Things are obfuscated.

I have the following line in my proguard-project.pro as well:

-printmapping my-mapping.txt

Everything else in that file works fine, but the mapping keeps getting printed to the wrong place:

Printing mapping to [C:\path\to\my\project\build\outputs\mapping\debug\mapping.txt]

Has this syntax changed?

Note: I've tried supplying a direct path. I've tried supplying a name without a hyphen. Nothing changes.

For now I just made a gradle copy task for it.

VicVu
  • 6,655
  • 5
  • 50
  • 89
  • What do you mean, Wrong place? – RaGe Feb 25 '16 at 11:29
  • @RaGe In the past, that line would put the mapping file in the project root. Now, regardless of where that line points, it always prints the mapping in the build folder AND with the wrong name, – VicVu Feb 25 '16 at 18:21
  • I'm not familiar with what it was in the past, but if you want to put it in a specific folder, you should try providing an absolute path. As for wrong name, maybe the hyphen in the file name is an issue? Try enclosing it in quotes. – RaGe Feb 25 '16 at 19:19
  • I've done all of that, it doesn't change. – VicVu Feb 25 '16 at 19:21
  • what about -basedirectory directoryname (In your proguard.pro file. Specifies the base directory for all subsequent relative file names in these configuration arguments or this configuration file.) ? – Michael D. Mar 01 '16 at 00:23
  • -printmapping in section "obfuscation options" is what you want. Provide a filespec to it and no more copy task needed..http://proguard.sourceforge.net/index.html..see gradle task then look for print mapping – Robert Rowntree Mar 24 '16 at 08:30
  • @RobertRowntree the issue is that the printmapping function is not working... – VicVu Mar 25 '16 at 05:15

5 Answers5

10

The mapping file at location build\outputs\mapping\debug\mapping.txt is the default one that gets generated even when you don't specify -printmapping my-mapping.txt inside proguard-project.pro. I see the name is always mapping.txt so -printmapping is being ignored with the new Android Studio version.

I remember it used to get generated at the same project root folder where proguard-project.pro is present but I confirm, it doesn't generate now with Android Studio 2.0 and is a bug that you can file at Android Issue Tracker.


UPDATE

Link to Android Issue: https://code.google.com/p/android/issues/detail?id=205213

random
  • 9,832
  • 8
  • 53
  • 97
  • 2
    It would seem that someone just filed it. Could you update the link to point here? https://code.google.com/p/android/issues/detail?id=205213 – Pooks Mar 29 '16 at 01:35
3

Faced with same problem, but it seems that

{projectRoot}\build\outputs\mapping\debug\mapping.txt

is correct place for mapping files now

SILINIK
  • 920
  • 7
  • 16
  • I feel like the method is simply broken. Why would the build pass with printmapping in it if it's not meant to work anymore? – VicVu Mar 23 '16 at 17:22
0

Maybe you can change to follwoing

android {
    buildTypes {
        release {
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'some-other-rules.txt'
            //proguardFile 'some-other-rules.txt' 
        }
    }
}
TanLingxiao
  • 284
  • 3
  • 7
0

Starting from Android Studio 3.5.3 and AGP 3.5.3 the -printmapping parameter is respected.

For example using:

-printmapping mapping.txt

It is copied from the default:

{projectRoot}\build\outputs\mapping\release\mapping.txt

to:

{projectRoot}\mapping.txt

MatPag
  • 29,651
  • 11
  • 74
  • 87
-1

Just try to start Android Studio as administrator.

-printmapping

may not write to system folder which cause this issue.

Mohd
  • 29
  • 4