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 529 forks source link

Android app is not building on Linux - .NET MAUI 9 RC1 #9296

Closed egvijayanand closed 1 month ago

egvijayanand commented 1 month ago

Description

Android app is not building on Linux - .NET MAUI RC1.

Ends up with some weird error message.

Steps to Reproduce

  1. Ensure MAUI Android workload is installed on Linux
  2. Create a new .NET MAUI app on Linux
  3. Build the app targeting the Android platform
  4. Build fails with weird error messages (Refer to the log output for details)

Link to public reproduction project repository

Default template itself is suffice, no authored code

Version with bug

9.0.0-rc.1.24453.9

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.0-preview.6.24327.7

Affected platforms

Android

Affected platform versions

Android 35.0

Did you find any workaround?

Nope.

Relevant log output

dotnet build -f net9.0-android Command output.

Restore complete (0.5s)
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  MauiApp9 failed with 1 error(s) (4.5s)
    /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/35.0.0-rc.1.80/tools/Xamarin.Android.EmbeddedResource.targets(39,5): error XARLP7000:
      System.DllNotFoundException: Unable to load shared library 'libZipSharpNative-3-3' or one of its dependencies. In order to help
       diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment
       variable:
      /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0-rc.1.24431.7/libZipSharpNative-3-3.so: cannot open shared object file: No
      such file or directory
      /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linu
      x/35.0.0-rc.1.80/tools/libZipSharpNative-3-3.so)
      /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0-rc.1.24431.7/liblibZipSharpNative-3-3.so: cannot open shared object file:
      No such file or directory
      /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/35.0.0-rc.1.80/tools/liblibZipSharpNative-3-3.so: cannot open shared object
       file: No such file or directory
      /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0-rc.1.24431.7/libZipSharpNative-3-3: cannot open shared object file: No suc
      h file or directory
      /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/35.0.0-rc.1.80/tools/libZipSharpNative-3-3: cannot open shared object file:
       No such file or directory
      /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0-rc.1.24431.7/liblibZipSharpNative-3-3: cannot open shared object file: No
      such file or directory
      /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/35.0.0-rc.1.80/tools/liblibZipSharpNative-3-3: cannot open shared object fi
      le: No such file or directory

         at Xamarin.Tools.Zip.Native.zip_open(IntPtr path, OpenFlags flags, ErrorCode& errorp)
         at Xamarin.Tools.Zip.Native.zip_open(String path, OpenFlags flags, ErrorCode& errorp) in /Users/runner/work/1/s/LibZipSharp/
      Xamarin.Tools.Zip/Native.cs:line 162
         at Xamarin.Tools.Zip.ZipArchive.Open(String path, OpenFlags flags) in /Users/runner/work/1/s/LibZipSharp/Xamarin.Tools.Zip/Z
      ipArchive.cs:line 187
         at Xamarin.Tools.Zip.ZipArchive.Open(String path, FileMode mode, String defaultExtractionDir, Boolean strictConsistencyCheck
      s, IPlatformOptions options) in /Users/runner/work/1/s/LibZipSharp/Xamarin.Tools.Zip/ZipArchive.cs:line 267
         at Microsoft.Android.Build.Tasks.Files.ReadZipFile(String filename, Boolean strictConsistencyChecks) in /mnt/vss/_work/1/s/x
      amarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/Files.cs:line 335
         at Xamarin.Android.Tasks.MonoAndroidHelper.ReadZipFile(String filename) in /mnt/vss/_work/1/s/xamarin-android/src/Xamarin.An
      droid.Build.Tasks/Utilities/MonoAndroidHelper.cs:line 361
         at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(IDictionary`2 jars, ICollection`1 resolvedResourceDirectories,
       ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments, ICollection`1 proguardConfigFiles) in /mnt/vss/_wo
      rk/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs:line 396
         at Xamarin.Android.Tasks.ResolveLibraryProjectImports.RunTask() in /mnt/vss/_work/1/s/xamarin-android/src/Xamarin.Android.Bu
      ild.Tasks/Tasks/ResolveLibraryProjectImports.cs:line 95
         at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /mnt/vss/_work/1/s/xamarin-android/external/xamarin-android-tools/
      src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25

Build failed with 1 error(s) in 5.7s
github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

egvijayanand commented 1 month ago

It builds successfully on .NET 8. The issue is only with .NET 9.

dellis1972 commented 1 month ago

can you do a find in /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/35.0.0-rc.1.80/tools/ and look for libZipSharpNative ?

If it is there. can you run ldd on it and make sure it has all its dependencies.

dellis1972 commented 1 month ago

ah there it is. /lib/x86_64-linux-gnu/libc.so.6: versionGLIBC_2.33'` your libc is not up to date or does not match.

egvijayanand commented 1 month ago

ah there it is. /lib/x86_64-linux-gnu/libc.so.6: versionGLIBC_2.33'` your libc is not up to date or does not match.

So what's the resolution? And which one to update?

grendello commented 1 month ago

@egvijayanand what Linux distribution do you use?

jonpryor commented 1 month ago

@egvijayanand: Please see also: https://github.com/dotnet/runtime/blob/main/docs/design/features/y2038.md

https://github.com/dotnet/android-libzipsharp uses time_t based members, and to begin addressing the Year 2038 Problem, it now assumes 64-bit time_t values. The use of 64-bit time_t values requires a newer GLibC.

If at all possible, update your Linux distribution to something that uses 64-bit time_t values.

egvijayanand commented 1 month ago

Have upgraded my Ubuntu from ver. 20.04 to ver. 22.04. Then the build issue was resolved.

Thanks for your support. This ticket can be marked as resolved.