Skip to content

Android - APT2000 build error when maui-blazor #7639

Description

@skoc10

Android application type

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

Affected platform version

.NET 7.0.100

Description

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.4\tools\Xamarin.Android.Aapt2.targets(212,3): error APT2000: The system cannot find the file specified. (2). [D:\ci\Jenkins\workspace\abp-commercial-nightly\volo\abp\templates\app-pro\aspnet-core\src\MyCompanyName.MyProjectName.MauiBlazor\MyCompanyName.MyProjectName.MauiBlazor.csproj::TargetFramework=net7.0-android]

image

I am facing this error when build Maui-Blazor project.
I updated all related SDK but problem continues.
This issue is not related #6925.

Steps to Reproduce

dotnet new maui-blazor
dotnet build

Did you find any workaround?

No response

Relevant log output

No response

Activity

  1. added
    Area: App+Library BuildIssues when building Library projects or Application projects.
    needs-triageIssues that need to be assigned.
    on Dec 15, 2022
  2. dellis1972 commented on Dec 15, 2022

    @dellis1972
    Contributor

    @skoc10

    As per the other bug can you add the following to your project

    <AndroidAapt2LinkExtraArgs>$(AndroidAapt2LinkExtraArgs) -v</AndroidAapt2LinkExtraArgs>
    

    then build (from clean) on the command line again and post the logs? We need the binlog file
    so you need to run

    dotnet build MyCompanyName.MyProjectName.MauiBlazor.csproj -bl
    

    This will give us more verbose aapt2 output. It should help narrow down which file is causing the error.

    On a side note, the path you have D:\ci\Jenkins\workspace\abp-commercial-nightly\volo\abp\templates\app-pro\aspnet-core\src\MyCompanyName.MyProjectName.MauiBlazor\MyCompanyName.MyProjectName.MauiBlazor.csproj might cause some issues on windows. Windows has a max command line length which you might hit when building release builds with aot.

  3. added
    need-infoIssues that need more information from the author.
    and removed
    needs-triageIssues that need to be assigned.
    on Dec 15, 2022
  4. skoc10 commented on Dec 15, 2022

    @skoc10
    Author
  5. ghost removed
    need-infoIssues that need more information from the author.
    on Dec 15, 2022
  6. ghost added
    need-attentionA xamarin-android contributor needs to review
    on Dec 15, 2022
  7. dellis1972 commented on Dec 15, 2022

    @dellis1972
    Contributor

    @skoc10

    I'm not seeing anyting obvious in the logs. aapt2 is raising that error, but its not reporting which file it cannot find.
    I will try to repo here (not luck so far).

    Are you getting this on a maui-blazor template? If so can you zip up the entire project and attach it to this issue please?

  8. added
    need-infoIssues that need more information from the author.
    and removed
    need-attentionA xamarin-android contributor needs to review
    on Dec 15, 2022
  9. ebicoglu commented on Dec 16, 2022

    @ebicoglu

    this problem is related to Windows long path. but the error message that aapt2 is rasing is not clear. developers can easily fall into this issue, so we should find a way to expose this exception.

  10. ghost removed
    need-infoIssues that need more information from the author.
    on Dec 16, 2022
  11. ghost added
    need-attentionA xamarin-android contributor needs to review
    on Dec 16, 2022
  12. dellis1972 commented on Dec 16, 2022

    @dellis1972
    Contributor

    It might also be worth looking at some of the suggestions in https://learn.microsoft.com/en-us/xamarin/android/troubleshooting/questions/path-too-long-exception and see if they work.

    Setting a shorter BaseIntermediateOutputPath (and leaving the project where it is) might also help.
    You will need to place this in a Directory.Build.props file next to your project/solution.

    <Project>
      <PropertyGroup>
          <BaseIntermediateOutputPath Condition=" '$(OS)' == 'Windows_NT' ">C:\Intermediate\$(ProjectName)</BaseIntermediateOutputPath>
          <BaseIntermediateOutputPath Condition=" '$(OS)' != 'Windows_NT' ">/tmp/Intermediate/$(ProjectName)</BaseIntermediateOutputPath>
      </PropertyGroup>
    </Project>
    
  13. skoc10 commented on Dec 16, 2022

    @skoc10
    Author

    It might also be worth looking at some of the suggestions in https://learn.microsoft.com/en-us/xamarin/android/troubleshooting/questions/path-too-long-exception and see if they work.

    Setting a shorter BaseIntermediateOutputPath (and leaving the project where it is) might also help. You will need to place this in a Directory.Build.props file next to your project/solution.

    <Project>
      <PropertyGroup>
          <BaseIntermediateOutputPath Condition=" '$(OS)' == 'Windows_NT' ">C:\Intermediate\$(ProjectName)</BaseIntermediateOutputPath>
          <BaseIntermediateOutputPath Condition=" '$(OS)' != 'Windows_NT' ">/tmp/Intermediate/$(ProjectName)</BaseIntermediateOutputPath>
      </PropertyGroup>
    </Project>
    

    Thanks. Directory.Build.props file worked!

  14. dellis1972 commented on Dec 16, 2022

    @dellis1972
    Contributor

    Excelent.

    While we cannot fix the error in aapt2 I did open a PR which should improve the error messaging a bit #7644.

  15. ghost locked as resolved and limited conversation to collaborators on Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.need-attentionA xamarin-android contributor needs to review

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions