java - Xamarin Forms java.exe"退出代码 1 (ProGuard)

标签 java android xamarin xamarin.android xamarin.forms

我的 Xamarin Forms 项目与 ProGuard 有问题,出现以下错误:java.exe"exited with code 1

和多个警告,例如:okio.Okio: can't find referenced class java.nio.file.Path

我尝试了很多解决方案,例如:

  • 下载最新版本的 Proguard 并将其替换到特定文件夹中。
  • 将我的 Java 最大堆大小设置为 1G
  • 创建我自己的 proguard.cfg 并将构建操作设置为 ProguardConfiguration

这些解决方案都不起作用,我也尝试了多次清理和构建。 但是有一点很奇怪,当我的Linking 设置为“None”而不是“SDK Assemblies Only”时,我可以构建我的项目。当启用 ProGuard 并且我的 Linking 设置为 SDK Assemblies Only 时它不起作用,这是否正常?

这是我的输出构建示例:

Note: there were 7 references to unknown classes. (TaskId:223) 1> You should check your configuration for typos. (TaskId:223) 1> (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass) (TaskId:223) 1> Note: there were 2 classes trying to access generic signatures using reflection. (TaskId:223) 1> You should consider keeping the signature attributes (TaskId:223) 1> (using '-keepattributes Signature'). (TaskId:223) 1> (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes) (TaskId:223) 1> Note: there were 17 unkept descriptor classes in kept class members. (TaskId:223) 1> You should consider explicitly keeping the mentioned classes (TaskId:223) 1> (using '-keep'). (TaskId:223) 1> (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass) (TaskId:223) 1> Note: there were 10 unresolved dynamic references to classes or interfaces. (TaskId:223) 1> You should check if you need to specify additional program jars. (TaskId:223) 1> (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass) (TaskId:223) 1> Note: there were 4 accesses to class members by means of introspection. (TaskId:223) 1> You should consider explicitly keeping the mentioned class members (TaskId:223) 1> (using '-keep' or '-keepclassmembers'). (TaskId:223) 1> (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember) (TaskId:223) 1>PROGUARD : warning : there were 14 unresolved references to classes or interfaces. 1> You may need to add missing library jars or update their versions. (TaskId:223) 1> If your code works fine without the missing classes, you can suppress (TaskId:223) 1> the warnings with '-dontwarn' options. (TaskId:223) 1> (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass) (TaskId:223) 1> java.io.IOException: Please correct the above warnings first. (TaskId:223)

这些是我的警告:

Severity Code Description Project File Line Suppression State Warning there were 14 unresolved references to classes or interfaces. Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning CS0169 The field 'MainActivity.ContextCompat' is never used Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\MainActivity.cs 24 Active Warning CS0067 The event 'Vwm_Listing.PopulateList' is never used Test.App.Forms C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Forms\ViewModels\Vwm_Listing.cs 7 Active Warning okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.Path Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.Path Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.Path Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.Path Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.OpenOption Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.OpenOption Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.OpenOption Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.OpenOption Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.Files Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.Files Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.Okio: can't find referenced class java.nio.file.Files Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Test.App.Droid C:\User\Projects\Test\Test.Mob.App\Test.App\Test.App.Droid\PROGUARD
Warning Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. Test.App.Droid C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets 1820

我该怎么办?我不知道如何解决这个问题..

最佳答案

发布您的警告错误。还在您的 progaurd.pro 文件中添加一些行。

-keep class org.apache.http.** { *; }
-dontnote org.apache.http.**
-dontwarn org.apache.http.**
-dontwarn android.net.*

关于java - Xamarin Forms java.exe"退出代码 1 (ProGuard),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44304299/

相关文章:

java - 如何自定义 jzy3d 图表

java - Android:我无法弄清楚 SimpleDateFormat

java - Android 应用程序的多个实例打开 - 仅在 Touchwiz 上

c# - Xamarin新建项目错误

c# - 在 Xamarin Forms C# 中发送 HTTP Post 请求

java - Java Arraylist 中的选择排序

java - 如何使用 Android 发现任何 NFC 技术(不仅是标签)?

java - 等待监听器完成任务并获取另一个函数的结果 [Android]

android - 如何共享元素从 fragment 过渡到 Activity

c# - Xamarin.Forms MVVM 从 DISplayAlert 获得响应