Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
748 views
in Technique[技术] by (71.8m points)

c# - Xamarin Java.exe exited with code 1 (Proguard Issue)

Another day with Xamarin! Can't even build my first Hello World project! Not surprising, huh?

So, fresh new Xamarin.Android blank project. Enabled ProGuard, link to SDK Assemblies Only and went on building the project. And wallah!! There's an error!(Wait, i shouldn't be surprised, right? After all, it's Xamarin). Here's the error :

"java.exe" exited with code 1

Double-clicking the exception opens up Xamarin.Android.Common.Targets file and points to the ProGuard tag which is as follows :

<Proguard
Condition="'$(AndroidEnableProguard)' == 'True' and '$(_ProguardProjectConfiguration)' != ''"
ProguardJarPath="$(ProguardJarPath)"
AndroidSdkDirectory="$(_AndroidSdkDirectory)"
JavaToolPath="$(JavaToolPath)"
ProguardToolPath="$(ProguardToolPath)"
ToolExe="$(ProguardToolExe)"
UseProguard="$(UseProguard)"
JavaPlatformJarPath="$(JavaPlatformJarPath)"
ClassesOutputDirectory="$(IntermediateOutputPath)androidinclasses"
AcwMapFile="$(_AcwMapFile)"
ProguardCommonXamarinConfiguration="$(IntermediateOutputPath)proguardproguard_xamarin.cfg"
ProguardGeneratedReferenceConfiguration="$(_ProguardProjectConfiguration)"
ProguardGeneratedApplicationConfiguration="$(IntermediateOutputPath)proguardproguard_project_primary.cfg"
ProguardConfigurationFiles="$(ProguardConfigFiles)"
JavaLibrariesToEmbed="@(_JarsToProguard);@(_InstantRunJavaReference)"
ExternalJavaLibraries="@(AndroidExternalJavaLibrary)"
DoNotPackageJavaLibraries="@(_ResolvedDoNotPackageAttributes)"
ProguardJarOutput="$(IntermediateOutputPath)proguard\__proguard_output__.jar"
EnableLogging="$(ProguardEnableLogging)"
DumpOutput="$(IntermediateOutputPath)proguarddump.txt"
PrintSeedsOutput="$(IntermediateOutputPath)proguardseeds.txt"
PrintUsageOutput="$(IntermediateOutputPath)proguardusage.txt"
PrintMappingOutput="$(IntermediateOutputPath)proguardmapping.txt"
ProguardInputJarFilter="$(_AndroidProguardInputJarFilter)"
/>

So, my best guess was that it might be a ProGuard related issue. So, searched up google and applied all fixes i found so far :

  • Updated Android SDK
  • Set Java heap size to 1G(and even 5G)
  • Enabled Multi-Dex
  • Updated ProGuard
  • Created a new proguard.cfg file in solution(of course set build action to ProGuardConfiguration and added custom lines that are necessary.

But still, same error pointing to the same ProGuard tag. Now before anybody starts bashing me saying i could've messed up the proguard configuratiom file, here's the link to it:

I have read that this is a very common issue in Xamarin. So, i guess, somebody might have come up with a solution that really works!. So, any fixes or ideas on what i might be missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  1. Make sure that the proguard file you added is NOT a Unicode text file (U+FEFF byte order mark (BOM)) as proguard will fail...

  2. Enable diag. level logging for MSBuild and get the full error message.

  3. Proguard is being replaced by Google's R8

If you are using the latest version of Xamarin, refer to this blog post as a start:

Detailed info on the various D8/R8 project configurations can be found in the Xamarin.Android repo here:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...