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

Error java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete #648

Closed
adydecki opened this issue Jun 28, 2022 · 10 comments · Fixed by #649

Comments

@adydecki
Copy link

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

.NET 6.0.301

Description

When two packages Square.OkHttp3 and Xamarin.Kotlin.StdLib are added to the .net6-android application then compile time error (as shown in the repro steps) occurs during the application build.

Steps to Reproduce

  1. create new Android application, i.e. dotnet new android -n AndroidApp
  2. cd to /AndroidApp and add Xamarin.Kotlin.StdLib and Square.OkHttp3 packages, i.e. dotnet add package Xamarin.Kotlin.StdLib dotnet add package Square.OkHttp3
  3. build the application dotnet build
  4. the following compile time error shows up
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/32.0.415/tools/Xamarin.Android.D8.targets(79,5): error : java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /Users/adrian/.nuget/packages/xamarin.kotlin.stdlib/1.6.21.1/buildTransitive/net6.0-android31.0/../../jar/org.jetbrains.kotlin.kotlin-stdlib-1.6.21.jar : kotlin/collections/ArraysUtilJVM.class [/Users/adrian/Dev/projects/github/net6-maui-test/AndroidApp/AndroidApp.csproj]

Above steps can be found in the repository https://github.com/adydecki/net6-maui-test/tree/main/AndroidApp

Did you find any workaround?

No response

Relevant log output

No response

@jonathanpeppers
Copy link
Member

@jpobst do we own Square.OkHttp3?

The error is:

Caused by: com.android.tools.r8.internal.f: Type org.jetbrains.annotations.Unmodifiable is defined multiple times: C:\Users\jopepper\.nuget\packages\xamarin.jetbrains.annotations\23.0.0.4\buildTransitive\net6.0-android31.0\..\..\jar\org.jetbrains.annotations-23.0.0.jar:org/jetbrains/annotations/Unmodifiable.class, obj\Debug\net6.0-android\lp\5\jl\libs\DB43F1C10974DC83.jar:org/jetbrains/annotations/Unmodifiable.class

image

I think it's redistributing things it shouldn't be. Similar to some of the issues we had with AndroidX/GPS.

@jpobst
Copy link
Contributor

jpobst commented Jun 29, 2022

Yes, we bind it out of the GPS repository.

These lines need to be updated to the latest Kotlin versions:
https://github.com/xamarin/GooglePlayServicesComponents/blob/main/config.json#L1951-L1974

The 1.5.31.2 version listed is missing the Condition part of the .targets, so it is adding the library inside the Square.OkHttp3 package.

<AndroidJavaLibrary Condition=" '$(AndroidApplication)' == 'true' " Include="$(MSBuildThisFileDirectory)..\..\jar\org.jetbrains.kotlin.kotlin-stdlib-1.6.21.jar" />

@adydecki
Copy link
Author

Thank you for your answers. Is there a workaround to this issue?
Our application depends on the following packages and fails to build because some of the mentioned packages (Xamairn.AndroidX.Fragment) have a hard dependency to Kotlin ver>=1.6.10.

Xamarin.AndroidX.AppCompat ver="1.3.1.3"
Xamarin.AndroidX.ConstraintLayout ver="2.1.1.2"
Xamarin.AndroidX.CoordinatorLayout ver="1.1.0.10"
Xamarin.AndroidX.Fragment ver="1.4.1"
Xamarin.AndroidX.RecyclerView ver="1.2.1.6"
Xamarin.Kotlin.StdLib ver="1.6.10"
Square.OkHttp3 ver="4.9.2.3"

@jonathanpeppers
Copy link
Member

@adydecki the workaround would be to delete the above DB43F....jar file from Square.OkHttp3.aar.

@tuyen-vuduc
Copy link

@jonathanpeppers Do we still need to do the workaround by far?

@jonathanpeppers
Copy link
Member

No, this was fixed in #649.

You might update all NuGet packages and see if that is the problem.

@tuyen-vuduc
Copy link

@jonathanpeppers Can you advise which packages in particular?

@jonathanpeppers
Copy link
Member

@moljac what versions of GPS packages would contain #649?

@tuyen-vuduc
Copy link

@jonathanpeppers After upgrading Square.OkHttp3 to the latest version, it seems to be ok. I will revert if I face any other issues.

@moljac
Copy link
Member

moljac commented Mar 26, 2023

@moljac what versions of GPS packages would contain #649?

There was tons of updates since 2022-07. Several times bumped all packages for various reasons.

Do you want me to go deeper into details?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants