(x86)\ MSBuild \ Xamarin \ Android \ Xamarin.Android.Common.targets(2053,3):错误MSB6006:“java.exe”已退出,代码为1

问题描述 投票:1回答:1

我有一个xamarin.form PCL。

应用程序构建在DEBUG中查找并正常工作。我想启用“ProGuard”功能。

但得到以下错误:

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2053,3): error MSB6006: "java.exe" exited with code 1.

我做了什么:

  • 设置最大堆大小:1G到5G。
  • 启用/禁用Multi-Dex
  • 切换:仅SDK程序集/ SDK和用户程序集
  • 已更新至最新的ProGuard,并保留了旧ProGuard的最新配置。
  • 更新了SDK Manager。 jdk1.8.0_111
  • 设置Xamarin诊断输出的真实性:诊断。

无法找到任何其他错误。

Android项目包含-proguard.cfg

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

我在Xamarin.android.Common.targets中检查了2053行:

 <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"
     />

使用最新版本进行编译最小值:23目标:使用编译SDK版本

VS2015 NDK和SDK引用是正确的,因为我可以在DEBUG中生成构建。

详细:诊断

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.
c# android xamarin proguard
1个回答
1
投票

Proguard可能有点痛苦。通常的症状是这样的

java退出代码1

对我有用的步骤(我将这些笔记存储在我的解决方案中,因为它并不明显)。从this site解除

  1. 下载最新版的Proguard
  2. 找到Android SDK的安装位置(类似于/ android-sdk / tools / proguard)。要找到sdk,请访问Tools->Options->Xamarin
  3. 用新的Proguard换掉旧版本的Proguard。为此,将当前文件夹重命名为“Proguard-pointless”,并将新文件夹复制到tools文件夹中。
  4. 请务必将新版本的文件夹重命名为“proguard”。
  5. 确保所有配置文件也被复制到新的Proguard文件夹中。对我来说,这是proguard-android-optimize.txtproguard-android.txtproguard-project.txt
  6. 将新文件添加到名为proguard.cfg的Android项目的根目录中 注意:因为Xamarin很聪明,它使用UTF-8将这个新文件保存在BOM中,你需要更改它。可能最好在记事本中创建文件,然后将其包含在您的程序中。这是必需的,因为Proguard不会读取文件,除非它是UTF-8编码。
  7. 在VS中右键单击该文件,然后选择“属性”。对于Build Action,选择ProguardConfiguration。
  8. 将相关的keepdontwarn子句添加到没有引号的文件中(这取决于你的警告),例如它可能是这样的...... “-dontwarn com.google.android.gms。**” “-keep class com.google.android.gms。**”
  9. 完成这些步骤后,再次尝试构建。
  10. 希望这次会更成功。如果不成功,请检查您的构建输出,看看Proguard给您的警告和注释。

从这个阶段开始,您需要确定需要对自定义Proguard文件进行哪些修改,一旦工作,构建就会成功。

更新

Xamarin.Forms.Platform.Android.dll(vv8.0)大于项目的$(TargetFrameworkVersion)(v7.1)

我知道这些只是警告,但是已经尝试了它所说的。我更新了你的项目的目标框架版本?

© www.soinside.com 2019 - 2024. All rights reserved.