问题
I've got a xamarin.form PCL.
App build find in DEBUG and working. I wanted to enable "ProGuard" feature.
but got the following error:
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2053,3): error MSB6006: "java.exe" exited with code 1.
What I've done:
- Set Max Heap Size: 1G to 5G.
- Enabled/Disabled Multi-Dex
- Switch between: SDK Assemblies only / SDK and user Assemblies
- Updated to the latest ProGuard and kept the latest configuration from the old ProGuard.
- Updated SDK Manager.
- jdk1.8.0_111
- Set Xamarin Diagnostics output vervosity: Diagnostic.
Unable to find any other error.
Android Project contain -proguard.cfg
# General Android
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
I checked line 2053 in Xamarin.android.Common.targets:
<Proguard
Condition="'$(AndroidEnableProguard)' == 'True' and '$(_ProguardProjectConfiguration)' != ''"
ProguardJarPath="$(ProguardJarPath)"
AndroidSdkDirectory="$(_AndroidSdkDirectory)"
JavaToolPath="$(JavaToolPath)"
ProguardToolPath="$(ProguardToolPath)"
ToolExe="$(ProguardToolExe)"
UseProguard="$(UseProguard)"
JavaPlatformJarPath="$(JavaPlatformJarPath)"
ClassesOutputDirectory="$(IntermediateOutputPath)android\bin\classes"
AcwMapFile="$(_AcwMapFile)"
ProguardCommonXamarinConfiguration="$(IntermediateOutputPath)proguard\proguard_xamarin.cfg"
ProguardGeneratedReferenceConfiguration="$(_ProguardProjectConfiguration)"
ProguardGeneratedApplicationConfiguration="$(IntermediateOutputPath)proguard\proguard_project_primary.cfg"
ProguardConfigurationFiles="$(ProguardConfigFiles)"
JavaLibrariesToEmbed="@(_JavaLibrariesToCompile);@(_InstantRunJavaReference)"
ExternalJavaLibraries="@(AndroidExternalJavaLibrary)"
DoNotPackageJavaLibraries="@(_ResolvedDoNotPackageAttributes)"
ProguardJarOutput="$(IntermediateOutputPath)proguard\__proguard_output__.jar"
EnableLogging="$(ProguardEnableLogging)"
DumpOutput="$(IntermediateOutputPath)proguard\dump.txt"
PrintSeedsOutput="$(IntermediateOutputPath)proguard\seeds.txt"
PrintUsageOutput="$(IntermediateOutputPath)proguard\usage.txt"
PrintMappingOutput="$(IntermediateOutputPath)proguard\mapping.txt"
/>
Compile using latest version Min: 23 Target:Use Compile SDK Version
VS2015 NDK and SDK reference are correct since I can generate a build in DEBUG.
Verbose: Diagnostic
3>C:\TEST_TFS\XXXX.XXXXX-XXXX-XXXX\XXXXX-XXXX-XXXX-branch-no-auth\APP.XXXXX.XXXX\APP.XXXXX.XXXX.Droid\AWClient-SDK.dll : warning XA0101: @(Content) build action is not supported
3>C:\TEST_TFS\XXXX.XXXXX-XXXX-XXXX\XXXXX-XXXX-XXXX-branch-no-auth\APP.XXXXX.XXXX\APP.XXXXX.XXXX.Droid\LocalDb\DatabaseConnection_Android.cs(22,30,22,32): warning CS0168: The variable 'ex' is declared but never used
3>C:\TEST_TFS\XXXX.XXXXX-XXXX-XXXX\XXXXX-XXXX-XXXX-branch-no-auth\APP.XXXXX.XXXX\APP.XXXXX.XXXX.Droid\PCL\PlatformStyleBO.cs(19,24,19,44): warning CS0169: The field 'PlatformStyleBO._buttonHeightRequest' is never used
3> APP.XXXXX.XXXX.Droid -> C:\TEST_TFS\XXXX.XXXXX-XXXX-XXXX\XXXXX-XXXX-XXXX-branch-no-auth\APP.XXXXX.XXXX\APP.XXXXX.XXXX.Droid\bin\Release\APP.XXXXX.XXXX.Droid.dll
3>C:\TEST_TFS\SSSSS.XXXXX-XXXX-XXXX\XXXXX-XXXX-XXXX-branch-no-auth\APP.XXXXX.XXXX\APP.XXXXX.XXXX.Droid\APP.XXXXX.XXXX.Droid.csproj : warning XA0105: The $(TargetFrameworkVersion) for FormsViewGroup.dll (vv8.0) is greater than the $(TargetFrameworkVersion) for your project (v7.1). You need to increase the $(TargetFrameworkVersion) for your project.
3>C:\TEST_TFS\SSSSS.XXXXX-XXXX-XXXX\XXXXX-XXXX-XXXX-branch-no-auth\APP.XXXXX.XXXX\APP.XXXXX.XXXX.Droid\APP.XXXXX.XXXX.Droid.csproj : warning XA0105: The $(TargetFrameworkVersion) for Xamarin.Forms.Platform.Android.dll (vv8.0) is greater than the $(TargetFrameworkVersion) for your project (v7.1). You need to increase the $(TargetFrameworkVersion) for your project.
3>C:\TEST_TFS\SSSSS.XXXXX-XXXX-XXXX\XXXXX-XXXX-XXXX-branch-no-auth\APP.XXXXX.XXXX\APP.XXXXX.XXXX.Droid\APP.XXXXX.XXXX.Droid.csproj : warning XA0105: The $(TargetFrameworkVersion) for Xamarin.Forms.Platform.dll (vv8.0) is greater than the $(TargetFrameworkVersion) for your project (v7.1). You need to increase the $(TargetFrameworkVersion) for your project.
3>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2053,3): error MSB6006: "java.exe" exited with code 1.
回答1:
Proguard can be a bit of a pain. The usual symptom is something like
java exited with code 1
Steps that worked for me (I had these notes stored in my solution because it just wasn't obvious). Lifted from this site
- Download the latest version of Proguard
- Find where your Android SDK is installed (something like /android-sdk/tools/proguard”). To find the sdk go to
Tools->Options->Xamarin - Swap out the old version of Proguard, with the new one. To do this rename the current folder to something like “Proguard-pointless” and copy your new one into the tools folder.
- Be sure to rename the folder for the new version to just be “proguard”.
- Make sure that any configuration files are also copied across into the new Proguard folder. For me this was
proguard-android-optimize.txt,proguard-android.txt, andproguard-project.txt. Add a new file to the root of your Android project called
proguard.cfgNOTE : Because Xamarin is smart, it saves this new file in
UTF-8withBOM, 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.- In VS Right Click on the file and select Properties. For Build Action, select ProguardConfiguration.
- Add relevant
keepordontwarnclauses to the file without the quotes (it depends on your warnings) , for example it could be something like this...- "-dontwarn com.google.android.gms.**"
- "-keep class com.google.android.gms.**"
- Once you have done those steps, try a build once again.
- Hopefully this time it will be more successful. If it is not successful, check your build output and see what warnings and notes Proguard is giving you.
From this stage it is a matter of identifying what modifications you need to make to your custom Proguard file, once that works the build will be successful.
Update
Xamarin.Forms.Platform.Android.dll (vv8.0) is greater than the $(TargetFrameworkVersion) for your project (v7.1)
I know these are just warnings, however have tried what it says. I.e updated your target framework version for your projects ?
来源:https://stackoverflow.com/questions/48921533/x86-msbuild-xamarin-android-xamarin-android-common-targets2053-3-error-msb6