0

My issues started when updating Firebase packages in my xamarin.forms project. I then get this error

"The type 'PlaybackStateCompat' exists in both 'Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Xamarin.AndroidX.Media, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' DABApp.Droid"

I need both of these packages in my project for dependencies but I followed a thread and go into the properties of 'Xamarin.AndroidX.Media' in the 'References' folder of my droid project and change the alias for that reference. I change it to 'destination' in my case.

This gets rid of that error and all related errors but now I have been working through this error..

"java.exe exited with code 1"

and related with not much success. I attempted many workarounds I found around the web including changing the heap size and android option to 512M, 1G, 2G, or 4G. Enabled Multi-Dex, changed code shrinker to ProGuard, and also changing PackageReferences in the projcs file. Clean project after each attempt and have been regularly deleting bin/obj folder, and restore nuget packages when appropriate. Some of the different threads I have followed are linked below. The java.exe error comes immediately after I change the alias for 'Xamarin.AndroidX.Media' and I havn't been able to work past this error yet.

These first two links are for the two assemblies error I was getting at first

https://github.com/xamarin/AndroidX/issues/71

https://github.com/xamarin/AndroidX/issues/55#issuecomment-586492571

Links for java.exe error

https://github.com/xamarin/GooglePlayServicesComponents/issues/379

Xamarin Java.exe exited with code 1 (Proguard Issue)

and others but none of my attempts have given success yet.

Has anyone ran into something similar before?

Output is too long for post character amount but I'll post the later part of it.

2>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'DLToolkit.Forms.Controls.FlowListView 2.0.4' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 2>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'Microsoft.Bcl 1.1.10' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 2>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'Microsoft.Net.Http 2.2.29' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 2>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'SegmentedControl.FormsPlugin 1.3.4' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 2>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'TEditor 1.0.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 2>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'Xam.Plugin.Version 1.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 2> DABApp.iOS -> C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\iOS\bin\iPhoneSimulator\Debug\DABApp.iOS.exe 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\droidDabNativePlayer.cs(346,14,346,24): warning CS0114: 'DroidDabNativePlayer.DeleteFile(string)' hides inherited member 'ContextWrapper.DeleteFile(string?)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword. 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\droidDabNativePlayer.cs(462,32,462,39): warning CS0114: 'DroidDabNativePlayer.Dispose(bool)' hides inherited member 'Object.Dispose(bool)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword. 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\droidDabNativePlayer.cs(473,21,473,28): warning CS0108: 'DroidDabNativePlayer.Dispose()' hides inherited member 'Object.Dispose()'. Use the new keyword if hiding was intended. 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabAudioOutputRenderer.cs(12,3,14,4): warning CS0618: 'ViewRenderer.ViewRenderer()' is obsolete: 'This constructor is obsolete as of version 2.5. Please use ViewRenderer(Context) instead.' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabPickerRenderer.cs(23,47,23,98): warning CS0618: 'Resources.GetDrawable(int)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabPickerRenderer.cs(25,34,25,36): warning CS0168: The variable 'ex' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabEditorRenderer.cs(10,2,28,3): warning CS0618: 'EditorRenderer.EditorRenderer()' is obsolete: 'This constructor is obsolete as of version 2.5. Please use EntryRenderer(Context) instead.' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabPaddedEntryRenderer.cs(20,5,34,6): warning CS0618: 'EntryRenderer.EntryRenderer()' is obsolete: 'This constructor is obsolete as of version 2.5. Please use EntryRenderer(Context) instead.' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\NonScrollingListViewRenderer.cs(10,2,21,3): warning CS0618: 'ListViewRenderer.ListViewRenderer()' is obsolete: 'This constructor is obsolete as of version 2.5. Please use ListViewRenderer(Context) instead.' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabSwitchRenderer.cs(23,5,23,145): warning CS0618: 'Drawable.SetColorFilter(Color, PorterDuff.Mode)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabSwitchRenderer.cs(27,5,27,140): warning CS0618: 'Drawable.SetColorFilter(Color, PorterDuff.Mode)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\HtmlLabelRenderer.cs(24,22,24,49): warning CS0618: 'Html.FromHtml(string?)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabNavigationPageRenderer.cs(11,2,27,3): warning CS0618: 'NavigationPageRenderer.NavigationPageRenderer()' is obsolete: 'This constructor is obsolete as of version 2.5. Please use NavigationPageRenderer(Context) instead.' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\HtmlLabelRenderer.cs(37,23,37,50): warning CS0618: 'Html.FromHtml(string?)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabSwitchRenderer.cs(49,5,49,145): warning CS0618: 'Drawable.SetColorFilter(Color, PorterDuff.Mode)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabSwitchRenderer.cs(53,5,53,140): warning CS0618: 'Drawable.SetColorFilter(Color, PorterDuff.Mode)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabSwitchRenderer.cs(9,2,62,3): warning CS0618: 'SwitchRenderer.SwitchRenderer()' is obsolete: 'This constructor is obsolete as of version 2.5. Please use SwitchRenderer(Context) instead.' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\droidDabNativePlayer.cs(554,37,554,39): warning CS0168: The variable 'ex' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\droidDabNativePlayer.cs(56,37,56,118): warning CS0618: 'AudioManager.RequestAudioFocus(AudioManager.IOnAudioFocusChangeListener?, Stream, AudioFocus)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabAndroidAchievementsProgressBarRenderer.cs(10,5,30,6): warning CS0618: 'ProgressBarRenderer.ProgressBarRenderer()' is obsolete: 'This constructor is obsolete as of version 2.5. Please use ProgressBarRenderer(Context) instead.' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\AnalyticsService.cs(60,30,60,32): warning CS0168: The variable 'ex' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\CallReceiver.cs(54,30,54,32): warning CS0168: The variable 'ex' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DabApi\FileManagement.cs(55,30,55,31): warning CS0168: The variable 'e' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DabApi\FileManagement.cs(75,30,75,31): warning CS0168: The variable 'e' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabSwitchCellRenderer.cs(44,5,44,139): warning CS0618: 'Drawable.SetColorFilter(Color, PorterDuff.Mode)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\CustomRenderers\DabSwitchCellRenderer.cs(48,5,48,134): warning CS0618: 'Drawable.SetColorFilter(Color, PorterDuff.Mode)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DabSockets\droidWebSocket.cs(41,30,41,32): warning CS0168: The variable 'ex' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DabSockets\droidDabSocket.cs(63,30,63,32): warning CS0168: The variable 'ex' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DabApi\FileManagement.cs(110,34,110,36): warning CS0168: The variable 'e2' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DabApi\FileManagement.cs(104,30,104,31): warning CS0168: The variable 'e' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\MainActivity.cs(77,13,77,63): warning CS0618: 'AudioManager.RegisterMediaButtonEventReceiver(ComponentName?)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DabSockets\droidWebSocket.cs(55,28,55,37): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DabData\SQLite_Droid.cs(80,58,80,60): warning CS0168: The variable 'ex' is declared but never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\droidDabNativePlayer.cs(309,17,309,70): warning CS0618: 'MediaPlayer.SetAudioStreamType(Stream)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\droidDabNativePlayer.cs(505,17,505,52): warning CS0618: 'PlaybackStateCompat.Builder.SetErrorMessage(string)' is obsolete: 'deprecated' 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\MainActivity.cs(312,21,312,41): warning CS0169: The field 'AndroidBug5497WorkaroundForXamarinAndroid.usableHeightPrevious' is never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DabApi\FileManagement.cs(18,49,18,65): warning CS0067: The event 'FileManagement.EpisodeCompleted' is never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\droidDabNativePlayer.cs(598,26,598,33): warning CS0649: Field 'PreviousActivity.Episode' is never assigned to, and will always have its default value null 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\droidDabNativePlayer.cs(566,26,566,33): warning CS0649: Field 'SkipActivity.Episode' is never assigned to, and will always have its default value null 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\CallReceiver.cs(20,17,20,24): warning CS0169: The field 'CallReceiver.context' is never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\droidDabNativePlayer.cs(519,26,519,33): warning CS0649: Field 'PlayPauseActivity.Episode' is never assigned to, and will always have its default value null 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\DependencyServices\CallReceiver.cs(19,26,19,36): warning CS0169: The field 'CallReceiver.telManager' is never used 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'Acr.DeviceInfo 4.0.3' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'DLToolkit.Forms.Controls.FlowListView 2.0.4' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'Microsoft.Bcl 1.1.10' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'Microsoft.Net.Http 2.2.29' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'SegmentedControl.FormsPlugin 1.3.4' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'TEditor 1.0.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 3>C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\DABApp\DABApp.csproj : warning NU1701: Package 'Xam.Plugin.Version 1.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.1'. This package may not be fully compatible with your project. 3> DABApp.Droid -> C:\Users\carroconnor\Documents\GitHub\DABApp\DABApp\Droid\bin\Debug\DABApp.Droid.dll 3>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(240,5): warning XA0122: Assembly 'Xamarin.Android.Support.Annotations' is using a deprecated attribute '[assembly: Java.Interop.DoNotPackageAttribute]'. Use a newer version of this NuGet package or notify the library author. 3>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.D8.targets(51,5): error MSB6006: "java.exe" exited with code 1. ========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

3
  • for your first error message, please try to update Xamarin.Android.Support.V7.AppCompat and Xamarin.Android.Support.V4 to the latest. Commented Feb 25, 2021 at 5:37
  • Checked that, they are. They are both at 28.0.0.3 in my droid project. Only way I have been able to get through the first error so far is changing an extern alias. Commented Feb 25, 2021 at 15:07
  • You can try to change it back, and see whether there is any problem. Commented Feb 26, 2021 at 7:16

1 Answer 1

1

I recently encountered similar issue while raising the target framework to Android 10. Maybe that information can be helpful to others.

In debug mode everything works but in release I got this:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.D8.targets(51,5):error MSB6006:java.exe exited with code 1.

As you guys mentioned doubled references my issue was connected with Multidex libraries:

Xamarin.AndroidX.MultiDex

XamarinLibrary.Xamarin.Android.Support.Multidex.

I deleted the latter and purged .cs files from Android.Support references - for example:

AlertDialog had to be changed to AndroidX.AppCompat.App.AlertDialog.

It compiled but app actually crashes with:

E/AndroidRuntime(2854): java.lang.RuntimeException: Unable to instantiate application androidx.multidex.MultiDexApplication: java.lang.ClassNotFoundException: Didn't find class androidx.multidex.MultiDexApplication" on path: DexPathList[...]

Issue after issue... will be trying to fix this.

#UPDATE1: I added proguard-config.cfg file in UTF-8 encoding: -keep class androidx.multidex.MultiDexApplication { *; } -dontwarn androidx.multidex.MultiDexApplication** -keep class com.google.android.gms.** { *; } -dontwarn com.google.android.gms.** and changed the manifest file with android:name="[...]MultiDexApplication"

and then in release mode I got different errors, regarding missing classes: com.google.firebase.provider

I installed Xamarin.Firebase.Common and .Messaging and GooglePlayServices.Base after that the reference Xamarin.Javax.Inject was also needed. I installed this and then again error - missing class androidx.work. I installed this library and added new lines to proguard-config.cfg:

-keep class com.google.firebase.** { *; } -dontwarn com.google.firebase.** -keep class androidx.work.** { *; } -dontwarn androidx.work.**

Then it released without errors.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.