Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSBuild\Xamarin\Android\Xamarin.Android.D8.targets(79,5): error MSB6006: "java.exe" exited with code 1. #379

Open
Mataboge opened this issue Aug 26, 2020 · 50 comments
Assignees
Labels
investigating We are currently looking into this needs-info More information is requested by engineering

Comments

@Mataboge
Copy link

Mataboge commented Aug 26, 2020

Xamarin.Android Version (eg: 6.0):

Android 10

Operating System & Version (eg: Mac OSX 10.11):

Windows 10, visual studio 19 16.7.2

Google Play Services Version

Xamarin.Firebase.Firestore v121.4.3-preview02
also tried (71.1705.4)

Describe your Issue

Immediately after adding this package, I get the build error MSB6006: "java.exe" exited with code 1. Which points to the Xamarin.Android.D8.targets(79,5) file and line 79 is the beginning D8 compiler code.

Edit:

after some investigation, i found that the issue is caused by having these packages at the same time:
<PackageReference Include="Xamarin.GooglePlayServices.Ads"> <Version>119.1.0-preview02</Version> </PackageReference>
and

<PackageReference Include="Xamarin.Firebase.Firestore"> <Version>121.4.3-preview02</Version> </PackageReference>
These two packages seem to be referencing different versions on Xamarin.GoogleplayServices.Base and that causes this error. I am forced to use that Xamarin.GooglePlayServices.Ads version because other versions cause this error ( #369 ). Any other version of Xamarin.Firebase.Firestore isn't working well

Relevant information

Add relevant project settings from *.csproj file:

Packages used:

    <PackageReference Include="Acr.UserDialogs">
      <Version>7.1.0.446</Version>
    </PackageReference>
    <PackageReference Include="IntelliAbb.Xamarin.Controls">
      <Version>1.0.148</Version>
    </PackageReference>
    <PackageReference Include="PCLStorage">
      <Version>1.0.2</Version>
    </PackageReference>
    <PackageReference Include="Plugin.InAppBilling">
      <Version>2.0.0</Version>
    </PackageReference>
    <PackageReference Include="Plugin.LocalNotification">
      <Version>5.0.6</Version>
    </PackageReference>
    <PackageReference Include="Plugin.Permissions">
      <Version>6.0.1</Version>
    </PackageReference>
    <PackageReference Include="sqlite-net-pcl">
      <Version>1.7.335</Version>
    </PackageReference>
    <PackageReference Include="Xam.Plugin.LatestVersion">
      <Version>1.1.2</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.Fragment">
      <Version>1.2.4.2</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.Fragment">
      <Version>1.2.4.2</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.Migration">
      <Version>1.0.6.2</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Essentials">
      <Version>1.5.3.2</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Firestore">
      <Version>121.4.3-preview02</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Forms">
      <Version>4.8.0.1269</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.GooglePlayServices.Ads">
      <Version>119.1.0-preview02</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.0-preview03" />

Build settings (tools)

    <AndroidDexTool>d8</AndroidDexTool>

Steps to Reproduce (with link to sample solution if possible):

install these two packages in the project then build & deploy.
<PackageReference Include="Xamarin.GooglePlayServices.Ads"> <Version>119.1.0-preview02</Version> </PackageReference>
and
<PackageReference Include="Xamarin.Firebase.Firestore"> <Version>121.4.3-preview02</Version> </PackageReference>

Include any relevant Exception Stack traces, build logs, adb logs:

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

@Mataboge
Copy link
Author

My Analysis of the problems seems to have been wrong at the beginning, the issue seems to have been caused by the Firebase.Firestore Plugin and the 'Plugin.LocalNotifications', removal of any of these two plug-ins the error goes away.

@moljac moljac self-assigned this Sep 27, 2020
@moljac moljac added investigating We are currently looking into this needs-info More information is requested by engineering labels Sep 27, 2020
@moljac
Copy link
Member

moljac commented Sep 27, 2020

Can you attach diagnosic logs, please?

@Mataboge
Copy link
Author

build.log

@moljac
Copy link
Member

moljac commented Sep 28, 2020

Can I see your project file, please? OR at least ProjectReferences?

@Mataboge
Copy link
Author

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{A75388B3-D512-4365-85E4-AB8EAC5C9E73}</ProjectGuid>
    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <TemplateGuid>{6968b3a4-1835-46a3-ac5c-1ae33b475983}</TemplateGuid>
    <OutputType>Library</OutputType>
    <RootNamespace>SampleProject.Droid</RootNamespace>
    <AssemblyName>SampleProject.Android</AssemblyName>
    <Deterministic>True</Deterministic>
    <AndroidApplication>True</AndroidApplication>
    <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
    <AndroidResgenClass>Resource</AndroidResgenClass>
    <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
    <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
    <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
    <AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
    <TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
    <AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
    <AndroidUseAapt2>true</AndroidUseAapt2>
    <AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>portable</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug</OutputPath>
    <DefineConstants>DEBUG;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidLinkMode>None</AndroidLinkMode>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>portable</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidManagedSymbols>true</AndroidManagedSymbols>
    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Mono.Android" />
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Numerics" />
    <Reference Include="System.Numerics.Vectors" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Plugin.LocalNotification">
      <Version>5.0.7</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Ads.Lite">
      <Version>71.1601.4</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Firestore">
      <Version>71.1705.4</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Forms" Version="4.8.0.1451" />
    <PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="MainActivity.cs" />
    <Compile Include="Resources\Resource.designer.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Resources\AboutResources.txt" />
    <None Include="Assets\AboutAssets.txt" />
    <None Include="Properties\AndroidManifest.xml" />
  </ItemGroup>
  <ItemGroup>
    <AndroidResource Include="Resources\layout\Tabbar.xml" />
    <AndroidResource Include="Resources\layout\Toolbar.xml" />
    <AndroidResource Include="Resources\values\styles.xml" />
    <AndroidResource Include="Resources\values\colors.xml" />
    <AndroidResource Include="Resources\mipmap-anydpi-v26\icon.xml" />
    <AndroidResource Include="Resources\mipmap-anydpi-v26\icon_round.xml" />
    <AndroidResource Include="Resources\mipmap-hdpi\icon.png" />
    <AndroidResource Include="Resources\mipmap-hdpi\launcher_foreground.png" />
    <AndroidResource Include="Resources\mipmap-mdpi\icon.png" />
    <AndroidResource Include="Resources\mipmap-mdpi\launcher_foreground.png" />
    <AndroidResource Include="Resources\mipmap-xhdpi\icon.png" />
    <AndroidResource Include="Resources\mipmap-xhdpi\launcher_foreground.png" />
    <AndroidResource Include="Resources\mipmap-xxhdpi\icon.png" />
    <AndroidResource Include="Resources\mipmap-xxhdpi\launcher_foreground.png" />
    <AndroidResource Include="Resources\mipmap-xxxhdpi\icon.png" />
    <AndroidResource Include="Resources\mipmap-xxxhdpi\launcher_foreground.png" />
    <AndroidResource Include="Resources\drawable\xamarin_logo.png" />
    <AndroidResource Include="Resources\drawable\tab_about.png" />
    <AndroidResource Include="Resources\drawable\tab_feed.png" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\SampleProject\SampleProject.csproj">
      <Project>{4256123D-5731-43DC-9F48-B820EE9E35C6}</Project>
      <Name>SampleProject</Name>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>

@REXiator
Copy link

REXiator commented Oct 14, 2020

I have the same issue, found by installing the same components (Xamarin.Firebase.Firestore and Plugin.LocalNotification). I did some further tests and can conclude that there's some incompatibility between Xamarin.Firebase.Firestore (or a dependency) and Xamarin.AndroidX.Work.Runtime. There seems to be no version combination of the two that works. Is there any new info available about this?

EDIT: It is easily reproducible by installing VS Enterprise 2019 16.7.4, creating a new Xamarin.Forms project, installing e.g. Xamarin.Firebase.Firestore 120.2.0 and Xamarin.AndroidX.Work.Runtime 2.3.4.6 into the Android project, and trying to build the project/solution.

@moljac
Copy link
Member

moljac commented Oct 14, 2020

Could you provide binlogs please. Those are smaller and easier to investigate. Thanks

@REXiator
Copy link

Sure. Here is a binlog of the sample scenario I described (plus targeted Android to API level 30 and removed iOS project so as not to flood the logs with Mac connection attempts): msbuild.zip

@hvaughan3
Copy link

hvaughan3 commented Oct 25, 2020

I get the same error but using different libraries. When I tried upgrading all Firebase libraries i get the issue.

When I looked through the msbuild command output I saw this:

Error in obj\Debug\100\lp\140\jl\classes.jar:com/google/android/gms/internal/measurement/zzu.class:
  Type com.google.android.gms.internal.measurement.zzu is defined multiple times: obj\Debug\100\lp\140\jl\classes.jar:c
  om/google/android/gms/internal/measurement/zzu.class, obj\Debug\100\lp\160\jl\classes.jar:com/google/android/gms/inte
  rnal/measurement/zzu.class
  Compilation failed

Also switching from d8 to dx compiler produces this error after waiting over 30 minutes for the build to complete:

CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/MSFTSIG.SF] (Duplicate jar entry [META-INF/MSFTSIG.SF])
CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/MSFTSIG.RSA] (Duplicate jar entry [META-INF/MSFTSIG.RSA])
CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [firebase-analytics-impl.properties] (Duplicate jar entry [firebase-analytics-impl.properties])
CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [firebase-measurement-connector-impl.properties] (Duplicate jar entry [firebase-measurement-connector-impl.properties])
  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/AppMeasurement;
  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/AppMeasurementContentProvider;
  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/AppMeasurementInstallReferrerReceiver;
  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/measurement/zzsi;
  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/AppMeasurement;
  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/AppMeasurementContentProvider;
  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/AppMeasurementInstallReferrerReceiver;
  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/measurement/zzu;
  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/measurement/zzv;
  
  UNEXPECTED TOP-LEVEL EXCEPTION:
  java.lang.RuntimeException: Translation has been interrupted
  	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:614)
  	at com.android.dx.command.dexer.Main.runMultiDex(Main.java:365)
  	at com.android.dx.command.dexer.Main.runDx(Main.java:286)
  	at com.android.dx.command.dexer.Main.main(Main.java:244)
  	at com.android.dx.command.Main.main(Main.java:95)
  Caused by: java.lang.InterruptedException: Too many errors
  	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:606)
  	... 4 more
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\Android\Xamarin.Android.DX.targets(83,5): error : java.lang.IllegalArgumentException: already added :  Lcom/google/android/gms/measurement/AppMeasurement;

@brendanzagaeski
Copy link
Member

brendanzagaeski commented Oct 26, 2020

@moljac, @jpobst, since I was looking at another conflicting Java type issue today (dotnet/android#5237), I was curious if this was related and took a quick look at this too. This case looks like something a little different.

Example error message for reference:

Type com.google.common.util.concurrent.ListenableFuture is defined multiple times: C:\Users\user\.nu
get\packages\xamarin.google.guava.listenablefuture\1.0.0.2\buildTransitive\monoandroid50\guava-liste
nablefuture.jar:com/google/common/util/concurrent/ListenableFuture.class, obj\Release\100\lp\47\jl\_
_reference__guava.jar:com/google/common/util/concurrent/ListenableFuture.class

Investigation notes:

I noticed that according to https://mvnrepository.com/artifact/com.google.firebase/firebase-firestore/21.4.3, Xamarin.Firebase.Firestore version 121.4.3 might not need the dependency that it currently has on Xamarin.Google.Guava.

I can stop the build error with the following steps:

  1. Add the following PackageReference for Xamarin.Google.Guava with ExcludeAssets="all":

    <PackageReference Include="Xamarin.Google.Guava" ExcludeAssets="all">
      <Version>27.1.0</Version>
    </PackageReference>
  2. Delete the obj\project.assets.json file and close and reopen the solution to force the NuGet packages to re-restore.

That is, if I intentionally exclude the assets from the Xamarin.Google.Guava package so the __reference__guava.jar isn't extracted or used at all during the build, the build is successful. Admittedly, I haven't tested the behavior of Xamarin.Firebase.Firestore at run time on device with this work around.

But if this sounds right, then maybe the Xamarin.Google.Guava dependency can be removed from the latest versions of the Xamarin.Firebase.Firestore NuGet package?

@felipechavez
Copy link

Hello everyone, I have a similar problem and tried everything. Here's my detailed log:

5>Usando la tarea "D8" del ensamblado "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Build.Tasks.dll". 5>Tarea "D8" 5> processing ClassesZip, JavaLibrariesToEmbed... 5> C:\Program Files\Java\jdk1.8.0_271\bin\java.exe -Xmx1G -classpath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\r8.jar" com.android.tools.r8.D8 --debug --min-api 22 --output obj\Debug\110\android\bin\ --lib "C:\Program Files (x86)\Android\android-sdk\platforms\android-30\android.jar" --lib "C:\Program Files (x86)\Android\android-sdk\platforms\android-30\optional\org.apache.http.legacy.jar" obj\Debug\110\android\bin\classes.zip "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v11.0\mono.android.jar" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\\java_runtime.jar" C:\Users\chave\.nuget\packages\xamarin.androidx.annotation\1.1.0.6\buildTransitive\monoandroid90\..\..\jar\androidx.annotation.annotation.jar C:\Users\chave\.nuget\packages\xamarin.androidx.collection\1.1.0.5\buildTransitive\monoandroid90\..\..\jar\androidx.collection.collection.jar C:\Users\chave\.nuget\packages\xamarin.androidx.lifecycle.common\2.2.0.3\buildTransitive\monoandroid90\..\..\jar\androidx.lifecycle.lifecycle-common.jar C:\Users\chave\.nuget\packages\xamarin.androidx.arch.core.common\2.1.0.6\buildTransitive\monoandroid90\..\..\jar\androidx.arch.core.core-common.jar C:\Users\chave\.nuget\packages\xamarin.androidx.room.common\2.2.5.5\buildTransitive\monoandroid90\..\..\jar\androidx.room.room-common.jar C:\Users\chave\.nuget\packages\xamarin.androidx.paging.common\2.1.2.5\buildTransitive\monoandroid90\..\..\jar\androidx.paging.paging-common.jar obj\Debug\110\androidx\jl\56b8ca90-8e8e-4903-a49f-eaea4ea0a53c.jar obj\Debug\110\lp\100\jl\bin\classes.jar obj\Debug\110\lp\101\jl\bin\classes.jar obj\Debug\110\lp\107\jl\bin\classes.jar obj\Debug\110\lp\108\jl\bin\classes.jar obj\Debug\110\lp\109\jl\bin\classes.jar obj\Debug\110\lp\111\jl\auto-value-annotations.jar obj\Debug\110\lp\112\jl\dagger.jar obj\Debug\110\lp\114\jl\bin\classes.jar obj\Debug\110\lp\115\jl\bin\classes.jar obj\Debug\110\lp\116\jl\bin\classes.jar obj\Debug\110\lp\117\jl\bin\classes.jar obj\Debug\110\lp\118\jl\bin\classes.jar obj\Debug\110\lp\119\jl\bin\classes.jar obj\Debug\110\lp\120\jl\bin\classes.jar obj\Debug\110\lp\121\jl\bin\classes.jar obj\Debug\110\lp\122\jl\bin\classes.jar obj\Debug\110\lp\123\jl\bin\classes.jar obj\Debug\110\lp\124\jl\bin\classes.jar obj\Debug\110\lp\125\jl\bin\classes.jar obj\Debug\110\lp\126\jl\bin\classes.jar obj\Debug\110\lp\127\jl\bin\classes.jar obj\Debug\110\lp\128\jl\bin\classes.jar obj\Debug\110\lp\129\jl\bin\classes.jar obj\Debug\110\lp\13\jl\formsviewgroup.jar obj\Debug\110\lp\130\jl\bin\classes.jar obj\Debug\110\lp\131\jl\bin\classes.jar obj\Debug\110\lp\132\jl\bin\classes.jar obj\Debug\110\lp\133\jl\bin\classes.jar obj\Debug\110\lp\134\jl\bin\classes.jar obj\Debug\110\lp\135\jl\javax-inject.jar obj\Debug\110\lp\136\jl\protobuf-lite-3.0.1.jar obj\Debug\110\lp\140\jl\classes.jar obj\Debug\110\lp\141\jl\classes.jar obj\Debug\110\lp\142\jl\classes.jar obj\Debug\110\lp\143\jl\classes.jar obj\Debug\110\lp\144\jl\classes.jar obj\Debug\110\lp\145\jl\classes.jar obj\Debug\110\lp\146\jl\classes.jar obj\Debug\110\lp\147\jl\classes.jar obj\Debug\110\lp\148\jl\classes.jar obj\Debug\110\lp\149\jl\classes.jar obj\Debug\110\lp\15\jl\bin\classes.jar obj\Debug\110\lp\150\jl\classes.jar obj\Debug\110\lp\151\jl\classes.jar obj\Debug\110\lp\152\jl\classes.jar obj\Debug\110\lp\153\jl\classes.jar obj\Debug\110\lp\154\jl\classes.jar obj\Debug\110\lp\155\jl\classes.jar obj\Debug\110\lp\156\jl\classes.jar obj\Debug\110\lp\157\jl\classes.jar obj\Debug\110\lp\158\jl\classes.jar obj\Debug\110\lp\159\jl\classes.jar obj\Debug\110\lp\160\jl\classes.jar obj\Debug\110\lp\161\jl\classes.jar obj\Debug\110\lp\162\jl\classes.jar obj\Debug\110\lp\163\jl\classes.jar obj\Debug\110\lp\164\jl\classes.jar obj\Debug\110\lp\165\jl\classes.jar obj\Debug\110\lp\166\jl\classes.jar obj\Debug\110\lp\167\jl\classes.jar obj\Debug\110\lp\168\jl\classes.jar obj\Debug\110\lp\169\jl\classes.jar obj\Debug\110\lp\170\jl\classes.jar obj\Debug\110\lp\171\jl\classes.jar obj\Debug\110\lp\172\jl\classes.jar obj\Debug\110\lp\173\jl\classes.jar obj\Debug\110\lp\174\jl\classes.jar obj\Debug\110\lp\176\jl\classes.jar obj\Debug\110\lp\177\jl\classes.jar obj\Debug\110\lp\178\jl\classes.jar obj\Debug\110\lp\179\jl\classes.jar obj\Debug\110\lp\180\jl\classes.jar obj\Debug\110\lp\181\jl\classes.jar obj\Debug\110\lp\182\jl\classes.jar obj\Debug\110\lp\183\jl\classes.jar obj\Debug\110\lp\184\jl\classes.jar obj\Debug\110\lp\196\jl\classes.jar obj\Debug\110\lp\197\jl\classes.jar obj\Debug\110\lp\198\jl\classes.jar obj\Debug\110\lp\199\jl\classes.jar obj\Debug\110\lp\200\jl\classes.jar obj\Debug\110\lp\201\jl\classes.jar obj\Debug\110\lp\208\jl\classes.jar obj\Debug\110\lp\209\jl\classes.jar obj\Debug\110\lp\211\jl\classes.jar obj\Debug\110\lp\214\jl\classes.jar obj\Debug\110\lp\215\jl\classes.jar obj\Debug\110\lp\3\jl\bin\classes.jar obj\Debug\110\lp\32\jl\okio.jar obj\Debug\110\lp\4\jl\bin\classes.jar obj\Debug\110\lp\5\jl\bin\classes.jar obj\Debug\110\lp\6\jl\bin\classes.jar obj\Debug\110\lp\7\jl\bin\classes.jar obj\Debug\110\lp\8\jl\bin\classes.jar obj\Debug\110\lp\9\jl\bin\classes.jar obj\Debug\110\lp\93\jl\bin\classes.jar 5> Error in obj\Debug\110\lp\211\jl\classes.jar:com/google/android/gms/internal/crash/zza.class: 5> Type com.google.android.gms.internal.crash.zza is defined multiple times: obj\Debug\110\lp\211\jl\classes.jar:com/google/android/gms/internal/crash/zza.class, obj\Debug\110\lp\93\jl\bin\classes.jar:com/google/android/gms/internal/crash/zza.class 5> Compilation failed

And here is my PackageReferences:

<PackageReference Include="BarcodeScanner.XF">
  <Version>4.8.0</Version>
</PackageReference>
<PackageReference Include="CardsView">
  <Version>2.6.6</Version>
</PackageReference>
<PackageReference Include="Com.Airbnb.Xamarin.Forms.Lottie">
  <Version>4.0.6</Version>
</PackageReference>
<PackageReference Include="ContextViewCell">
  <Version>2.0.1</Version>
</PackageReference>
<PackageReference Include="Plugin.LocalNotification">
  <Version>5.1.0</Version>
</PackageReference>
<PackageReference Include="Plugin.MediaManager.Forms">
  <Version>1.0.4</Version>
</PackageReference>
<PackageReference Include="Rg.Plugins.Popup">
  <Version>2.0.0.6</Version>
</PackageReference>
<PackageReference Include="Sharpnado.Presentation.Forms">
  <Version>1.7.1</Version>
</PackageReference>
<PackageReference Include="System.Runtime.Extensions">
  <Version>4.3.1</Version>
</PackageReference>
<PackageReference Include="TouchView">
  <Version>4.1.89</Version>
</PackageReference>
<PackageReference Include="Xam.Plugin.DeviceInfo">
  <Version>4.1.1</Version>
</PackageReference>
<PackageReference Include="Xam.Plugin.HtmlLabel">
  <Version>4.1.3</Version>
</PackageReference>
<PackageReference Include="Xam.Plugin.Media">
  <Version>5.0.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Arch.Core.Common">
  <Version>1.1.1.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Arch.Core.Runtime">
  <Version>1.1.1.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Arch.Lifecycle.Common">
  <Version>1.1.1.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Arch.Lifecycle.Extensions">
  <Version>1.1.1.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Arch.Lifecycle.LiveData">
  <Version>1.1.1.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Arch.Lifecycle.LiveData.Core">
  <Version>1.1.1.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Arch.Lifecycle.Runtime">
  <Version>1.1.1.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Arch.Lifecycle.ViewModel">
  <Version>1.1.1.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Annotations">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Collections">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Compat">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Core.UI">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.CursorAdapter">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Fragment">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Interpolator">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Loader">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Media.Compat">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.v4">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.v7.RecyclerView">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.VersionedParcelable">
  <Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.AppCompat">
  <Version>1.2.0.4</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.AppCompat.AppCompatResources">
  <Version>1.2.0.4</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.AppCompat.Resources">
  <Version>1.1.0.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Browser">
  <Version>1.2.0.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Collection">
  <Version>1.1.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Core">
  <Version>1.3.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4">
  <Version>1.0.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Service">
  <Version>2.2.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Media">
  <Version>1.1.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.MediaRouter">
  <Version>1.1.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Migration">
  <Version>1.0.7.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Paging.Common">
  <Version>2.1.2.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Paging.Runtime">
  <Version>2.1.2.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Palette">
  <Version>1.0.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.RecyclerView">
  <Version>1.1.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Room.Runtime">
  <Version>2.2.5.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.VersionedParcelable">
  <Version>1.1.1.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Work.Runtime">
  <Version>2.3.4.6</Version>
</PackageReference>
<PackageReference Include="Xamarin.Build.Download">
  <Version>0.10.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.FFImageLoading.Forms">
  <Version>2.4.11.982</Version>
</PackageReference>
<PackageReference Include="Xamarin.FFImageLoading.Transformations">
  <Version>2.4.11.982</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
<PackageReference Include="Xamarin.Firebase.Abt">
  <Version>119.0.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Analytics">
  <Version>117.4.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Common">
  <Version>119.3.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Components">
  <Version>116.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Config">
  <Version>119.1.4</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Core">
  <Version>117.4.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Crash">
  <Version>116.2.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Datatransport">
  <Version>117.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Encoders.JSON">
  <Version>116.1.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Iid">
  <Version>120.1.7</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Installations">
  <Version>116.3.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Installations.InterOp">
  <Version>116.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Measurement.Connector">
  <Version>118.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Messaging">
  <Version>120.1.7</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms">
  <Version>4.8.0.1560</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms.Visual.Material">
  <Version>4.8.0.1560</Version>
</PackageReference>
<PackageReference Include="Xamarin.Google.Android.DataTransport.TransportApi">
  <Version>2.2.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Google.Android.DataTransport.TransportBackendCct">
  <Version>2.2.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.Google.Android.DataTransport.TransportRuntime">
  <Version>2.2.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.Google.Android.Material">
  <Version>1.0.0.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Google.Dagger">
  <Version>2.25.2.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Base">
  <Version>117.2.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Basement">
  <Version>117.2.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Flags">
  <Version>117.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Gcm">
  <Version>117.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Location">
  <Version>117.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Maps">
  <Version>117.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Measurement">
  <Version>117.4.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Measurement.Api">
  <Version>117.4.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Measurement.Sdk">
  <Version>117.4.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Tasks">
  <Version>117.0.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.JavaX.Inject">
  <Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Plugin.SharedTransitions">
  <Version>2.4.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Protobuf.Lite">
  <Version>3.0.1</Version>
</PackageReference>
<PackageReference Include="XamEffects">
  <Version>1.6.3</Version>
</PackageReference>
<PackageReference Include="XF.Material">
  <Version>1.7.5</Version>
</PackageReference>

@brendanzagaeski
Copy link
Member

@felipechavez, that looks similar to dotnet/android#5237, but involving a different type, so I suspect it might be caused by a different outdated NuGet package. I tried a quick experiment with copying and pasting the list of PackageReference elements into a new project, but unfortunately I wasn't able to reproduce the error that way.

An idea for a next step is that you can try the "Manual investigation approach" from dotnet/android#5237 (comment) to identify which two NuGet packages are causing the conflict and see if one looks outdated. If that doesn't reveal a way to solve the problem by updating or removing an old NuGet package, then if you can submit a new issue with all the details you've collected so the team can take a look, that would be perfect. Thanks in advance!

@felipechavez
Copy link

felipechavez commented Oct 31, 2020

@brendanzagaeski thanks very much for the answer, i figured it out uninstalling Xamarin.Firebase.Crash v116.2.1 in the android projects (what an irony). Works fine now after cleaning bin/obj and compiling (action that triggered the error before)

@brendanzagaeski
Copy link
Member

Excellent. Glad you found a solution, and thanks for sharing the information on how you solved it!

@EduardoReisDev
Copy link

EduardoReisDev commented Nov 7, 2020

@felipechavez
Did you solve the problem by removing Xamarin.Firebase.Crash?
In my project I only have Xamarin.Firebase.Firestore and Xamarin.Firebase.Auth.
I am looking for a solution to this problem (Error MSB6006: “java” exited with code 1) for more than a week but no solution. :(

PT-BR
Você resolveu o problema removendo o Xamarin.Firebase.Crash?
No meu projeto eu só tenho o Xamarin.Firebase.Firestore e Xamarin.Firebase.Auth.
Estou procurando uma solução para esse problema (Error MSB6006: “java” exited with code 1 ) a mais de uma semana mas nada de uma solução. :(

@EduardoReisDev
Copy link

image

@brendanzagaeski

This comment has been minimized.

@brendanzagaeski

This comment has been minimized.

@EduardoReisDev
Copy link

EduardoReisDev commented Nov 20, 2020

@brendanzagaeski

OMG! It worked! I followed the steps you told me in the first comment. I added the PackageReference to the .csproj file.

Thank you!!

@brendanzagaeski
Copy link
Member

Perfect. Glad it worked for you too!

@Mataboge
Copy link
Author

@brendanzagaeski your solutions seem to make this error go away, but eventually, guava introduces this runtime error

Java.Lang.NoClassDefFoundError: 'Failed resolution of: Lcom/google/common/io/BaseEncoding;

do you perhaps know maybe how i can get through this?

@brendanzagaeski
Copy link
Member

@Mataboge (and @EduardoReisDev and @gioggio79 too, so you can fix the incorrect workarounds for your projects), oh shoot. You're absolutely right. The previous candidate workarounds were both invalid. Luckily, there are a couple different workaround options.

Corrected candidate workaround option A

  1. If one of the invalid candidate workarounds for Xamarin.Google.Guava was previously applied, remove the workaround, delete the obj\project.assets.json, and close and reopen the solution to force the NuGet packages to re-restore.

  2. Install the Xamarin.AndroidX.Browser version 1.0.0 NuGet package to force a downgrade of that package to version 1.0.0.

Corrected candidate workaround option B

If the project needs to use a Xamarin.AndroidX.Browser version higher than 1.0.0, this is another option.

  1. If one of the invalid candidate workarounds for Xamarin.Google.Guava was previously applied, remove it.

  2. Open the .csproj project file for the Xamarin.Android app project in Visual Studio or another text editor.

  3. Find the <PropertyGroup> tag that contains the <PackageReference> elements for the project, and add the following additional <PackageReference> element to that list:

     <PackageReference Include="Xamarin.Google.Guava.ListenableFuture" ExcludeAssets="build;buildTransitive">
       <Version>1.0.0.2</Version>
     </PackageReference>
  4. Delete the obj\project.assets.json file and close and reopen the solution to force the NuGet packages to re-restore.

Explanation of candidate workaround option A

In Android Studio, the output of the dependencies Gradle task for com.google.firebase:firebase-firestore:21.4.3 reveals that there are transitive dependencies on the full Guava library:

These same dependencies exist even for the more recent com.google.firebase:firebase-firestore:22.0.0, so the Xamarin project needs to use the assets from the Xamarin.Google.Guava NuGet package, and the original candidate workarounds were invalid.

That said, unlike in the Xamarin.Android project, in the Android Studio project, adding com.google.android.gms:play-services-ads:19.1.0 doesn't add a dependency on com.google.guava:listenablefuture.

Dependency output for com.google.android.gms:play-services-ads:19.1.0
+--- com.google.android.gms:play-services-ads:19.1.0
|    +--- androidx.browser:browser:1.0.0
|    |    +--- androidx.core:core:1.0.0 -> 1.3.0 (*)
|    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    +--- androidx.interpolator:interpolator:1.0.0 (*)
|    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |    \--- androidx.legacy:legacy-support-core-ui:1.0.0
|    |         +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |         +--- androidx.core:core:1.0.0 -> 1.3.0 (*)
|    |         +--- androidx.legacy:legacy-support-core-utils:1.0.0
|    |         |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |         |    +--- androidx.core:core:1.0.0 -> 1.3.0 (*)
|    |         |    +--- androidx.documentfile:documentfile:1.0.0
|    |         |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |         |    +--- androidx.loader:loader:1.0.0 (*)
|    |         |    +--- androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
|    |         |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |         |    \--- androidx.print:print:1.0.0
|    |         |         \--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |         +--- androidx.customview:customview:1.0.0 (*)
|    |         +--- androidx.viewpager:viewpager:1.0.0 (*)
|    |         +--- androidx.coordinatorlayout:coordinatorlayout:1.0.0
|    |         |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |         |    +--- androidx.core:core:1.0.0 -> 1.3.0 (*)
|    |         |    \--- androidx.customview:customview:1.0.0 (*)
|    |         +--- androidx.drawerlayout:drawerlayout:1.0.0 (*)
|    |         +--- androidx.slidingpanelayout:slidingpanelayout:1.0.0
|    |         |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |         |    +--- androidx.core:core:1.0.0 -> 1.3.0 (*)
|    |         |    \--- androidx.customview:customview:1.0.0 (*)
|    |         +--- androidx.interpolator:interpolator:1.0.0 (*)
|    |         +--- androidx.swiperefreshlayout:swiperefreshlayout:1.0.0
|    |         |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |         |    +--- androidx.core:core:1.0.0 -> 1.3.0 (*)
|    |         |    \--- androidx.interpolator:interpolator:1.0.0 (*)
|    |         +--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0
|    |         |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |         |    \--- androidx.core:core:1.0.0 -> 1.3.0 (*)
|    |         \--- androidx.cursoradapter:cursoradapter:1.0.0 (*)
|    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    +--- androidx.core:core:1.0.0 -> 1.3.0 (*)
|    +--- com.google.android.gms:play-services-ads-base:[19.1.0] -> 19.1.0
|    +--- com.google.android.gms:play-services-ads-identifier:17.0.0
|    |    \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    +--- com.google.android.gms:play-services-ads-lite:[19.1.0] -> 19.1.0
|    |    +--- com.google.android.gms:play-services-ads-base:[19.1.0] -> 19.1.0
|    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    \--- com.google.android.gms:play-services-measurement-sdk-api:17.1.0
|    |         +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |         \--- com.google.android.gms:play-services-measurement-base:[17.1.0] -> 17.1.0
|    |              \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    \--- com.google.android.gms:play-services-gass:[19.1.0] -> 19.1.0
|         +--- com.google.android.gms:play-services-ads-base:[19.1.0] -> 19.1.0
|         +--- com.google.android.gms:play-services-ads-identifier:17.0.0 (*)
|         +--- com.google.android.gms:play-services-ads-lite:[19.1.0] -> 19.1.0 (*)
|         +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|         \--- com.google.android.gms:play-services-tasks:17.0.0 (*)

The difference is that the Xamarin project is using androidx.browser:browser:1.2.0 instead of androidx.browser:browser:1.0.0. androidx.browser:browser:1.2.0 has a dependency on com.google.guava:listenablefuture, while androidx.browser:browser:1.0.0 does not.

The new candidate workaround option A forces the androidx.browser:browser version to 1.0.0 to avoid the com.google.guava:listenablefuture dependency.

Explanation of candidate workaround option B

What happens if Android Studio is forced to use the "problematic" newer androidx.browser:browser:1.2.0 instead of androidx.browser:browser:1.0.0? In that case, there is a special dependency that avoids the conflict:

\--- com.google.guava:guava:28.1-android
|    |    |    |         +--- com.google.guava:failureaccess:1.0.1
|    |    |    |         +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|    +--- androidx.browser:browser:1.0.0 -> 1.2.0
|    |    +--- androidx.core:core:1.1.0 -> 1.3.0 (*)
|    |    +--- androidx.annotation:annotation:1.1.0
|    |    \--- com.google.guava:listenablefuture:1.0 -> 9999.0-empty-to-avoid-conflict-with-guava

That is, the com.google.guava:guava artifact has a dependency on a special strange artifact version com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava that overrides other versions of com.google.guava:listenablefuture and provides an empty placeholder library that avoids conflicts with the full Guava library.

Because there is no corresponding special version "9999.0-empty-to-avoid-conflict-with-guava" of the Xamarin.Google.Guava.ListenableFuture NuGet package, the corrected candidate workaround option B takes a different approach to achieve a similar result. That NuGet package uses build and buildTransitive .targets files to instruct the Xamarin.Android build process to reference guava-listenablefuture.jar, so it's possible to stop the package from adding the .jar by excluding the build and buildTransitive assets from the NuGet package. After this change, when the app runs on a device, the androidx.browser:browser library will in theory reference the full Guava library that Firestore brings in, and everything will work happily. One caution is that I didn't have a test handy to try androidx.browser:browser hands-on in this build setup, but it should work without error.

@Mataboge
Copy link
Author

@brendanzagaeski thank you for your explanations and solutions.

Candidate B gave an Error saying Cannot Access Google.Guava.ListenableFuture.

Candidate A worked for me. Thank you very much.

@gioggio79
Copy link

gioggio79 commented Dec 3, 2020

@brendanzagaeski really thanks for your assistance (and sorry for the delay in my response)

Candidate A don't work for me (I tried with v. 1.0.0 and 1.0.0.1 required for xamarin 4.8.0.1687)
Compilation fail with error: Type com.google.common.util.concurrent.ListenableFuture is defined multiple times

Candidate B works like a charm, now I can build without java exit code 1.
But I think there are some problem with cloud firestore.

I try to retrieve the database fields with

//var FirestoreIstance = FirebaseFirestore.GetInstance(MainActivity.MyFirebaseApp); <- I tried all two version to get firestoreIstance
var FirestoreIstance = FirebaseFirestore.Instance;
if (FirestoreIstance != null)
{
	try
	{
		var myMessages = FirestoreIstance.Collection("chatChannels").Document(ChannelId).Collection("messages");
		FirestoreIstance.Collection("chatChannels").Document(ChannelId).Collection("messages").OrderBy("time", Query.Direction.Descending).Limit(20).WhereLessThan("time", JavaDate).Get().AddOnCompleteListener(new GmsTaskCompletion((sender, e) =>
			{
			//code
			}));
	}
	catch (Exception e)
	{
		
	}

public class GmsTaskCompletion : Java.Lang.Object, IOnCompleteListener
	{
		public class GmsTaskEvent : EventArgs
		{
			public readonly Android.Gms.Tasks.Task task;
			public GmsTaskEvent(Android.Gms.Tasks.Task task) => this.task = task;
		}

		readonly EventHandler handler;
		public GmsTaskCompletion(EventHandler handler) => this.handler = handler;
		public void OnComplete(Android.Gms.Tasks.Task task)
		{
			if (handler != null)
				handler.Invoke(this, new GmsTaskEvent(task));
		}
	}

and application crash

12-03 12:18:14.472 E/AndroidRuntime(24974): FATAL EXCEPTION: main
12-03 12:18:14.472 E/AndroidRuntime(24974): Process: , PID: 24974
12-03 12:18:14.472 E/AndroidRuntime(24974): java.lang.RuntimeException: Internal error in Cloud Firestore (21.4.3).
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(com.google.firebase:firebase-firestore@@21.4.3:534)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(Unknown Source:2)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at android.os.Handler.handleCallback(Handler.java:873)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at android.os.Handler.dispatchMessage(Handler.java:99)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at android.os.Looper.loop(Looper.java:201)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at android.app.ActivityThread.main(ActivityThread.java:6810)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at java.lang.reflect.Method.invoke(Native Method)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
12-03 12:18:14.472 E/AndroidRuntime(24974): Caused by: java.lang.NoSuchMethodError: No virtual method putPropagating(Lio/opencensus/tags/TagKey;Lio/opencensus/tags/TagValue;)Lio/opencensus/tags/TagContextBuilder; in class Lio/opencensus/tags/TagContextBuilder; or its super classes (declaration of 'io.opencensus.tags.TagContextBuilder' appears in /data/app/-xDdh2aAJ-YJ1bTONYB8cdg==/base.apk!classes2.dex)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at io.grpc.internal.CensusStatsModule$ClientCallTracer.<init>(CensusStatsModule.java:359)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at io.grpc.internal.CensusStatsModule.newClientCallTracer(CensusStatsModule.java:146)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at io.grpc.internal.CensusStatsModule$StatsClientInterceptor.interceptCall(CensusStatsModule.java:689)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:814)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at io.grpc.internal.ForwardingManagedChannel.newCall(ForwardingManagedChannel.java:63)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at io.grpc.android.AndroidChannelBuilder$AndroidChannel.newCall(AndroidChannelBuilder.java:288)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at com.google.firebase.firestore.remote.GrpcCallProvider.lambda$createClientCall$0(com.google.firebase:firebase-firestore@@21.4.3:138)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at com.google.firebase.firestore.remote.GrpcCallProvider$$Lambda$1.then(Unknown Source:4)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at com.google.android.gms.tasks.zzg.run(com.google.android.gms:play-services-tasks@@17.0.2:2)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
12-03 12:18:14.472 E/AndroidRuntime(24974): 	at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@21.4.3:229)

below the packages I'm using for Candidate A

<ItemGroup>
    <PackageReference Include="Branch-Xamarin-Linking-SDK">
      <Version>7.0.7</Version>
    </PackageReference>
    <PackageReference Include="CardsView">
      <Version>2.6.4</Version>
    </PackageReference>
    <PackageReference Include="CarouselView.FormsPlugin">
      <Version>5.2.0</Version>
    </PackageReference>
    <PackageReference Include="Com.Airbnb.Xamarin.Forms.Lottie">
      <Version>4.0.7</Version>
    </PackageReference>
    <PackageReference Include="Forms9Patch">
      <Version>2.4.6</Version>
    </PackageReference>
    <PackageReference Include="MLToolkit.Forms.SwipeCardView">
      <Version>2.2.0</Version>
    </PackageReference>
    <PackageReference Include="MR.Gestures">
      <Version>2.1.3</Version>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json">
      <Version>12.0.3</Version>
    </PackageReference>
    <PackageReference Include="PhotoBrowser.Forms">
      <Version>0.1.4</Version>
    </PackageReference>
    <PackageReference Include="Plugin.CurrentActivity">
      <Version>2.1.0.4</Version>
    </PackageReference>
    <PackageReference Include="Plugin.FirebasePushNotification">
      <Version>3.3.10</Version>
    </PackageReference>
    <PackageReference Include="Plugin.InAppBilling">
      <Version>2.0.0</Version>
    </PackageReference>
    <PackageReference Include="Plugin.LocalNotification">
      <Version>5.1.1</Version>
    </PackageReference>
    <PackageReference Include="Plugin.Permissions">
      <Version>6.0.1</Version>
    </PackageReference>
    <PackageReference Include="Rg.Plugins.Popup">
      <Version>2.0.0.7</Version>
    </PackageReference>
    <PackageReference Include="System.Net.Http">
      <Version>4.3.4</Version>
    </PackageReference>
    <PackageReference Include="UrhoSharp.Forms">
      <Version>1.9.67</Version>
    </PackageReference>
    <PackageReference Include="UrhoSharp.Tools">
      <Version>1.8.93</Version>
    </PackageReference>
    <PackageReference Include="Xam.Plugin.DeviceInfo">
      <Version>4.1.1</Version>
    </PackageReference>
    <PackageReference Include="Xam.Plugin.Media">
      <Version>4.0.1.5</Version>
    </PackageReference>
    <PackageReference Include="Xam.Plugin.SimpleAudioPlayer">
      <Version>1.4.0</Version>
    </PackageReference>
    <PackageReference Include="Xam.Plugins.Settings">
      <Version>4.1.0-beta</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData">
      <Version>2.2.0.3</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Auth">
      <Version>119.3.1</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Crashlytics">
      <Version>117.1.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Datatransport">
      <Version>117.0.5</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Firestore">
      <Version>121.4.3</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Messaging">
      <Version>120.1.7</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Google.Android.Material">
      <Version>1.1.0.5</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.Browser">
      <Version>1.0.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4">
      <Version>1.0.0.5</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.MediaRouter">
      <Version>1.2.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.Browser">
      <Version>1.2.0.1</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4">
      <Version>1.0.0.1</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.FFImageLoading">
      <Version>2.4.11.982</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.FFImageLoading.Forms">
      <Version>2.4.11.982</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Analytics">
      <Version>117.4.1</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Forms" Version="4.8.0.1687" />
    <PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
    <PackageReference Include="Xamarin.Forms.PancakeView">
      <Version>1.4.2</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Forms.Visual.Material">
      <Version>4.8.0.1687</Version>
    </PackageReference>
    <PackageReference Include="XF.Material">
      <Version>1.7.6</Version>
    </PackageReference>
  </ItemGroup>

@rjhind
Copy link

rjhind commented Jan 8, 2021

Just to add that solution B) worked for me.

@greg84
Copy link

greg84 commented Jan 11, 2021

I have the same problem after installing the following nuget packages in an Android project:

Xamarin.Firebase.Analytics (118.0.0)
Xamarin.Firebase.Analytics.Impl (116.3.0)

This is the error I get:

Type com.google.android.gms.internal.measurement.zzu is defined multiple times: obj\Debug\100\lp\109\jl\classes.jar:com/google/android/gms/internal/measurement/zzu.class, obj\Debug\100\lp\123\jl\classes.jar:com/google/android/gms/internal/measurement/zzu.class (TaskId:185)

Workaround by downgrading to:

Xamarin.Firebase.Analytics (71.1630.4)
Xamarin.Firebase.Analytics.Impl (71.1630.4)

...and also installing:

Xamarin.Android.Support.Core.Utils (28.0.0.3)
Xamarin.Android.Support.Fragment (28.0.0.3)

Don't know if it actually works yet, but I don't get the build error anymore.

Repro steps: Make new Xamarin Forms solution with Android project. Add latest versions of the two packages above. Build.

@IzyPro
Copy link

IzyPro commented Jan 27, 2021

Thanks a lot @greg84
Downgrading Firebase.Analytics and Firebase.Analytics.Impl to (71.1630.4)
And then adding Xamarin.Android.Support.Core.Utils (28.0.0.3) and Xamarin.Android.Support.Fragment (28.0.0.3) worked perfectly for me

@cbovar
Copy link

cbovar commented Feb 6, 2021

Removing Xamarin.Firebase.Analytics.Impl which is not needed anymore worked for me.

@fabian-st
Copy link

Removing Xamarin.Firebase.Analytics.Impl which is not needed anymore worked for me.

Thanks, this was the solution for me!

@banjahman
Copy link

the solution from @greg84 worked for me as well. Thanks for posting that, saved me a bunch of wasted time.

For what it's worth, I didn't need to install the support libs. My issue was fixed by simply downgrading the following

Xamarin.Firebase.Analytics (71.1630.4)
Xamarin.Firebase.Analytics.Impl (71.1630.4)

@tiaan-lg
Copy link

Removing Xamarin.Firebase.Analytics.Impl which is not needed anymore worked for me.

Thanks! This also worked for me

@EduardoReisDev
Copy link

@brendanzagaeski solution B its work!! Tnaks

@ladoleste
Copy link

Tried every single solution... the closest one was to downgrade Analytics to 71.1630.4 but that requires downgrading every firebase dependency in the project which in turn brings a world of new problems.

@tolgakucuk
Copy link

tolgakucuk commented Mar 25, 2021

@brendanzagaeski Hi Mr.Zagaeski, I have been trying every solution about this topic but I couldnt fix the issue.
I am still getting this error:
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\Android\Xamarin.Android.D8.targets(51,5): error MSB6006: "java.exe" exited with code 1.

here is the page When I double clicked:
`
<R8

    Condition=" '$(_UseR8)' == 'True' "
    ToolPath="$(JavaToolPath)"
    JavaMaximumHeapSize="$(JavaMaximumHeapSize)"
    JavaOptions="$(JavaOptions)"
    JarPath="$(AndroidR8JarPath)"
    AndroidManifestFile="$(IntermediateOutputPath)android\AndroidManifest.xml"
    OutputDirectory="$(_AndroidIntermediateDexOutputDirectory)"
    Debug="$(AndroidIncludeDebugSymbols)"
    JavaPlatformJarPath="$(JavaPlatformJarPath)"
    ClassesZip="$(_AndroidIntermediateClassesZip)"
    JavaLibrariesToEmbed="@(_JavaLibrariesToCompileForApp);@(_InstantRunJavaReference)"
    JavaLibrariesToReference="@(AndroidExternalJavaLibrary)"
    EnableDesugar="$(AndroidEnableDesugar)"
    AndroidSdkBuildToolsPath="$(AndroidSdkBuildToolsPath)"
    AcwMapFile="$(_AcwMapFile)"
    ProguardCommonXamarinConfiguration="$(IntermediateOutputPath)proguard\proguard_xamarin.cfg"
    ProguardGeneratedReferenceConfiguration="$(_ProguardProjectConfiguration)"
    ProguardGeneratedApplicationConfiguration="$(IntermediateOutputPath)proguard\proguard_project_primary.cfg"
    ProguardMappingFileOutput="$(AndroidProguardMappingFile)"
    ProguardConfigurationFiles="@(_ProguardConfiguration)"
    EnableShrinking="$(_R8EnableShrinking)"
    EnableMultiDex="$(AndroidEnableMultiDex)"
    MultiDexMainDexListFile="$(_AndroidMainDexListFile)"
    CustomMainDexListFiles="@(MultiDexMainDexList)"
    IgnoreWarnings="$(AndroidR8IgnoreWarnings)"
    ExtraArguments="$(AndroidR8ExtraArguments)"
/>

`

Here is my package references which I am using:

`

<PackageReference Include="Xamarin.Android.Support.Design">
  <Version>28.0.0.3</Version>
</PackageReference>

<PackageReference Include="Xamarin.Android.Support.v7.AppCompat">
  <Version>28.0.0.3</Version>
</PackageReference>

<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.2.0.5" />

<PackageReference Include="Xamarin.AndroidX.Browser">
  <Version>1.0.0</Version>
</PackageReference>

<PackageReference Include="Xamarin.Build.Download">
  <Version>0.4.11</Version>
</PackageReference>

<PackageReference Include="Xamarin.Firebase.Auth">
  <Version>60.1142.1</Version>
</PackageReference>

<PackageReference Include="Xamarin.Firebase.Database">
  <Version>60.1142.1</Version>
</PackageReference>

<PackageReference Include="Xamarin.Forms">
  <Version>5.0.0.2012</Version>
</PackageReference>

<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />

<PackageReference Include="Xamarin.Essentials" Version="1.6.1" />

<PackageReference Include="Xamarin.Google.Guava" ExcludeAssets="all">
  <Version>27.1.0</Version>
</PackageReference>

<PackageReference Include="Xamarin.GooglePlayServices.Basement">
  <Version>117.6.0</Version>
</PackageReference>

<PackageReference Include="Xamarin.GooglePlayServices.Tasks">
  <Version>117.2.1</Version>
</PackageReference>
`

Please help me.

@rezamohamed
Copy link

rezamohamed commented Mar 28, 2021

In my Android project, I am only using Xamarin.Firebase.Auth (120.0.2) and Xamarin.Firebase.Firestore (122.1.0) and get the "java.exe" exited with code 1 error as well. Attached build log set to Diagnostic here.
build log java error.txt

Unlike the solutions mentioned above, I don't have any of the analytics, googleplayservices, nor the guava packages installed. Very minimal package references:

<ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> <Reference Include="System.Numerics" /> <Reference Include="System.Numerics.Vectors" /> </ItemGroup> <ItemGroup> <PackageReference Include="Xamarin.Firebase.Auth"> <Version>120.0.2</Version> </PackageReference> <PackageReference Include="Xamarin.Firebase.Firestore"> <Version>122.1.0</Version> </PackageReference> <PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" /> <PackageReference Include="Xamarin.Essentials" Version="1.6.1" /> </ItemGroup>

The issues seem to be at the Xamarin.Firebase.Firestore package because if that is removed the build works fine. I have tried downgrading the Firestore package to 71.1705.4 and below and still get the same issue.

UPDATE: I added the Xamarin.Google.Guava package and the project does seem to build without the error now.

UPDATE 2: With Xamarin.Google.Guava, now I am getting a different error when actually trying to access a Firestore Collection: Failed resolution of: Lcom/google/common/io/BaseEncoding;

UPDATE 3: The above helped me to bypass some error messages, but kept propping up new errors. At this point it looks like I'm at a standstill with no resolution.

For what it's worth, it looks like the errors are around here, but I am not sure how to interepret the following message:
Type com.google.common.util.concurrent.ListenableFuture is defined multiple times: obj\Debug\100\androidx\jl\42e41d18-3b93-4719-baed-f89b781acd7f.jar:com/google/common/util/concurrent/ListenableFuture.class, obj\Debug\100\lp\58\jl\__reference__guava.jar:com/google/common/util/concurrent/ListenableFuture.class (TaskId:157) 1> Compilation failed (TaskId:157) 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.D8.targets(79,5): error MSB6006: "java.exe" exited with code 1. 1>Done executing task "D8" -- FAILED. (TaskId:157) 1>Done building target "_CompileToDalvik" in project "MySubscriptions.Android.csproj" -- FAILED.: (TargetId:239)

@jpobst
Copy link
Contributor

jpobst commented Mar 28, 2021

For those finding this issue, note that error MSB6006: "java.exe" exited with code 1 is the generic error message you get for any Java error. You will need to look in a diagnostic log to see the actual error from java.exe.

@OladotunO
Copy link

OladotunO commented Apr 17, 2021

"java.exe" exited with code 1

Hi All, I started getting this error after I updated my App for the first time in about 6 months. I find that to solve it I have to reverse my nugets to

Xamarin.GooglePlayServices.Measurement,base v 71.1630.4
Xamarin.Android Bindings for Google Play Services - Measurement.Sdk.Api 71.1630.4
Xamarin.Android Bindings for Google Play Services - Stats 71.1601.4
Xamarin.Android Bindings for Google Play Services - Xamarin.Firebase.Iid 71.1710.4
Xamarin.Android Bindings for Google Play Services - Xamarin.Firebase.Analytics.Impl 71.1630.4

Then my App builds again, I really dont know for sure which nuget of the above is failing,
I am not even certain that others error are the same issue

Cheers

Ola

@RadoslawKubas
Copy link

RadoslawKubas commented Apr 17, 2021

@OladotunO I have seen this and similar bugs many times and the solution has always been one and so far works. For each package used in the solution I've checked the list of their dependencies (recurrently). If there were any "google" dependency I referenced this "google" package directly (to force latest stable version). When all "google" packages were updated to their lates versions everything works again :) I know it may be problematic if there were some breaking changes in google but it is more common to see problem between google packages it selfs when they are from different versions.

@JanaJunkiss
Copy link

@brendanzagaeski Thank you! You saved my weekend.

@ShuhjiKaya
Copy link

I got the same problem by all NuGet packages update to latest.
It is fixed by below 5 packages downdate.

Xamarin.GooglePlayServices.Ads 120.0.0
Xamarin.GooglePlayServices.Ads.Base 120.0.0
Xamarin.GooglePlayServices.Ads.Identifier 117.0.0
Xamarin.GooglePlayServices.Ads.Lite 120.0.0
Xamarin.GooglePlayServices.Basement 117.6.0

I don't use firebase in the project.
I leave this comment for somebody's hint.

@filipnavara
Copy link

Unfortunately there's a secondary problem. Some packages also shipped the ListenableFuture .aar assets inside the transitive dependencies. Now tracked in xamarin/XamarinComponents#1312.

The one and only reliable workaround in that case is

  <Target Name="Remove1B1B3F705C33DF84" AfterTargets="_CheckDuplicateJavaLibraries">
    <ItemGroup>
      <ExtractedJarImportsToRemove Include="@(ExtractedJarImports)" Condition="'%(Filename)' == '1B1B3F705C33DF84'" />
      <ExtractedJarImports Remove="@(ExtractedJarImportsToRemove)" />
    </ItemGroup>
  </Target>

It removes all instances of the problematic .aar after the packages are resolved.

For reference, the packages that hit this problem are:

  <ItemGroup>
    <PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.0.2.1" />
    <PackageReference Include="Xamarin.AndroidX.Camera.Lifecycle" Version="1.0.2.1" />
    <PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.0.0.5-alpha20" />
    <PackageReference Include="Xamarin.AndroidX.Browser" Version="1.3.0.9" />
    <PackageReference Include="Xamarin.AndroidX.Concurrent.Futures" Version="1.1.0.6" />
    <PackageReference Include="Xamarin.AndroidX.Core" Version="1.7.0.1" />
    <PackageReference Include="Xamarin.AndroidX.CustomView" Version="1.1.0.10" />
    <PackageReference Include="Xamarin.AndroidX.Preference" Version="1.1.1.12" />
    <PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.2.1.4" />
    <PackageReference Include="Xamarin.AndroidX.Work.Runtime" Version="2.7.0.1" />
    <PackageReference Include="Xamarin.Google.Dagger" Version="2.39.1" />
    <PackageReference Include="Xamarin.Google.MLKit.BarcodeScanning" Version="116.1.2.2" />

    <PackageReference Include="SkiaSharp" Version="2.88.0-preview.155" />
    <PackageReference Include="Xamarin.CommunityToolkit.MauiCompat" Version="1.3.0-compat-alpha3" />
    <PackageReference Include="Xamarin.CommunityToolkit.Markup.MauiCompat" Version="1.3.0-compat-alpha3" />
  </ItemGroup>

with <UseMaui> and <UseMauiEssentials> bringing in few additional dependencies.

@hazwan223
Copy link

I

@Mataboge (and @EduardoReisDev and @gioggio79 too, so you can fix the incorrect workarounds for your projects), oh shoot. You're absolutely right. The previous candidate workarounds were both invalid. Luckily, there are a couple different workaround options.

Corrected candidate workaround option A

  1. If one of the invalid candidate workarounds for Xamarin.Google.Guava was previously applied, remove the workaround, delete the obj\project.assets.json, and close and reopen the solution to force the NuGet packages to re-restore.
  2. Install the Xamarin.AndroidX.Browser version 1.0.0 NuGet package to force a downgrade of that package to version 1.0.0.

Corrected candidate workaround option B

If the project needs to use a Xamarin.AndroidX.Browser version higher than 1.0.0, this is another option.

  1. If one of the invalid candidate workarounds for Xamarin.Google.Guava was previously applied, remove it.
  2. Open the .csproj project file for the Xamarin.Android app project in Visual Studio or another text editor.
  3. Find the <PropertyGroup> tag that contains the <PackageReference> elements for the project, and add the following additional <PackageReference> element to that list:
     <PackageReference Include="Xamarin.Google.Guava.ListenableFuture" ExcludeAssets="build;buildTransitive">
       <Version>1.0.0.2</Version>
     </PackageReference>
    
  4. Delete the obj\project.assets.json file and close and reopen the solution to force the NuGet packages to re-restore.

Explanation of candidate workaround option A

In Android Studio, the output of the dependencies Gradle task for com.google.firebase:firebase-firestore:21.4.3 reveals that there are transitive dependencies on the full Guava library:

These same dependencies exist even for the more recent com.google.firebase:firebase-firestore:22.0.0, so the Xamarin project needs to use the assets from the Xamarin.Google.Guava NuGet package, and the original candidate workarounds were invalid.

That said, unlike in the Xamarin.Android project, in the Android Studio project, adding com.google.android.gms:play-services-ads:19.1.0 doesn't add a dependency on com.google.guava:listenablefuture.

Dependency output for com.google.android.gms:play-services-ads:19.1.0
The difference is that the Xamarin project is using androidx.browser:browser:1.2.0 instead of androidx.browser:browser:1.0.0. androidx.browser:browser:1.2.0 has a dependency on com.google.guava:listenablefuture, while androidx.browser:browser:1.0.0 does not.

The new candidate workaround option A forces the androidx.browser:browser version to 1.0.0 to avoid the com.google.guava:listenablefuture dependency.

Explanation of candidate workaround option B

What happens if Android Studio is forced to use the "problematic" newer androidx.browser:browser:1.2.0 instead of androidx.browser:browser:1.0.0? In that case, there is a special dependency that avoids the conflict:

\--- com.google.guava:guava:28.1-android
|    |    |    |         +--- com.google.guava:failureaccess:1.0.1
|    |    |    |         +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|    +--- androidx.browser:browser:1.0.0 -> 1.2.0
|    |    +--- androidx.core:core:1.1.0 -> 1.3.0 (*)
|    |    +--- androidx.annotation:annotation:1.1.0
|    |    \--- com.google.guava:listenablefuture:1.0 -> 9999.0-empty-to-avoid-conflict-with-guava

That is, the com.google.guava:guava artifact has a dependency on a special strange artifact version com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava that overrides other versions of com.google.guava:listenablefuture and provides an empty placeholder library that avoids conflicts with the full Guava library.

Because there is no corresponding special version "9999.0-empty-to-avoid-conflict-with-guava" of the Xamarin.Google.Guava.ListenableFuture NuGet package, the corrected candidate workaround option B takes a different approach to achieve a similar result. That NuGet package uses build and buildTransitive .targets files to instruct the Xamarin.Android build process to reference guava-listenablefuture.jar, so it's possible to stop the package from adding the .jar by excluding the build and buildTransitive assets from the NuGet package. After this change, when the app runs on a device, the androidx.browser:browser library will in theory reference the full Guava library that Firestore brings in, and everything will work happily. One caution is that I didn't have a test handy to try androidx.browser:browser hands-on in this build setup, but it should work without error.

I've tried both workarounds and still end up with this error.
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-preview.12.2\tools\Xamarin.Android.D8.targets(79,5): error MSB6006: "java.exe" exited with code 1.

@moljac
Copy link
Member

moljac commented Feb 22, 2022

Hi

Most of your problems are because of real-world (complex) samples/apps, mostly due to transitive dependencies and some problems we caused (in the past) and google caused and is still causing. Here Guava is very specific and fun set of libraries.

For example new problems (FYI - from my notes):

Currently AndroidX (AX) and Google.PlayServices/Firebase/MLKit updates are blocked

... because more and more libraries bring in weird dependencies, like:

2 problems:

*   dependencies on 2 (two) versions of `guava`

    *   `30.1.1-android`
    
    *   `30.1.1-jre`

*   semantic versioning problem

    *   sufix indicates preview and our customers don't want to depend on preview (can be solved with naming, but..)

google releases more and more packages that depend on previews:

https://stackoverflow.com/questions/68723859/ml-kit-stable-artifacts-depending-on-preview-package-com-google-android-odml-im

@moljac
Copy link
Member

moljac commented Feb 22, 2022

some Tips and tricks

for most of your problems and issues:

  1. do not mix Android.Support and AndroidX
  2. try deleting nugets PackageReference for GPS-FB-MLKit and maybe AndroidX in order to get rid of old stale versions and add one by one the newest versions.

this is how I usually solve similar issues in complex projects

@powerdude
Copy link

I'm starting to get this error withe the latest preview. There's not much code, just a bunch of packages in each solution. Maybe someone will have better luck than i tracking down the offending package.

Also seems to be source generator warnings popping up.

MyCompany.MyApp.zip

@jpobst
Copy link
Contributor

jpobst commented Feb 22, 2022

Note that this is a completely generic error and may or may not be related to other people hitting the same error.

Xamarin.Android.D8.targets(79,5): error MSB6006: "java.exe" exited with code 1.

You will need to enable diagnostic logs to see the actual error java is returning.

It may be something similar to:

C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -Xmx1G -classpath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\r8.jar" com.android.tools.r8.D8 --debug --min-api 21 --output obj\Debug\100\android\bin\ --lib "C:\Program Files (x86)\Android\android-sdk\platforms\android-29\android.jar" --lib "C:\Program Files (x86)\Android\android-sdk\platforms\android-29\optional\org.apache.http.legacy.jar" obj\Debug\100\android\bin\classes.zip "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v10.0\mono.android.jar" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\java_runtime_fastdev.jar" C:\Users\chriz\.nuget\packages\xamarin.google.guava.listenablefuture\1.0.0.2\buildTransitive\monoandroid50\guava-listenablefuture.jar C:\Users\chriz\.nuget\packages\xamarin.androidx.annotation\1.1.0.6\buildTransitive\monoandroid90\..\..\jar\androidx.annotation.annotation.jar C:\Users\chriz\.nuget\packages\xamarin.androidx.collection\1.1.0.5\buildTransitive\monoandroid90\..\..\jar\androidx.collection.collection.jar C:\Users\chriz\.nuget\packages\xamarin.androidx.lifecycle.common\2.2.0.3\buildTransitive\monoandroid90\..\..\jar\androidx.lifecycle.lifecycle-common.jar C:\Users\chriz\.nuget\packages\xamarin.androidx.arch.core.common\2.1.0.6\buildTransitive\monoandroid90\..\..\jar\androidx.arch.core.core-common.jar C:\Users\chriz\.nuget\packages\xamarin.androidx.room.common\2.2.5.5\buildTransitive\monoandroid90\..\..\jar\androidx.room.room-common.jar obj\Debug\100\lp\0\jl\formsviewgroup.jar obj\Debug\100\lp\100\jl\classes.jar obj\Debug\100\lp\101\jl\classes.jar obj\Debug\100\lp\102\jl\classes.jar obj\Debug\100\lp\103\jl\classes.jar obj\Debug\100\lp\104\jl\classes.jar obj\Debug\100\lp\105\jl\classes.jar obj\Debug\100\lp\106\jl\classes.jar obj\Debug\100\lp\107\jl\classes.jar obj\Debug\100\lp\108\jl\classes.jar obj\Debug\100\lp\109\jl\classes.jar obj\Debug\100\lp\110\jl\classes.jar obj\Debug\100\lp\111\jl\classes.jar obj\Debug\100\lp\112\jl\classes.jar obj\Debug\100\lp\113\jl\classes.jar obj\Debug\100\lp\114\jl\classes.jar obj\Debug\100\lp\115\jl\classes.jar obj\Debug\100\lp\116\jl\classes.jar obj\Debug\100\lp\117\jl\classes.jar obj\Debug\100\lp\118\jl\classes.jar obj\Debug\100\lp\120\jl\classes.jar obj\Debug\100\lp\121\jl\classes.jar obj\Debug\100\lp\122\jl\classes.jar obj\Debug\100\lp\123\jl\classes.jar obj\Debug\100\lp\124\jl\classes.jar obj\Debug\100\lp\125\jl\classes.jar obj\Debug\100\lp\2\jl\okhttp-2.7.2.jar obj\Debug\100\lp\3\jl\okio.jar obj\Debug\100\lp\52\jl\bin\classes.jar obj\Debug\100\lp\53\jl\bin\classes.jar obj\Debug\100\lp\54\jl\bin\classes.jar obj\Debug\100\lp\55\jl\bin\classes.jar obj\Debug\100\lp\56\jl\bin\classes.jar obj\Debug\100\lp\57\jl\bin\classes.jar obj\Debug\100\lp\58\jl\bin\classes.jar obj\Debug\100\lp\59\jl\bin\classes.jar obj\Debug\100\lp\63\jl\auto-value-annotations.jar obj\Debug\100\lp\64\jl\__reference__guava.jar obj\Debug\100\lp\65\jl\guava-failureaccess.jar obj\Debug\100\lp\67\jl\bin\classes.jar obj\Debug\100\lp\68\jl\bin\classes.jar obj\Debug\100\lp\69\jl\bin\classes.jar obj\Debug\100\lp\70\jl\bin\classes.jar obj\Debug\100\lp\71\jl\bin\classes.jar obj\Debug\100\lp\72\jl\bin\classes.jar obj\Debug\100\lp\73\jl\bin\classes.jar obj\Debug\100\lp\74\jl\bin\classes.jar obj\Debug\100\lp\75\jl\bin\classes.jar obj\Debug\100\lp\76\jl\bin\classes.jar obj\Debug\100\lp\77\jl\grpc-context-1.14.0.jar obj\Debug\100\lp\78\jl\grpc-core-1.14.0.jar obj\Debug\100\lp\79\jl\grpc-okhttp-1.14.0.jar obj\Debug\100\lp\80\jl\grpc-protobuf-lite-1.14.0.jar obj\Debug\100\lp\81\jl\grpc-stub-1.14.0.jar obj\Debug\100\lp\82\jl\opencensus-api-0.12.3.jar obj\Debug\100\lp\83\jl\opencensus-contrib-grpc-metrics-0.12.3.jar obj\Debug\100\lp\84\jl\protobuf-lite-3.0.1.jar obj\Debug\100\lp\85\jl\classes.jar obj\Debug\100\lp\86\jl\classes.jar obj\Debug\100\lp\87\jl\classes.jar obj\Debug\100\lp\88\jl\classes.jar obj\Debug\100\lp\89\jl\classes.jar obj\Debug\100\lp\90\jl\classes.jar obj\Debug\100\lp\91\jl\classes.jar obj\Debug\100\lp\92\jl\classes.jar obj\Debug\100\lp\93\jl\classes.jar obj\Debug\100\lp\94\jl\classes.jar obj\Debug\100\lp\95\jl\classes.jar obj\Debug\100\lp\96\jl\classes.jar obj\Debug\100\lp\97\jl\classes.jar obj\Debug\100\lp\98\jl\classes.jar obj\Debug\100\lp\99\jl\classes.jar 
Error in C:\Users\chriz\.nuget\packages\xamarin.google.guava.listenablefuture\1.0.0.2\buildTransitive\monoandroid50\guava-listenablefuture.jar:com/google/common/util/concurrent/ListenableFuture.class:
Type com.google.common.util.concurrent.ListenableFuture is defined multiple times: C:\Users\chriz\.nuget\packages\xamarin.google.guava.listenablefuture\1.0.0.2\buildTransitive\monoandroid50\guava-listenablefuture.jar:com/google/common/util/concurrent/ListenableFuture.class, obj\Debug\100\lp\64\jl\__reference__guava.jar:com/google/common/util/concurrent/ListenableFuture.class
Compilation failed
MSB6006: "java.exe" exited with code 1.
Done executing task "D8" -- FAILED.

@venkatsunilm
Copy link

error MSB6006: "java.exe" exited with code 1.

I took the sample from - https://github.com/Azure-Samples/active-directory-xamarin-native-v2/tree/main/1-Basic
and imported it to VS 2022 Version 17.1.3
I have the same issue, any solution for this please?

More error details with Diagnostic logs.
C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin\java.exe -cp "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\manifestmerger.jar" com.xamarin.manifestmerger.Main obj\Debug\110\android\manifestmerger.rsp
Exception in thread "main" java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:878)
at com.android.manifmerger.XmlNode$NamespaceAwareName.(XmlNode.java:208)
at com.android.manifmerger.XmlNode$NamespaceAwareName.(XmlNode.java:194)
at com.android.manifmerger.XmlNode.unwrapName(XmlNode.java:122)
at com.android.manifmerger.OrphanXmlElement.getName(OrphanXmlElement.java:74)
at com.android.manifmerger.OrphanXmlElement.getId(OrphanXmlElement.java:67)
at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:167)
at com.android.manifmerger.XmlNode.getOriginalId(XmlNode.java:50)
at com.android.manifmerger.ActionRecorder.getDecisionTreeRecord(ActionRecorder.java:203)
at com.android.manifmerger.ActionRecorder.recordAddedNodeAction(ActionRecorder.java:110)
at com.android.manifmerger.ActionRecorder.recordAddedNodeAction(ActionRecorder.java:127)
at com.android.manifmerger.ManifestMerger2.load(ManifestMerger2.java:1061)
at com.android.manifmerger.ManifestMerger2.merge(ManifestMerger2.java:171)
at com.android.manifmerger.ManifestMerger2.access$600(ManifestMerger2.java:74)
at com.android.manifmerger.ManifestMerger2$Invoker.merge(ManifestMerger2.java:1843)
at com.android.manifmerger.Merger.process(Merger.java:160)
at com.android.manifmerger.Merger.main(Merger.java:42)
at com.xamarin.manifestmerger.Main.main(Main.java:33)
MSB6006: "java.exe" exited with code 1.

VS2022_17_MSALSample_1_basic_compilationIssues.txt

@vivekscorp
Copy link

Hi, has this issue been fixed yet?

@romali28
Copy link

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.D8.targets(5,5): Error: java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/lp/312/jl/classes.jar : com/google/android/gms/ads/internal/zzc.class

I am facing a similar issue can anyone have an idea how to resolve it?

@FabriBertani
Copy link

I fix this by completly removing the Xamarin.FireBase.Analytics.Impl package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating We are currently looking into this needs-info More information is requested by engineering
Projects
None yet
Development

No branches or pull requests