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.93k stars 533 forks source link

net8.0-android34.0 - Deployment failed on Android device with error XABLD7023: Could not find a part of the path #9433

Closed JamestsaiTW closed 3 weeks ago

JamestsaiTW commented 1 month ago

Hello,

I tried again without any changes (or involuntarily...) and it works now... Sorry, I don’t know why.

Thank you for your attention.

Originally posted by @tobinfodata in #23796

The same issue also had occurred on my project, too.

XABLD7023: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\<mynugetsfolder>\microsoft.maui.controls.core\8.0.<xx>\lib
et8.0-android34.0\<localizationfolder>\shrunk\Microsoft.Maui.Controls.resources.dll'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Xamarin.Android.Tasks.MonoAndroidHelper.IsReferenceAssembly(String assembly)
   at Xamarin.Android.Tasks.BuildApk.<AddAssemblies>g__AddAssembliesFromCollection|160_0(ITaskItem[] assemblies, <>c__DisplayClass160_0& )
   at Xamarin.Android.Tasks.BuildApk.AddAssemblies(ZipArchiveEx apk, Boolean debug, Boolean compress, IDictionary`2 compressedAssembliesInfo, String assemblyStoreApkName)
   at Xamarin.Android.Tasks.BuildApk.ExecuteWithAbi(String[] supportedAbis, String apkInputPath, String apkOutputPath, Boolean debug, Boolean compress, IDictionary`2 compressedAssembliesInfo, String assemblyStoreApkName)
   at Xamarin.Android.Tasks.BuildApk.RunTask()
   at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25
Done building project "MyApp.csproj" -- FAILED.
Build FAILED.

My workaround is creating a folder naming "shrunk" on each localization folder and copy "Microsoft.Maui.Controls.resources.dll" from localization folder to "shrunk" folder.

After repeat above step for each localization folder, app's apk/aab can be archived successfully by Visual Studio.

PureWeen commented 1 month ago

Can you attach a logcat file with your crash? https://learn.microsoft.com/en-us/xamarin/android/deploy-test/debugging/android-debug-log?tabs=windows

@jonathanpeppers

jonathanpeppers commented 1 month ago

I think the error above is a build error, so a .binlog would help us investigate: https://aka.ms/binlog

JamestsaiTW commented 1 month ago

Hi @PureWeen and @jonathanpeppers,

I can build my project successfully, and it can deploy to android device or simulator by using Visaul Studio. My problem is "It can't archive and sign apk or abb successfully.", so I can't upload my new version app to Google Play Console.

I notice there is something odd about the nuget library of Microsoft.Maui.Controls.Core at Nuget Folder.

For my case: The 8.0.82 and 8.0.90 version folder is correct: Image
and it can archive my app successfully.

The 8.0.91 version folder is wrong: Image
and it can't archive my app.


I also try to create a new .net maui app by the .net maui template of Visual Studio and update the Microsoft.Maui.Controls.Core version to 8.0.91. It can archive apk and aab successfully.

After I had archived by new project, I notice the nuget folder of version 8.0.91 for "Microsoft.Maui.Controls.Core" becomes the correct structure.

I also can archive my project.

But...if I delete the nugets folder of version 8.0.91 for "Microsoft.Maui.Controls.Core", it can't archive my project again.

jonathanpeppers commented 1 month ago

Can you share a .binlog of where it is writing to C:\<mynugetsfolder>\microsoft.maui.controls.core\8.0.<xx>\lib\net8.0-android34.0\<localizationfolder>\shrunk\? https://aka.ms/binlog

If it works fine in a project template, it must be something about your settings in this specific app.

dotnet-policy-service[bot] commented 1 month ago

Hi @JamestsaiTW. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

dotnet-policy-service[bot] commented 3 weeks ago

Hi @JamestsaiTW. Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you.