jmbowman1107 / ImageCropper.Maui

MIT License
58 stars 13 forks source link

Issue Compiling Android #31

Open natevarghese opened 1 month ago

natevarghese commented 1 month ago

Stack trace when compiling android in a Maui project.

Error JAVA0000 java: Error in obj/Debug/net8.0-android/lp/180/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class: Type androidx.lifecycle.LiveDataKt$observe$wrappedObserver$1 is defined multiple times: obj/Debug/net8.0-android/lp/180/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class, obj/Debug/net8.0-android/lp/142/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class Compilation failed java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/net8.0-android/lp/180/jl/classes.jar androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:135) at com.android.tools.r8.D8.main(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:5) Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/net8.0-android/lp/180/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class at Version.fakeStackEntry(Version_8.2.33.java:0) at com.android.tools.r8.T.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:5) at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:82) at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:32) at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:31) at com.android.tools.r8.utils.S0.b(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:2) at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:42) at com.android.tools.r8.D8.b(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:13) at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:40) at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:122) ... 1 more Caused by: com.android.tools.r8.utils.b: Type androidx.lifecycle.LiveDataKt$observe$wrappedObserver$1 is defined multiple times: obj/Debug/net8.0-android/lp/180/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class, obj/Debug/net8.0-android/lp/142/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class at com.android.tools.r8.utils.Q2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:21) at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:54) at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:10) at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048) at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:6) at com.android.tools.r8.graph.m4$a.d(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:6) at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:61) at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:12) at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:9) at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:45) at com.android.tools.r8.D8.d(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:17) at com.android.tools.r8.D8.c(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:69) at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:28) ... 6 more Directory 'obj/Debug/net8.0-android/lp/180' is from 'androidx.lifecycle.lifecycle-livedata-core-ktx.aar'.










I tried adding this condition but it didn't change the error. <ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'"> <PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.9.0.4"/> </ItemGroup>










Could it be Xamarin.AndroidX.Activity.Kt needs to be updated?

BehnamAbdy commented 1 month ago

suddenly i encountered the same issue, it took me more than a day to figure out the problem,finally clonig the repository and taking a look at the samples provided i noticed this package reference inside the .csproj file, adding it to my project cleared the annoying errors, i hope this helps the other guys struggling the same issue

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData.Core.Ktx" Version="2.8.3.1" />
</ItemGroup>
IliyanPopov commented 1 month ago

Stack trace when compiling android in a Maui project.

Error JAVA0000 java: Error in obj/Debug/net8.0-android/lp/180/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class: Type androidx.lifecycle.LiveDataKt$observe$wrappedObserver$1 is defined multiple times: obj/Debug/net8.0-android/lp/180/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class, obj/Debug/net8.0-android/lp/142/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class Compilation failed java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/net8.0-android/lp/180/jl/classes.jar androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:135) at com.android.tools.r8.D8.main(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:5) Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/net8.0-android/lp/180/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class at Version.fakeStackEntry(Version_8.2.33.java:0) at com.android.tools.r8.T.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:5) at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:82) at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:32) at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:31) at com.android.tools.r8.utils.S0.b(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:2) at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:42) at com.android.tools.r8.D8.b(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:13) at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:40) at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:122) ... 1 more Caused by: com.android.tools.r8.utils.b: Type androidx.lifecycle.LiveDataKt$observe$wrappedObserver$1 is defined multiple times: obj/Debug/net8.0-android/lp/180/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class, obj/Debug/net8.0-android/lp/142/jl/classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class at com.android.tools.r8.utils.Q2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:21) at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:54) at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:10) at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048) at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:6) at com.android.tools.r8.graph.m4$a.d(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:6) at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:61) at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:12) at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:9) at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:45) at com.android.tools.r8.D8.d(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:17) at com.android.tools.r8.D8.c(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:69) at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:28) ... 6 more Directory 'obj/Debug/net8.0-android/lp/180' is from 'androidx.lifecycle.lifecycle-livedata-core-ktx.aar'.

I tried adding this condition but it didn't change the error. <ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'"> <PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.9.0.4"/> </ItemGroup>

Could it be Xamarin.AndroidX.Activity.Kt needs to be updated?

Thanks mate. This actually worked