Xamarin Java.exe 退出,代码为 1(Proguard 问题)

编程入门 行业动态 更新时间:2024-10-11 09:25:17
本文介绍了Xamarin Java.exe 退出,代码为 1(Proguard 问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

又是 Xamarin 的一天!甚至无法构建我的第一个 Hello World 项目!不奇怪吧?

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

所以,全新的 Xamarin.Android 空白项目.启用ProGuard,链接到仅SDK 程序集,然后继续构建项目.而且wallah!!有一个错误!(等等,我不应该感到惊讶,对吧?毕竟是 Xamarin).这是错误:

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" 以代码 1 退出

"java.exe" exited with code 1

双击异常打开 Xamarin.Android.Common.Targets 文件并指向 ProGuard 标记,如下所示:

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

所以,我最好的猜测是这可能是与 ProGuard 相关的问题.所以,搜索谷歌并应用我到目前为止找到的所有修复:

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 :

  • 更新了 Android SDK
  • 将 Java 堆大小设置为 1G(甚至 5G)
  • 启用 Multi-Dex
  • 更新了混淆器
  • 在解决方案中创建了一个新的 proguard.cfg 文件(当然将 build action 设置为 ProGuardConfiguration 并添加了必要的自定义行.
  • 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.

但是,同样的错误指向相同的 ProGuard 标签.现在,在有人开始抨击我说我可能搞砸了 proguard 配置文件之前,这是它的链接:

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:

  • ProGuard.cfg
  • 从 Visual Studio 2017 构建输出

我读到这是 Xamarin 中非常常见的问题.所以,我想,有人可能想出了一个真正有效的解决方案!.那么,对我可能遗漏的内容有任何修复或想法吗?

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?

推荐答案

  • 确保您添加的 proguard 文件不是 Unicode 文本文件(U+FEFF 字节顺序标记 (BOM)),因为 proguard 将失败...

  • Make sure that the proguard file you added is NOT a Unicode text file (U+FEFF byte order mark (BOM)) as proguard will fail...

    启用诊断.MSBuild 的级别日志记录并获取完整的错误消息.

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

    Proguard 正在被 Google 的 R8 取代

    Proguard is being replaced by Google's R8

    如果您使用的是最新版本的 Xamarin,请参考这篇博文作为开始:

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

    • Android 的 D8 dexer 和 R8 收缩器

    可以在此处的 Xamarin.Android 存储库中找到有关各种 D8/R8 项目配置的详细信息:

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

    • 这是 D8 和 R8 集成规范Xamarin.Android.
  • 更多推荐

    Xamarin Java.exe 退出,代码为 1(Proguard 问题)

    本文发布于:2023-11-13 06:26:15,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1583693.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:代码   Java   Xamarin   Proguard   exe

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!