镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Android - APT2000 build error when project path contains non-ASCII symbols #6925

Open

Description

@Eilon

Originally opened by @janseris in dotnet/maui#5957


Description

Putting project in a folder/directory containing some non-ASCII chars, like Czech alphabet (tested with á) breaks Android build.
This does not affect any other C# projects. I have beeing using WinForms, Blazor, WPF on this path and all has been working fine for years.
Even VS Solution, folder names and class and property names can contain these special symbols fine.
It seems like the problem is in Android tools.
I have experienced these issues with C++ compilers and other UNIX tools which live in the ASCII-only world.

Severity	Code	Description	Project	File	Line	Suppression State
Error	APT2000	System cannot find file. (2).	Tempus.Mobile.GUI	C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-preview.14.106\tools\Xamarin.Android.Aapt2.targets	217	

image

Steps to Reproduce

Put project in any path containing "á" symbol.
I created a minimal repro with C:/á/ProjectFolder

Version with bug

Preview 14 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android

Did you find any workaround?

No response

Relevant log output

No response

Activity

  1. added this to the .NET 6 milestone on Apr 14, 2022
  2. jonathanpeppers commented on Apr 19, 2022

    @jonathanpeppers
    Member

    @janseris this works for me:

    mkdir 'testá' ; cd 'testá'
    dotnet new android
    dotnet build -bl
    

    If that doesn't work for you, can you attach the msbuild.binlog file that command creates? Thanks!

    I did find that Release builds fail, but different error:

    > dotnet build -c Release -bl
    ...
    C:\src\maui\bin\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.2.27\targets\Microsoft.Android.Sdk.Aot.targets(78,5): error : Precompiling failed for
     C:\src\testá\obj\Release\net6.0-android\android-arm\linked\testá.dll.
    

    Disabling AOT with -p:RunAOTCompilation=false works around this one. ^^

  3. janseris commented on Apr 19, 2022

    @janseris

    @jonathanpeppers confirmed your behavior on my machine as well.

    But for .NET MAUI the error still persists.

    APT2000.MAUI.MP4
  4. jonathanpeppers commented on Apr 19, 2022

    @jonathanpeppers
    Member

    @janseris can you build command line and share msbuild.binlog?

  5. janseris commented on Apr 19, 2022

    @janseris

    @jonathanpeppers can you please provide the command for CLI build for Android in MAUI? I am not familiar with that.
    Thank you

  6. jonathanpeppers commented on Apr 20, 2022

    @jonathanpeppers
    Member

    @janseris yes, it is above.

    Try making a folder named testá and cd into it:

    dotnet new android
    dotnet build -bl:debug.binlog
    dotnet build -c Release -bl:release.binlog
    

    These commands will create a debug.binlog and release.binlog, we can see what both Debug & Release do.

  7. janseris commented on Apr 21, 2022

    @janseris

    testá logs.zip

    However the commands you provided are not MAUI. They are some Android project commands (probably Xamarin) and they created an Android project, not MAUI.
    The APT2000 build error happens for MAUI projects.

  8. jonathanpeppers commented on Apr 21, 2022

    @jonathanpeppers
    Member

    @janseris can you do the same for dotnet new maui, then? Thanks!

  9. jonathanpeppers commented on Apr 21, 2022

    @jonathanpeppers
    Member

    I think it does reproduce with dotnet new maui and not dotnet new android:

    dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.2.27\tools\Xamarin.Android.Aapt2.targets(217,3): error APT2000: The system cannot find the file specified.
    
  10. janseris commented on Apr 21, 2022

    @janseris

    @jonathanpeppers yes that's it.
    Here is my output for building dotnet new maui template with the commands:
    testá MAUI.zip

  11. dellis1972 commented on Apr 21, 2022

    @dellis1972
    Contributor

    I think it does reproduce with dotnet new maui and not dotnet new android:

    dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.2.27\tools\Xamarin.Android.Aapt2.targets(217,3): error APT2000: The system cannot find the file specified.
    

    This may well be down to aapt2 . It is odd that certain characters are triggering this though. We do have unit tests specifically for accentent characters and they are passing.

  12. dellis1972 commented on Apr 21, 2022

    @dellis1972
    Contributor

    @janseris

    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?

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

  13. 16 remaining items

  14. jonathanpeppers commented on Jun 12, 2023

    @jonathanpeppers
    Member

    @BernhardPollerspoeck Xamarin ships a very old version of aapt2 that appears to be before Google introduced this issue.

    If you want to get the old version somehow, you can try setting $(Aapt2ToolPath) in your project:

    https://github.com/xamarin/xamarin-android/blob/4125c0ce14549623df7e860bf4ad67d0d9738aad/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Aapt2.targets#L132

  15. spanko commented on Mar 1, 2025

    @spanko

    aapt2 fails for file paths containing underscores as well

  16. dellis1972 commented on Mar 1, 2025

    @dellis1972
    Contributor

    @spanko are the underscores in the path above the project or in the Resources folder? Can you give an example?

  17. spanko commented on Mar 1, 2025

    @spanko
  18. dellis1972 commented on Mar 1, 2025

    @dellis1972
    Contributor

    Thats good to know thanks. I'll add a test for that. We can't "fix" it because the issue is upstream in one of google's tools.
    But we can log a better error message.

  19. LeDahu22 commented on Mar 14, 2025

    @LeDahu22

    Two days ago, we moved our Windows sessions to Azure Entra and I started having this issue when building in Release mode.

    The same day, I also updated VS to 17.13.3 version.

    I noticed that my account folder had a non-ASCII character in it, so I decided to move my repo on D drive (also using takeown to be the rightful owner of the directory)

    D:\Git\MyCompany\MyProduct\MyProduct.Mobile

    I moved it back to the root of C drive but it still happens.

    I also tried : dotnet workload repair

    It's strange because it was working perfectly before the latest VS Update + Entra migration.

    I don't know where the issue comes from ?

    • VS 17.13.3 regression ?
    • aapt bug ?
    • Some obscure right issue ?

    Unless the dot in the path is the culprit here ?

    Any help would be appreciated.

    Edit : looking at the build output, it's looking at my nuget package cache in my session folder (with non-ASCII character), could that be the issue ?

  20. dellis1972 commented on Mar 14, 2025

    @dellis1972
    Contributor

    @LeDahu22 we'd need a diagnostic build log to see what your specific issue is. See https://aka.ms/binlog for details on how to provide that.

    The path name should be in the error message though.

    For reference we added some new error messaging for this issue via #9809.

  21. LeDahu22 commented on Mar 14, 2025

    @LeDahu22

    Hi @dellis1972

    Here is my Release binlog (after reviewing it, it doesn't had much though)

    Edit : zip removed for privacy.

  22. janseris commented on Mar 14, 2025

    @janseris

    Two days ago, we moved our Windows sessions to Azure Entra and I started having this issue when building in Release mode.

    The same day, I also updated VS to 17.13.3 version.

    I noticed that my account folder had a non-ASCII character in it, so I decided to move my repo on D drive (also using takeown to be the rightful owner of the directory)

    D:\Git\MyCompany\MyProduct\MyProduct.Mobile

    I moved it back to the root of C drive but it still happens.

    I also tried : dotnet workload repair

    It's strange because it was working perfectly before the latest VS Update + Entra migration.

    I don't know where the issue comes from ?

    * VS 17.13.3 regression ?
    
    * aapt bug ?
    
    * Some obscure right issue ?
    

    Unless the dot in the path is the culprit here ?

    Any help would be appreciated.

    Edit : looking at the build output, it's looking at my nuget package cache in my session folder (with non-ASCII character), could that be the issue ?

    NuGet package cache has been a great serial killer of deterministic solution builds on new computers in our company. For example disabling/enabling package sources has no effects or when package is in two sources, Visual Studio does not find it at all. I suggest you definitely check the NuGet stuff

  23. LeDahu22 commented on Mar 14, 2025

    @LeDahu22

    @janseris I've also tried to move the cache location using the following in Nuget.config, but it didn't solve the root issue.

      <config>
        <add key="globalPackagesFolder" value="D:\NugetCache" />
      </config>
    
  24. dellis1972 commented on Mar 14, 2025

    @dellis1972
    Contributor

    @LeDahu22

    the log does not have the same error as this issue?

    C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.50\targets\Microsoft.Android.Sdk.Aot.targets(110,5): Precompiling failed for C:\Git\Novogen\NDC\NDC.Mobile\obj\Release\net9.0-android\android-arm64\linked\NDC.Constants.dll with exit code 1.
    The specified response file can not be read [C:\Git\Novogen\NDC\NDC.Mobile\NDC.Mobile.csproj]
    
  25. LeDahu22 commented on Mar 14, 2025

    @LeDahu22

    @dellis1972
    Well it might be a bit different now yes, but at first, I had the same issue as the one mentionned in this topic.

  26. dellis1972 commented on Mar 14, 2025

    @dellis1972
    Contributor

    We will need to open a new issue for that one.

  27. v-yanfw commented on Jul 18, 2025

    @v-yanfw

    Repro steps same as Eilon's bug, and error APT2265 when project path contains GB18030 string, error message: "error APT2265: This may be due to the project's file name or path containing non ASCII characters. For detailed information, please refer to https://learn.microsoft.com/dotnet/android/messages/apt2265."

    Testing Environment Confirmation
    • Ensure that the SimSun-ExtG font is installed on your Windows.
    • Make sure that the Windows display language and system locale are set to Chinese (Simplified, China):

    1. Go to Settings > Time & Language > Language & Region.
    2. If the Chinese (Simplified) language pack is not already installed, add it from the Language & Region settings UI.
    3. Change the display language to Simplified Chinese.
    4. Navigate to Administrative language settings and change the system locale to Chinese (Simplified, China).

    Repro steps:

    1. Create folder named as "唉", create a new sub folder named as "maui1".
    2. Go to the folder "maui1", run from command line: dotnet new maui
    3. run from command line: dotnet build

    Actually Result: error APT2265 appears:

    Image

    maui1 net10.0-android 失败,出现 1 错误 (46.5 秒) → bin\Debug\net10.0-android\maui1.dll
    C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\36.0.0-preview.6.169\tools\Xamarin.Android.Aapt2.targets(214,3): error APT2265: 这可能是由于项目的文件名或路径中包含非 ASCII 字符。有关详细信息,请参阅 https://learn.microsoft.com/dotnet/android/messages/apt2265。

  28. jonathanpeppers commented on Jul 18, 2025

    @jonathanpeppers
    Member

    For aapt2, we basically have to comment/upvote on Google's issue tracker.

    This is one issue I found, but there could be more related:

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.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions