Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to obfuscate project with proguard using library version 1.0.4 and 1.0.5 #20

Closed
andrey-shikhov opened this issue Nov 24, 2015 · 6 comments

Comments

@andrey-shikhov
Copy link

Proguard failed obfuscation with library 1.0.4+ but all is ok for 1.0.3.
From proguard docs:
Warning: can't find enclosing class/method If there are unresolved references to classes that are defined inside methods in your input, once more, your compiled class files are most likely inconsistent. Possibly, some class file didn't get recompiled properly, or some class file was left behind after its source file was removed. Try removing all compiled class files and rebuilding your project.

Failure log:

Warning: com.annimon.stream.Collectors$1$1: can't find enclosing method 'com.annimon.stream.function.Supplier supplier()' in program class com.annimon.stream.Collectors$1
Warning: com.annimon.stream.Collectors$1$2: can't find enclosing method 'com.annimon.stream.function.BiConsumer accumulator()' in program class com.annimon.stream.Collectors$1
Warning: com.annimon.stream.Collectors$2$1: can't find enclosing method 'com.annimon.stream.function.Supplier supplier()' in program class com.annimon.stream.Collectors$2
Warning: com.annimon.stream.Collectors$2$2: can't find enclosing method 'com.annimon.stream.function.BiConsumer accumulator()' in program class com.annimon.stream.Collectors$2
Warning: com.annimon.stream.Collectors$3$1: can't find enclosing method 'com.annimon.stream.function.Supplier supplier()' in program class com.annimon.stream.Collectors$3
Warning: com.annimon.stream.Collectors$3$2: can't find referenced field 'java.lang.CharSequence val$delimiter' in program class com.annimon.stream.Collectors$3
Warning: com.annimon.stream.Collectors$3$2: can't find referenced field 'java.lang.CharSequence val$prefix' in program class com.annimon.stream.Collectors$3
Warning: com.annimon.stream.Collectors$3$2: can't find enclosing method 'com.annimon.stream.function.BiConsumer accumulator()' in program class com.annimon.stream.Collectors$3
Warning: com.annimon.stream.Collectors$3$3: can't find referenced field 'java.lang.String val$emptyValue' in program class com.annimon.stream.Collectors$3
Warning: com.annimon.stream.Collectors$3$3: can't find referenced field 'java.lang.CharSequence val$suffix' in program class com.annimon.stream.Collectors$3
Warning: com.annimon.stream.Collectors$3$3: can't find enclosing method 'com.annimon.stream.function.Function finisher()' in program class com.annimon.stream.Collectors$3
Warning: com.annimon.stream.Collectors$4$1: can't find enclosing method 'com.annimon.stream.function.Supplier supplier()' in program class com.annimon.stream.Collectors$4
Warning: com.annimon.stream.Collectors$4$2: can't find referenced field 'com.annimon.stream.function.Function val$mapper' in program class com.annimon.stream.Collectors$4
Warning: com.annimon.stream.Collectors$4$2: can't find enclosing method 'com.annimon.stream.function.BiConsumer accumulator()' in program class com.annimon.stream.Collectors$4
Warning: com.annimon.stream.Collectors$4$3: can't find enclosing method 'com.annimon.stream.function.Function finisher()' in program class com.annimon.stream.Collectors$4
Warning: com.annimon.stream.Collectors$5$1: can't find enclosing method 'com.annimon.stream.function.Supplier supplier()' in program class com.annimon.stream.Collectors$5
Warning: com.annimon.stream.Collectors$5$2: can't find enclosing method 'com.annimon.stream.function.BiConsumer accumulator()' in program class com.annimon.stream.Collectors$5
Warning: com.annimon.stream.Collectors$5$3: can't find enclosing method 'com.annimon.stream.function.Function finisher()' in program class com.annimon.stream.Collectors$5
Warning: com.annimon.stream.Collectors$7$1: can't find referenced field 'com.annimon.stream.function.Function val$classifier' in program class com.annimon.stream.Collectors$7
Warning: com.annimon.stream.Collectors$7$1: can't find referenced field 'com.annimon.stream.Collector val$downstream' in program class com.annimon.stream.Collectors$7
Warning: com.annimon.stream.Collectors$7$1: can't find enclosing method 'com.annimon.stream.function.BiConsumer accumulator()' in program class com.annimon.stream.Collectors$7
Warning: com.annimon.stream.Collectors$7$2: can't find referenced field 'com.annimon.stream.Collector val$downstream' in program class com.annimon.stream.Collectors$7
Warning: com.annimon.stream.Collectors$7$2: can't find enclosing method 'com.annimon.stream.function.Function finisher()' in program class com.annimon.stream.Collectors$7
Warning: com.annimon.stream.function.BiFunction$Util$2: can't find enclosing method 'com.annimon.stream.function.BiFunction minBy(java.util.Comparator)' in program class com.annimon.stream.function.BiFunction$Util
Warning: com.annimon.stream.function.BiFunction$Util$3: can't find enclosing method 'com.annimon.stream.function.BiFunction maxBy(java.util.Comparator)' in program class com.annimon.stream.function.BiFunction$Util

@aNNiMON
Copy link
Owner

aNNiMON commented Nov 24, 2015

@andrey-shikhov what proguard config you use?

Try this option
-keepattributes EnclosingMethod

@andrey-shikhov
Copy link
Author

Proguard options don't matter because proguard interrupts itself during loading all library jars to build dependency tree, before obfuscation begin.
I created sample project which shows issue, try to run './gradlew assembleRelease' and it will fail, but assembleDebug version is working. https://drive.google.com/file/d/0B5KouoPaI5qqUWZvemk3RktCN1U/view?usp=sharing

@aNNiMON
Copy link
Owner

aNNiMON commented Nov 25, 2015

@andrey-shikhov this is just warning. I think default proguard configuration was changed with latest Android SDK Tools version, so it fails instead ignoring warnings.

Try this option:
-dontwarn com.annimon.stream.**

@andrey-shikhov
Copy link
Author

So, I made some research, proguard dontwarn seems to be working. I also made check out this repository and assembled library. Then, replaced remote dependency in test project above with that jar and these warnings are gone(without dontwarn rule), so I think something is wrong with build in repository.
My config: Ubuntu 15.10 x64, oracle jdk 1.8.0_66

@aNNiMON
Copy link
Owner

aNNiMON commented Dec 4, 2015

Thanks for pointing to that issue. You're right, the problem is in build system.

I've updated library on Maven, please, check it now. Perhaps, you will need to clean gradle cache /.gradle/caches/modules-2/files-2.1/com.annimon/stream/. Since you're using jcenter, it may need more time to update library.

@jaredsburrows
Copy link

@andrey-shikhov I ma using gradle with no proguard rules it everything is working file. Can you share you build.gradle?

@aNNiMON aNNiMON closed this as completed Mar 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants