6

I try to resolve this issue last few days, still without success. If I build release version without proguard then everything is OK.

I read many topics about possible problems but nothing help in my case. So far I did as follow:

  1. Java max heap size - 1G
  2. Use "mklink" - mklink /j C:\android-sdk “C:\Program Files (x86)\Android\android-sdk”
  3. Created own proguard.cfg with content:

General Android -dontwarn org.apache.http.** -dontwarn android.net.http.AndroidHttpClient

Android Support Library

-keep class android.support.multidex.MultiDexApplication

-keep class android.support.v4.**

-keep class android.support.v7.** { public *; }

Google Play Billing

-keep class com.android.vending.billing.**

Google Play Services

-dontwarn com.google.android.gms.internal.*

-keep class * extends java.util.ListResourceBundle { protected java.lang.Object[][] getContents(); }

  1. Manually update ProGuard to latest version.

And the result is 0 warnings and 1 error.

ERROR: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1929,3): error MSB6006: "java.exe" exited with code 1.

What else can I do? Please help.

Update. I created brand new app "Xamarin Hello World" and there "ProGuard" works. So it must be something wrong with my app not a system. But visual studio doesn't show me any other error apart that Java code 1. So how to track where is a problem?

UPDATE The problem was in my "proguard.cfg" file. I copy content from other source and one line there should be comment but it wasn't. So this problem gone. But now some warnings come out:

2>PROGUARD : warning : can't write resource [META-INF/MANIFEST.MF](Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF]) 
2>Copying resources from program jar [G:\ApkiC-Sharp\GNote\GNote\GNote.Android\obj\Release\__library_projects__\Xamarin.GooglePlayServices.Basement\library_project_imports\classes.jar](TaskId:345) 
2>PROGUARD : warning : can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF]) 
2>Copying resources from program jar [G:\ApkiC-Sharp\GNote\GNote\GNote.Android\obj\Release\__library_projects__\Xamarin.GooglePlayServices.Maps\library_project_imports\classes.jar] (TaskId:345) 
2>PROGUARD : warning : can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF]) 
2>Copying resources from program jar [G:\ApkiC-Sharp\GNote\GNote\GNote.Android\obj\Release\__library_projects__\Xamarin.GooglePlayServices.Tasks\library_project_imports\classes.jar] (TaskId:345) 
2>PROGUARD : warning : can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])

What dose it mean? Is it something to worried about? How to check if "ProGuard" works fine?

York Shen
  • 9,014
  • 1
  • 16
  • 40
Klick
  • 1,418
  • 1
  • 23
  • 45
  • 1
    Please refer to : https://stackoverflow.com/questions/39514518/xamarin-android-proguard-unsupported-class-version-number-52-0/39514706#39514706 – York Shen Oct 02 '17 at 05:51
  • I read it before. Didn't help. – Klick Oct 02 '17 at 09:12
  • 1
    Try find more complete error message by using [Diagnostic MSBuild Output](https://developer.xamarin.com/guides/android/troubleshooting/troubleshooting/#Getting_Diagnostic_Information). – York Shen Oct 02 '17 at 09:34
  • Thank you. It helped, but other thing come out. Details above. – Klick Oct 02 '17 at 10:13
  • Are you using any **3rd-party** libraries that are adding it? It seems that some `Xamarin.GooglePlayServices` package is **being included twice** in the set of code that `Proguard` is optimizing, and this isn't allowed. – York Shen Oct 02 '17 at 13:50
  • I'm using geolocation, google maps, sqlite, plugin. Is it that you ask? – Klick Oct 02 '17 at 14:05
  • Is this just a warning? If it is and you can deploy the apk(after proguard) on you phone, you could ignore the warning. – York Shen Oct 03 '17 at 00:49
  • It is warning. Yes I can deploy without any problem. Thank you for advice. – Klick Oct 03 '17 at 16:17

2 Answers2

1

I was also facing the same issue on my Windows 10 x64 and visual studio 2015. I have set the JDK path to JDK 1.8 under android settings in Visual studio tools ->options ->xamarin ->java development kit location. it was pointing to "C:\Program Files (x86)\Java\jdk1.7.0_55" and I made it to "C:\Program Files\Java\jdk1.8.0_31", and issue has been fixed.

Biswajit Pal
  • 91
  • 1
  • 2
  • I tried to upgrade to Android 12 (but failed and had to rollback). The upgrade process installed a new java version (targeting that v12) and got set as default for JDK. Selecting the other one I had installed previously solved the issue (from `C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot` to `C:\Program Files\Microsoft\jdk-11.0.10.9-hotspot`) – Ivan García Topete Apr 12 '22 at 19:07
  • I suggest adding the new JDK route in `VS 2022`: `C:\Program Files\Microsoft\jdk-11.0.[XX].[Y]-hotspot` to this answer. – Ivan García Topete Apr 12 '22 at 19:08
-2

Try enabling the Multi-Dex compilation option.

doxsi
  • 1,002
  • 19
  • 42