dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.89k stars 525 forks source link

Xamarin.Android.Aapt2.targets(123,3): error APT2144 com.stripe:stripe-android:20.40.4 #8923

Open tuyen-vuduc opened 2 months ago

tuyen-vuduc commented 2 months ago

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

VS2022 17.9.6, .NET 8.0.204

Description

I cannot compile my binding library for this only native library com.stripe:stripe-android:20.40.4. All of its dependencies were bound well, but it isn't.

The source code can be found here.

Steps to Reproduce

  1. Clone or download this repo at branch
  2. Check out branch feat/com.stripe--stripe-android---20.40.4
  3. Run sh bind.sh --artifact com.stripe:stripe-android:20.40.4 in the terminal (git bash)

Did you find any workaround?

No. not yet.

Relevant log output

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144:  [~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144: invalid file path '~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\obj\Release\net8.0-android34.0\lp\234.stamp'. [~\dotnet-bindin 
g-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144:  [~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144: invalid file path '~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\obj\Release\net8.0-android34.0\lp\237.stamp'. [~\dotnet-bindin 
g-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144:  [~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144: invalid file path '~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\obj\Release\net8.0-android34.0\lp\239.stamp'. [~\dotnet-bindin 
g-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144:  [~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144: invalid file path '~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\obj\Release\net8.0-android34.0\lp\233.stamp'. [~\dotnet-bindin 
g-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144:  [~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144: invalid file path '~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\obj\Release\net8.0-android34.0\lp\235.stamp'. [~\dotnet-bindin 
g-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.85\tools\Xamarin.Android.Aapt2.targets(123,3): error APT2144:  [~\dotnet-binding-utils\src\android\com.stripe\stripe-android\binding\Com.Stripe.StripeAndroid.csproj::TargetFramework=net8.0-android34.0]
tuyen-vuduc commented 2 months ago

Here is the Binlog

You can check out the generated CSPROJ file(s) by opening binding.g.sln.

tuyen-vuduc commented 1 month ago

Facing the issue also with my other lib :( . Really annoying.

https://github.com/tuyen-vuduc/mapbox-maui/issues/10

dellis1972 commented 1 month ago

I'm trying to repo this but the branch feat/com.stripe--stripe-android---20.40.4 does not exist? So I used the 20.43.0 branch, and that fails with a Nuget error.

I need a reliable repo in order to investigate this further.

tuyen-vuduc commented 1 month ago

@dellis1972 Can you simply check out the Mapbox for Maui repo linked above. The same issue there.

tuyen-vuduc commented 1 month ago

This repo is easier as no special config is required. Plz try it out. https://github.com/tuyen-vuduc/dotnet-shakebugs-maui

dellis1972 commented 1 month ago

Still no joy. That repo fails with error XACDJ7028: System.IO.FileNotFoundException: Could not find file `.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.24/3f6b4bd4f8dbe8d4bea06d107a3826469b85c3e9/slf4j-api-1.7.24.jar`.

tuyen-vuduc commented 1 month ago

@dellis1972 Sorry for that inconvenience. I haven't found when it occurs yet, but can you pull the latest and try again?

If the issue occurs again, plz try adding it as a direct dependency then.

<PackageReference Include="Org.Slf4j.Slf4jApi" Version="1.7.36" />
dellis1972 commented 1 month ago

Nope, even with the additional package reference it still fails with the same error about slf4j-api-1.7.36.jar in the gradle cache.

tuyen-vuduc commented 1 month ago

@dellis1972 Can you share your system info? And can you try to rebuild? It's a bit weird... :( .

dellis1972 commented 1 month ago

Its from the clean build. I'm on a Macbook Pro , I wont share any more info than that as its a MS machine.

tuyen-vuduc commented 1 month ago

@dellis1972 That's OK. My friend also tried my ShakeBugs sample app. It just works on his MacMini M1 :D . Can you pull latest and try again?

tuyen-vuduc commented 1 month ago

My tries on Windows, VS2022 have no success :(

tuyen-vuduc commented 3 weeks ago

@dellis1972 I think issue with ShakeBugs libraries is totally different. I will log another issue for that one. I found a workaround for it.

Can you try again the issue with Stripe libraries? The latest branch is changed to Stripe 20.43.0 now.

tuyen-vuduc commented 2 weeks ago

@dellis1972

I found a workaround 1/ Run the script for the desired library 2/ If there is an error, create binding libraries for dependencies one by one until done

BTW the new branch for Stripe Android binding is now for v20.46.0.

:D .

dellis1972 commented 2 weeks ago

Glad you found a work around.

I still get errors on the 20.46.0 branch

src/android/com.stripe/paymentsheet/binding/Com.Stripe.Paymentsheet.csproj : error NU1107: Version conflict detected for Xamarin.AndroidX.Activity. Install/reference Xamarin.AndroidX.Activity 1.9.0.3 directly to project Com.Stripe.Paymentsheet to resolve this issue.  
src/android/com.stripe/paymentsheet/binding/Com.Stripe.Paymentsheet.csproj : error NU1107:  Com.Stripe.Paymentsheet -> Xamarin.AndroidX.AppCompat 1.6.1.10 -> Xamarin.AndroidX.Activity (>= 1.9.0.3) 
src/android/com.stripe/paymentsheet/binding/Com.Stripe.Paymentsheet.csproj : error NU1107:  Com.Stripe.Paymentsheet -> Xamarin.AndroidX.Activity.Ktx 1.8.2.1 -> Xamarin.AndroidX.Activity (>= 1.8.2.1 && < 1.8.3).

So I have still not been able to repo your original issue yet.

tuyen-vuduc commented 2 weeks ago

Can you give more info of what command you triggered?

FYI: It looks like we now cannot create a binding library along with its dependencies all at once. Under my check, if A depends on B, I have to create nuget package for B first, then create package for A. Otherwise, this error will be shown. 😢 . In the other words, A binding library project cannot refer to another binding library project. It's really sucked.

tuyen-vuduc commented 2 weeks ago

Regarding your faced error, it is due to the way Nuget Manager resolves the dependencies. It doesn't implicitly choose the highest version among the conflicting versions of a dependency, but throwing the error. I am wondering if we have an option to force Nuget Manager to choose the highest version?

I already included a workaround with this kind of file, x.y.z.fixed.json. In this JSON, i will put the desired version of the dependency, then the error will be fixed. You can refer many other *.fixed.json in the source code.

dellis1972 commented 2 weeks ago

I can cloning the repo and running sh bind.sh --artifact com.stripe:stripe-android:20.46.0. I have comment out the workload installation in bind.sh as it need root privilages and manually installed the required workloads.