JimmyPun610 / BarcodeScanner.Mobile

Barcode Scanner using GoogleVision API for Xamarin Form, Maui
MIT License
333 stars 100 forks source link

.NET MAUI8 project does not compile with BarcodeScanner.Mobile Version 8.0.40.1 NuGet package #245

Open Timonysos opened 2 months ago

Timonysos commented 2 months ago

I added the NuGet package BarcodeScanner.Mobile Version 8.0.40.1 to an empty .NET MAUI8 project and it won't compile.

There are a lot of related issus like #218 and #223. I tried multiple fixes but it seems like I wasn't quiet able to figure out which packages I need to add.

These are my packages I use:

<ItemGroup>
    <PackageReference Include="BarcodeScanner.Mobile.Maui" Version="8.0.40.1" />
    <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.61" />
    <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.61" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
</ItemGroup>

I got the following errors:

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

Hi, Could you try downgrade the MAUI version to 8.0.41 and try rebuild? It might be caused by different version using in the library and MAUI. If this is the case, I will try to create a new version to use 8.0.61

Timonysos commented 2 months ago

Hi, Could you try downgrade the MAUI version to 8.0.41 and try rebuild? It might be caused by different version using in the library and MAUI. If this is the case, I will try to create a new version to use 8.0.61

I tried downgrading to MAUI version 8.0.40 but still got the same error.

<ItemGroup>
    <PackageReference Include="BarcodeScanner.Mobile.Maui" Version="8.0.40.1" />
    <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
    <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
</ItemGroup>
bengavin commented 2 months ago

@Timonysos - Have you tried this set of Android-specific includes:

https://github.com/JimmyPun610/BarcodeScanner.Mobile/issues/240#issuecomment-2194598764

Timonysos commented 2 months ago

@Timonysos - Have you tried this set of Android-specific includes:

#240 (comment)

Yes, I tried this set of includes but I didn't work for me.

oleg-varlamov commented 2 months ago

Hello! We have the same issue after upgrading our app from MAUI 7 to MAUI 8

stepkillah commented 2 months ago

including the latest version of Xamarin.AndroidX.Activity worked for me