2

I am facing the issue (Xamarin.Android.Common.targets(2550,3): error MSB6006: "java.exe" exited with code 1.) in release mode. I tried different solutions following these links below but still issue persists.

  1. Debug Mode is Ok, I can use the app on my device.
  2. Release Mode with "Enable Proguard" Checked and without Linker is Ok
  3. Release Mode with "Enable Proguard" Checked and with Linker on "Sdk Assemblies Only" is not Ok

In my Diagnostic build I have a lot of lines like those one:


    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)

I also have this:


    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):

and this:


    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 ==========

After 2 days searching on Google, testing, cleaning and rebuilding my solution I'm still stuck. These 16 classes are not mine and I don't know how to use -dontwarn and -keep for them in proguard.cfg. For confidentiality reasons I can't post the project, but I was able to create a apk and distribute it with app center with a little test app.

My configuration


    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

Can anyone help me please?

links used

https://forums.xamarin.com/discussion/149370/failed-to-read-formsviewgroup-dll-with-debugging-symbols

[https://stackoverflow.com/questions/52494167/apk-file-not-working-with-enabled-proguard-in-xamarin-forms-android][2]

[https://stackoverflow.com/questions/39514518/xamarin-android-proguard-unsupported-class-version-number-52-0/39514706#39514706][3]

[https://forums.xamarin.com/discussion/9305/java-exe-exited-with-code-1-xamarin-android-common-targets][4]

[https://learn.microsoft.com/fr-fr/xamarin/android/deploy-test/release-prep/proguard?tabs=windows#File_Issues][5]

[https://stackoverflow.com/questions/52494167/apk-file-not-working-with-enabled-proguard-in-xamarin-forms-android][6]

[https://stackoverflow.com/questions/43393942/proguard-java-exe-exited-with-code-1-after-adding-modernhttpclient][7]

[https://stackoverflow.com/questions/43760424/xamarin-proguard-stackoverflowerror?noredirect=1&lq=1][8]

[https://stackoverflow.com/questions/38743557/xamarin-proguard-parseexception-unknown-option-in-line-1-of-file-properties/38745003#38745003][9]

[https://forums.xamarin.com/discussion/159080/how-to-resolve-errors-in-resource-designer-cs-when-building-for-android][10]

I finally found that it's firebase which creates this issue with a new project. To reproduce:

    -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

No need to add google-services.json or to parametrize AndroidManifest.xml As soon as I added the firebase class, release mode with proguard fail. There is a zip file at https://github.com/jdev6630/MyTestApp with the solution, proguard and build.log. I hope it can help someone point me to the solution.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Jose
  • 21
  • 4
  • ,According to your error message, I find one thread that discussing the same issue, you can take a look:https://github.com/xamarin/xamarin-android/issues/1369, then about ProGuard work with Xamarin.Android, you can take a look this blog:https://www.jon-douglas.com/2016/11/22/xamarin-android-proguard/ – Cherry Bu - MSFT Dec 10 '19 at 01:51
  • @CherryBu-MSFT Thank you for reply. I followed your links but the first link didn't help me and i already tried the proguard configurations of the second. I think that the 16 classes are from the Resource.Designer.cs file but i don't know what to do and i still stuck. – Jose Dec 10 '19 at 09:43
  • ,Have you solved you issue now, any update? – Cherry Bu - MSFT Dec 25 '19 at 07:25
  • No solution yet. I migrated to VS2019 and after several tries with different configurations i use for the moment VS2019 with d8/r8 without proguard.cfg. I have one warning: "R8 : warning: The rule `-keep public class * extends androidx.versionedparcelable.VersionedParcelable {". and 15 warnings: "R8 : warning : Resource 'META-INF/MANIFEST.MF' already exists." but I can create the archive. This allows me to move forward while waiting for a more consistent solution. – Jose Dec 26 '19 at 10:28

0 Answers0