Skip to content

Building .NET 7 android binding gives error APT2144: invalid file path '(...)/obj/Debug/net7.0-android/lp/149.stamp' #7660

Closed

Description

@F-Goncalves

Android application type

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

Affected platform version

VS 2022 17.4.2, .NET 7.0.101, Xamarin Android 13.1.0.1

Description

Hi,

I am trying to migrate a Xamarin Android binding to .NET 7 and am seeing following errors during build time:

/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Aapt2.targets(123,3): error APT2144: invalid file path '(...)/obj/Debug/net7.0-android/lp/149.stamp
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Aapt2.targets(123,3): error APT2144: invalid file path '(...)/obj/Debug/net7.0-android/lp/158.stamp'

But the files that cannot be found do exist.

Any help on this issue would be appreciated.

Steps to Reproduce

Did you find any workaround?

No response

Relevant log output

No response

Activity

  1. jpobst commented on Jan 2, 2023

    @jpobst
    Contributor

    If this is a binding project, you likely do not need for it to use AAPT:

    https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNetBindingProjects.md#resourcedesignercs

    Try setting <AndroidGenerateResourceDesigner> to false and see if that fixes it.

  2. F-Goncalves commented on Jan 9, 2023

    @F-Goncalves
    Author

    Unfortunately it makes no difference. Honestly I do not even have a clue what the .stamp files are used for.

  3. jpobst commented on Jan 10, 2023

    @jpobst
    Contributor

    @dellis1972 Seems like these .stamp files should not be passed to AAPT?

  4. assigned and unassigned on Jan 10, 2023
  5. added
    Area: App+Library BuildIssues when building Library projects or Application projects.
    and removed
    Area: App+Library BuildIssues when building Library projects or Application projects.
    on Jan 10, 2023
  6. F-Goncalves commented on Jan 25, 2023

    @F-Goncalves
    Author

    @dellis1972 @jpobst Any news on this?

  7. dellis1972 commented on Jan 25, 2023

    @dellis1972
    Contributor

    @F-Goncalves can you share the Project? (or just even the csproj) It would help us repo the issue.

  8. added
    need-infoIssues that need more information from the author.
    and removed
    needs-triageIssues that need to be assigned.
    on Jan 25, 2023
  9. 11 remaining items

  10. F-Goncalves commented on Jan 26, 2023

    @F-Goncalves
    Author

    @dellis1972
    Oh I see. I will push it.

  11. F-Goncalves commented on Jan 26, 2023

    @F-Goncalves
    Author

    Done

  12. F-Goncalves commented on Feb 2, 2023

    @F-Goncalves
    Author

    Hey @dellis1972,
    it's been a while. Have you been able to compile the sample app?

  13. dellis1972 commented on Feb 6, 2023

    @dellis1972
    Contributor

    @F-Goncalves I am seeing the same BINDINGSGENERATOR : error BG0000: System.NullReferenceException: Object reference not set to an instance of an object. error locally.

    We might need to get help from @jpobst on that one, so you might need to add him to the private repo as well.

  14. F-Goncalves commented on Feb 6, 2023

    @F-Goncalves
    Author

    @jpobst I invited you to the repo. Would be awesome if you could help here. Thanks in advance

  15. jpobst commented on Feb 6, 2023

    @jpobst
    Contributor

    I still get the original errors, was there a fix committed for them?

    C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.26\tools\Xamarin.Android.Aapt2.targets(123,3): error A
    PT2144: invalid file path 'C:\code\temp\JitsiMeetSdk.Maui\JitsiMeetSdk.SlimBinding.Android.Maui\obj\Debug\net7.0-androi
    d\lp\158.stamp'. [C:\code\temp\JitsiMeetSdk.Maui\JitsiMeetSdk.SlimBinding.Android.Maui\JitsiMeetSdk.SlimBinding.Android
    .Maui.csproj]
    C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.26\tools\Xamarin.Android.Aapt2.targets(123,3): error A
    PT2144: invalid file path 'C:\code\temp\JitsiMeetSdk.Maui\JitsiMeetSdk.SlimBinding.Android.Maui\obj\Debug\net7.0-androi
    d\lp\158.stamp'. [C:\code\temp\JitsiMeetSdk.Maui\JitsiMeetSdk.SlimBinding.Android.Maui\JitsiMeetSdk.SlimBinding.Android
    .Maui.csproj]
    C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.26\tools\Xamarin.Android.Aapt2.targets(123,3): error A
    PT2144: invalid file path 'C:\code\temp\JitsiMeetSdk.Maui\JitsiMeetSdk.SlimBinding.Android.Maui\obj\Debug\net7.0-androi
    d\lp\149.stamp'. [C:\code\temp\JitsiMeetSdk.Maui\JitsiMeetSdk.SlimBinding.Android.Maui\JitsiMeetSdk.SlimBinding.Android
    .Maui.csproj]
    
  16. jpobst commented on Feb 6, 2023

    @jpobst
    Contributor

    I think the NRE is the issue I found last week trying to bind the latest Google Material:
    dotnet/java-interop#1080

    Due to the default includes in .NET SDK Style projects, you are trying to bind all 158 libraries in \JitsiLibs, which includes Google Material.

    You can disable this with <EnableDefaultItems>false</EnableDefaultItems>.

    Then you're down to only trying to incorrectly bind ~100 libraries in obj\Debug\net7.0-android\library_project_jars. I guess these come from the slim bindings something?

    In short, I would highly recommend not trying to use slim bindings infrastructure.

    I would suggest:

    • Create a binding project and add mylibrary-release.aar as an <AndroidLibrary>.
    • Add the Java dependencies that your library needs but shouldn't produce C# bindings as <AndroidLibrary Bind='false'>.
  17. andersonvieiragomeslopes commented on Sep 25, 2023

    @andersonvieiragomeslopes

    Hello,
    I hope I'm not late in the discussion, we are facing the same error with library bindings.

    BINDINGSGENERATOR : error BG0000: System.NullReferenceException: Object reference not set to an instance of an object.

    By insisting, we sometimes manage to generate the nuget package, but it breaks when trying to compile in a project, our project is public and we are using the azure communication services voip library.

    image

    https://github.com/Laerdal/Xamarin.AzureCommunicationCalling/tree/maui-beta/Bindings/Android/Laerdal.Maui.AzureCommunicationCalling.Android

    @F-Goncalves were you able to find a solution to your problem?

  18. andersonvieiragomeslopes commented on Sep 25, 2023

    @andersonvieiragomeslopes

    I think the NRE is the issue I found last week trying to bind the latest Google Material: xamarin/java.interop#1080

    Due to the default includes in .NET SDK Style projects, you are trying to bind all 158 libraries in \JitsiLibs, which includes Google Material.

    You can disable this with <EnableDefaultItems>false</EnableDefaultItems>.

    Then you're down to only trying to incorrectly bind ~100 libraries in obj\Debug\net7.0-android\library_project_jars. I guess these come from the slim bindings something?

    In short, I would highly recommend not trying to use slim bindings infrastructure.

    I would suggest:

    • Create a binding project and add mylibrary-release.aar as an <AndroidLibrary>.
    • Add the Java dependencies that your library needs but shouldn't produce C# bindings as <AndroidLibrary Bind='false'>.

    I made progress when trying this, but I'm still stuck with another problem when trying to use the generated nuget package.

    image

  19. jpobst commented on Sep 25, 2023

    @jpobst
    Contributor

    BINDINGSGENERATOR : error BG0000: System.NullReferenceException: Object reference not set to an instance of an object.

    This is a generic error so there's a decent chance it isn't related to this issue.

    I would suggest filing a new issue for this, ideally with:

    • Full stack trace of the exception
    • Sample product that produces this error

    As for the runtime error, that should likely be a separate issue. Look at the output log to get the full text of the Java error. (You may need to bump up the logging verbosity to see it, not sure.)

  20. andersonvieiragomeslopes commented on Sep 25, 2023

    @andersonvieiragomeslopes

    BINDINGSGENERATOR : error BG0000: System.NullReferenceException: Object reference not set to an instance of an object.

    This is a generic error so there's a decent chance it isn't related to this issue.

    I would suggest filing a new issue for this, ideally with:

    • Full stack trace of the exception
    • Sample product that produces this error

    As for the runtime error, that should likely be a separate issue. Look at the output log to get the full text of the Java error. (You may need to bump up the logging verbosity to see it, not sure.)

    It is an azure communication services library binding project, we are migrating to maui, but we came across the error below, this generic error that I mentioned was overcome, but I ran into another one later, to reproduce just add the package nuget that I generate in the link project in any example and build.

    1>Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\net6.0-android33.0\lp\189\jl\libs\ED64959F88B22E6D.jar:com/google/gson/FieldNamingPolicy$5.class
    1> at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:98)
    1> at com.android.tools.r8.D8.main(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:4)
    1>Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\net6.0-android33.0\lp\189\jl\libs\ED64959F88B22E6D.jar:com/google/gson/FieldNamingPolicy$5.class
    1> at Version.fakeStackEntry(Version_3.3.28.java:0)
    1> at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:75)
    1> at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:28)
    1> at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:27)
    1> at com.android.tools.r8.internal.Bj.b(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:2)
    1> at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:22)
    1> at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:17)
    1> at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:85)
    1> ... 1 more
    1>Caused by: com.android.tools.r8.internal.f: Type com.google.gson.FieldNamingPolicy$5 is defined multiple times: obj\Debug\net6.0-android33.0\lp\189\jl\libs\ED64959F88B22E6D.jar:com/google/gson/FieldNamingPolicy$5.class, obj\Debug\net6.0-android33.0\lp\194\jl\libs\2C5D90B3B25D7C1F.jar:com/google/gson/FieldNamingPolicy$5.class
    1> at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:14)
    1> at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:22)
    1> at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:33)
    1> at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:10)
    1> at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
    1> at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:6)
    1> at com.android.tools.r8.graph.B2$a.e(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:4)
    1> at com.android.tools.r8.dex.b.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:105)
    1> at com.android.tools.r8.dex.b.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:28)
    1> at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:25)
    1> at com.android.tools.r8.D8.d(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:606)
    1> at com.android.tools.r8.D8.c(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:1)
    1> at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:24)
    1> ... 5 more
    1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.509\tools\Xamarin.Android.D8.targets(79,5): error : java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\net6.0-android33.0\lp\189\jl\libs\ED64959F88B22E6D.jar : com/google/gson/FieldNamingPolicy$5.class
    1>Done building project "MauiApp9.csproj" -- FAILED.

    My nuget package

    <PackageReference Include="Laerdal.Maui.AzureCommunicationHelper.android"> <Version>2.5.1-beta.3.2</Version> </PackageReference> <PackageReference Include="Xamarin.Android.Volley"> <Version>1.2.1.5</Version> </PackageReference> <PackageReference Include="Xamarin.AndroidX.Activity"> <Version>1.7.2.2</Version> </PackageReference> <PackageReference Include="Xamarin.AndroidX.Activity.Ktx"> <Version>1.7.2.2</Version> </PackageReference> <PackageReference Include="Xamarin.AndroidX.AppCompat"> <Version>1.6.1.4</Version> </PackageReference> <PackageReference Include="Xamarin.AndroidX.Lifecycle.Common"> <Version>2.6.2.1</Version> </PackageReference> <PackageReference Include="Xamarin.AndroidX.Lifecycle.Common.Java8"> <Version>2.6.2.1</Version> </PackageReference> <PackageReference Include="GoogleGson"> <Version>2.10.1.5</Version> </PackageReference> <PackageReference Include="Xamarin.AndroidX.Core" Version="1.12.0.1" /> <PackageReference Include="Xamarin.AndroidX.Camera.Lifecycle" Version="1.2.3.2" /> <PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.2.3.2" /> <PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.2.3.2" /> <PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.6.2.1" /> <PackageReference Include="Xamarin.AndroidX.Preference"> <Version>1.2.1.1</Version> </PackageReference> <PackageReference Include="Xamarin.AndroidX.Work.Runtime"> <Version>2.8.1.4</Version> </PackageReference> <PackageReference Include="Xamarin.Google.Guava.ListenableFuture" Version="1.0.0.15" /> <PackageReference Include="Xamarin.AndroidX.Concurrent.Futures" Version="1.1.0.15" /> <PackageReference Include="Xamarin.GooglePlayServices.Base"> <Version>118.2.0.2</Version> </PackageReference>

  21. tompi commented on Dec 18, 2023

    @tompi

    @andersonvieiragomeslopes I think this last issue was due to gson being included by multiple sources(one of them being the bound library). Try 2.6.0-beta.5.4 and see if it works(You need to target at least net7, and I dont think you should explicitly reference gson). @jpobst I think the original issue is fixed.

  22. jpobst commented on Mar 20, 2024

    @jpobst
    Contributor

    @jpobst I think the original issue is fixed.

    🎉

  23. locked and limited conversation to collaborators on Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: Android ResourcesIssues with Android Resources (aapt, etc)need-attentionA xamarin-android contributor needs to review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions