Xamarin.Android.D8.Target - "java.exe" exited with code 1 on creating proguard configuration file

Viewed 3327

I'm Creating a Xamarin.Android application. On enabling Proguard or R8 Shrinker getting -> Xamarin.Android.D8.Target - "java.exe" exited with code 1

I have already deal with same error rise with Xamarin.Android.Common.Targets which is fixed by enable MultiDex.

But Xamarin.Android.D8.Target - "java.exe" exited with code 1 is different.

1>PROGUARD : warning : there were 6319 unresolved references to classes or interfaces.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.D8.targets(49,5): error MSB6006: "java.exe" exited with code 1.

Error occure when having proguard.cfg or proguard.pro file in project directory

2 Answers

Problem rises When you create/save proguard file.

Xamarin Uses two type of UTF-8 encoding.

  1. UTF-8 (Only)
  2. UTF-8 with BOM (default by xamarin during new file creation)

Because Xamarin is smart, it saves this new file in UTF-8 with BOM, you will need to change this. Probably best to create the file in notepad, and then include it in your program. This is required because Proguard will not read the file unless it is in UTF-8 encoding.

Enabling ProGuard (or R8) may (and frequently does) break your build. You need to add ProGuard.cfg and then add some exceptions to it that cause the problem so that it works properly.

Related