我在发布模式下遇到此问题(Xamarin.Android.Common.targets(2550,3):错误MSB6006:“ java.exe”以代码1退出)。我按照下面的这些链接尝试了不同的解决方案,但问题仍然存在。
在我的诊断版本中,我有很多类似的内容:
Not remapping resource: Animation.abc_fade_in (TaskId:177) Not remapping resource: Animator.design_appbar_state_list_animator (TaskId:177) Not remapping resource: Attribute.actionBarDivider (TaskId:177) Not remapping resource: Boolean.abc_action_bar_embed_tabs (TaskId:177) Not remapping resource: Color.ListViewHighlighted (TaskId:177) Not remapping resource: Dimension.tooltip_y_offset_touch (TaskId:177) Not remapping resource: Drawable.abc_ab_share_pack_mtrl_alpha (TaskId:177) Not remapping resource: Id.ALT (TaskId:177) Not remapping resource: Integer.abc_config_activityDefaultDur (TaskId:177) . . . Not remapping resource: Styleable.ViewStubCompat_android_layout (TaskId:177)
我也有这个:
2>Target "_GetAdditionalResourcesFromAssemblies" skipped. Previously built successfully. 2>Target "_CreateAdditionalResourceCache: (TargetId:278)" in file "D:\Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets" from project "D:\Projets\GitRepos\MyApp\MyApp\MyApp.Android\MyApp.Android.csproj" (target "_CompileJava" depends on it): 2>Skipping target "_CreateAdditionalResourceCache" because it has no outputs. 2>Though the target has declared its outputs, the output specification only references empty properties and/or empty item lists. 2>Done building target "_CreateAdditionalResourceCache" in project "MyApp.Android.csproj".: (TargetId:278) 2>Target "_DetermineJavaLibrariesToCompile: (TargetId:279)" in file "D:\Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets" from project "D:\Projets\GitRepos\MyApp\MyApp\MyApp.Android\MyApp.Android.csproj" (target "_CompileJava" depends on it):
这:
2> PROGUARD : warning : class [com/companyname/MyApp/R$anim.class] unexpectedly contains class [com.companyname.myapp.R$anim] 2> PROGUARD : warning : class [com/companyname/MyApp/R$animator.class] unexpectedly contains class [com.companyname.myapp.R$animator] 2> PROGUARD : warning : class [com/companyname/MyApp/R$attr.class] unexpectedly contains class [com.companyname.myapp.R$attr] 2> PROGUARD : warning : class [com/companyname/MyApp/R$bool.class] unexpectedly contains class [com.companyname.myapp.R$bool] 2> PROGUARD : warning : class [com/companyname/MyApp/R$color.class] unexpectedly contains class [com.companyname.myapp.R$color] 2> PROGUARD : warning : class [com/companyname/MyApp/R$dimen.class] unexpectedly contains class [com.companyname.myapp.R$dimen] 2> PROGUARD : warning : class [com/companyname/MyApp/R$drawable.class] unexpectedly contains class [com.companyname.myapp.R$drawable] 2> PROGUARD : warning : class [com/companyname/MyApp/R$id.class] unexpectedly contains class [com.companyname.myapp.R$id] 2> PROGUARD : warning : class [com/companyname/MyApp/R$integer.class] unexpectedly contains class [com.companyname.myapp.R$integer] 2> PROGUARD : warning : class [com/companyname/MyApp/R$interpolator.class] unexpectedly contains class [com.companyname.myapp.R$interpolator] 2> PROGUARD : warning : class [com/companyname/MyApp/R$layout.class] unexpectedly contains class [com.companyname.myapp.R$layout] 2> PROGUARD : warning : class [com/companyname/MyApp/R$string.class] unexpectedly contains class [com.companyname.myapp.R$string] 2> PROGUARD : warning : class [com/companyname/MyApp/R$style.class] unexpectedly contains class [com.companyname.myapp.R$style] 2> PROGUARD : warning : class [com/companyname/MyApp/R$styleable.class] unexpectedly contains class [com.companyname.myapp.R$styleable] 2> PROGUARD : warning : class [com/companyname/MyApp/R$xml.class] unexpectedly contains class [com.companyname.myapp.R$xml] 2> PROGUARD : warning : class [com/companyname/MyApp/R.class] unexpectedly contains class [com.companyname.myapp.R] 2> PROGUARD : warning : there were 16 classes in incorrectly named files. 2> 2> 2>"D:\Projets\GitRepos\MyApp\MyApp\MyApp.Android\MyApp.Android.csproj" (Build;BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;DebugSymbolsProjectOutputGroup;DebugSymbolsProjectOutputGroupDependencies;DocumentationProjectOutputGroup;DocumentationProjectOutputGroupDependencies;SatelliteDllsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;SGenFilesOutputGroup;SGenFilesOutputGroupDependencies target) (1) -> 2>(_CompileToDalvikWithDx target) -> 2> D:\Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2550,3): error MSB6006: "java.exe" exited with code 1. 2> 2> 17 Warning(s) 2> 1 Error(s) 2> 2>Time Elapsed 00:01:03.51 ========== Build: 1 succeeded, 1 failed, 0 up-to-date, 3 skipped ==========
在Google上搜索,测试,清理和重建我的解决方案2天后,我仍然遇到问题。 这16个类不是我的,我不知道如何在proguard.cfg中为它们使用-dontwarn和-keep。 出于保密原因,我无法发布该项目,但是我能够创建apk并通过一个带有少量测试应用程序的应用程序中心进行分发。
我的配置
Windows 10 x64 C:\Program Files (x86)\Java\jdk1.8.0_161 VS2017 Community 15.9.17 Proguard 6.2 Xamarin Forms 4.3.0.991221 D:\Android\Sdk\build-tools\28.0.3\ netstandard2.0 Target Android Version: 9.0 Minimum Android Version: 4.4 Java max heap size - 1G proguard.cfg: -keep class com.google.android.gms.** { *; } -dontwarn com.google.android.gms.** -keep class android.support.v7.widget.** { *; } -dontwarn android.support.v7.widget.** -keep class android.support.v4.widget.Space { *; } -dontwarn android.support.v4.widget.Space
有人可以帮我吗?
使用的链接
[Apk file not working with enabled proguard in xamarin forms Android
[Xamarin.Android Proguard - Unsupported class version number 52.0
[Apk file not working with enabled proguard in xamarin forms Android
[ProGuard: "java.exe" exited with code 1 after adding ModernHTTPClient
[Xamarin ProGuard StackOverflowError
[Xamarin proguard.ParseException: Unknown option '' in line 1 of file 'Properties/proguard.cfg'
我终于发现,这是使用新项目创建此问题的基础。复制:
-New blank xamarin forms project -Targeted Android 9 -Update solution to Xamarin forms 4.3.0 -Update the 6 other plugins to latest stable version -Add Xamarin.Firebase.Messaging latest -Add a class derived from FirebaseMessagingService
无需添加google-services.json或参数化AndroidManifest.xml 一旦添加了Firebase类,带有proguard的发布模式就会失败。 https://github.com/jdev6630/MyTestApp有一个zip文件,其中包含解决方案proguard和build.log。 我希望它可以帮助某人指出解决方案。