Bug 37992 - I keep getting error when proguard is enabled:
Summary: I keep getting error when proguard is enabled:
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2016-01-25 13:46 UTC by Sam
Modified: 2016-02-08 09:28 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Shows the build errors (475.79 KB, text/plain)
2016-01-25 13:46 UTC, Sam
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Sam 2016-01-25 13:46:32 UTC
Created attachment 14716 [details]
Shows the build errors

0
down vote
favorite
1
Hi I'm trying to reduce my app size by enabling proguard. I keep getting error when proguard is enabled:

Java.exe exited with code 1. File: Xamarin.Android.Common.targets.
All the posts online refer to Gradle, but not sure what gradle means, i think its some kind of plugin but i'm not using that...

Any ideas on a fix? It was working previously with the same project so it is unusual.
Comment 1 Sam 2016-01-25 14:57:24 UTC
.cfg file

___________________________________________________________________________

# This is Xamarin-specific (and enhanced) configuration.

-dontobfuscate

-keep class mono.MonoRuntimeProvider
-keep class mono.MonoPackageManager
-keep class mono.MonoPackageManager_Resources
-keep class mono.android.**
-keep class mono.java.**
-keep class mono.javax.**
-keep class opentk.platform.android.AndroidGameView
-keep class opentk.GameViewBase
-keep class opentk_1_0.platform.android.AndroidGameView
-keep class opentk_1_0.GameViewBase
# hash for android.runtime
-keep class md52ce486a14f4bcd95899665e9d932190b.**
-keepclassmembers class md52ce486a14f4bcd95899665e9d932190b.** {
	<init>(***);
}

# Android's template misses fluent setters...
-keepclassmembers class * extends android.view.View {
   *** set*(***);
}

# also misses those inflated custom layout stuff from xml...
-keepclassmembers class * extends android.view.View {
   <init>(android.content.Context,android.util.AttributeSet);
   <init>(android.content.Context,android.util.AttributeSet,int);
}
Comment 2 Atsushi Eno 2016-02-08 09:28:59 UTC
Everything is described in your build output. There is a lot of warning messages from proguard output, and it ends up with this: 

>    java.io.IOException: Please correct the above warnings first.
>    	at proguard.Initializer.execute(Initializer.java:321)
>    	at proguard.ProGuard.initialize(ProGuard.java:211)
>    	at proguard.ProGuard.execute(ProGuard.java:86)
>    	at proguard.ProGuard.main(ProGuard.java:492)

What are those warnings? I found those ones (but not limited to those) problematic:

>    PROGUARD : warning : okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
>    PROGUARD : warning : okio.Okio: can't find referenced class java.nio.file.Files

The first line tells you didn't give additional jars to the project in any form (InputJar/EmbeddedJar/etc.).

The second line implies that the library you are trying to bind does NOT support Android, because its referencing API java.nio.file.Files does not exist on Android.