JimmyPun610 / BarcodeScanner.Mobile

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

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

Open Timonysos opened 4 months ago

Timonysos commented 4 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 4 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 4 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 4 months ago

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

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

Timonysos commented 4 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 4 months ago

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

stepkillah commented 4 months ago

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

dalevross commented 2 months ago

@stepkillah What version on Xamarin.AndroidX.Activity was that?

15mgm15 commented 1 month ago

@dalevross Did you manage to solve this?

alejandro7x commented 2 weeks ago

Any news on this error? We are in the process of migrating an application from Xamarin Forms to MAUI, and we haven't been able to make the switch because this library is a fundamental part of the application.

elqubed84 commented 6 days ago

i can install it by this command dotnet add package BarcodeScanner.Mobile.Maui --prerelease -s=https://api.nuget.org/v3/index.json but when i publish apk `MSBUILD : java.exe error JAVA0000: Error in obj\Release\net8.0-android\lp\171\jl\classes.jar:androidx/activity/ActivityViewModelLazyKt$viewModels$1.class: Type androidx.activity.ActivityViewModelLazyKt$viewModels$1 is defined multiple times: obj\Release\net8.0-android\lp\171\ jl\classes.jar:androidx/activity/ActivityViewModelLazyKt$viewModels$1.class, obj\Release\net8.0-android\lp\207\jl\classes .jar:androidx/activity/ActivityViewModelLazyKt$viewModels$1.class Compilation failed java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\ Release\net8.0-android\lp\171\jl\classes.jar androidx/activity/ActivityViewModelLazyKt$viewModels$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\Release\net8.0-an droid\lp\171\jl\classes.jar:androidx/activity/ActivityViewModelLazyKt$viewModels$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.activity.ActivityViewModelLazyKt$viewModels$1 is defined multiple times: obj\Release\net8.0-android\lp\171\jl\classes.jar:androidx/activity/ActivityViewModelLazyKt$viewModels$1.class, obj \Release\net8.0-android\lp\207\jl\classes.jar:androidx/activity/ActivityViewModelLazyKt$viewModels$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:2056) 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\Release\net8.0-android\lp\171' is from 'androidx.activity.activity.aar'.

Build failed with 1 error(s) and 305 warning(s) in 183.1s`

AbsolutelyFreeWeb commented 1 day ago

Hello, I need one that uses newer packages, specifically, I get this conflict:

Xamarin.AndroidX.Fragment.Ktx 1.8.2 -> Xamarin.AndroidX.Lifecycle.LiveData.Core.Ktx (>= 2.8.4)

BarcodeScanner.Mobile.Maui 8.0.40.1 -> Xamarin.AndroidX.Camera.Camera2 1.3.3.2 -> Xamarin.AndroidX.Camera.Core 1.3.3.2 -> Xamarin.AndroidX.Lifecycle.LiveData 2.7.0.3 -> Xamarin.AndroidX.Lifecycle.LiveData.Core.Ktx (>= 2.7.0.3 && < 2.7.1).

I'm also running on maui 8.0.83. Any chance there will be a new release soon ?

dalevross commented 13 hours ago

@dalevross Did you manage to solve this?

I didn't. I managed to get scanning working with the ZXing library