Skip to content

Android ELF issues on MacOSX Sequoia #10506

@gsmiro

Description

@gsmiro

Description

Building a MAUI app targeting net9.0-android generates an app that crashes every time. During compilation, the following messages are generated

dotnet build -f net9.0-android --no-incremental
  NexumInsights net9.0-android êxito(s) com 4 aviso(s) (77,7s) → bin/Debug/net9.0-android/NexumInsights.dll
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/35.0.101/tools/Xamarin.Android.Common.targets(2208,2): warning : Attempt to check whether 'obj/Debug/net9.0-android/app_shared_libraries/arm64-v8a/libxamarin-app.so' is a correctly aligned ELF file failed with exception, ignoring alignment check for the file.
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/35.0.101/tools/Xamarin.Android.Common.targets(2208,2): warning : 
      Given stream is not a proper ELF file.
         at ELFSharp.ELF.ELFReader.Load(Stream stream, Boolean shouldOwnStream)
         at ELFSharp.ELF.ELFReader.Load(String fileName)
         at Xamarin.Android.Tasks.ELFHelper.AssertValidLibraryAlignment(TaskLoggingHelper log, Int32 alignmentInPages, String path, ITaskItem item) in /Use
      rs/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/ELFHelper.cs:line 29
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/35.0.101/tools/Xamarin.Android.Common.targets(2208,2): warning : Attempt to check whether 'obj/Debug/net9.0-android/app_shared_libraries/x86_64/libxamarin-app.so' is a correctly aligned ELF file failed with exception, ignoring alignment check for the file.
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/35.0.101/tools/Xamarin.Android.Common.targets(2208,2): warning : 
      Given stream is not a proper ELF file.
         at ELFSharp.ELF.ELFReader.Load(Stream stream, Boolean shouldOwnStream)
         at ELFSharp.ELF.ELFReader.Load(String fileName)
         at Xamarin.Android.Tasks.ELFHelper.AssertValidLibraryAlignment(TaskLoggingHelper log, Int32 alignmentInPages, String path, ITaskItem item) in /Use
      rs/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/ELFHelper.cs:line 29
Construir êxito(s) com 4 aviso(s) em 78,6s

in adb logcat i find the following

9-21 12:42:58.952  6229  6229 D nativeloader: Load /data/app/~~x0-xZdzpR2HummQiTe1Z8g==/com.nexum.nexuminsights-SLtbz76QGPcCcR_qDuqX3Q==/lib/arm64/libmonosgen-2.0.so using ns clns-7 from class loader (caller=/data/app/~~x0-xZdzpR2HummQiTe1Z8g==/com.nexum.nexuminsights-SLtbz76QGPcCcR_qDuqX3Q==/base.apk!classes2.dex): ok
09-21 12:42:58.954  6229  6229 D nativeloader: Load /data/app/~~x0-xZdzpR2HummQiTe1Z8g==/com.nexum.nexuminsights-SLtbz76QGPcCcR_qDuqX3Q==/lib/arm64/libxamarin-app.so using ns clns-7 from class loader (caller=/data/app/~~x0-xZdzpR2HummQiTe1Z8g==/com.nexum.nexuminsights-SLtbz76QGPcCcR_qDuqX3Q==/base.apk!classes2.dex): dlopen failed: "/data/app/~~x0-xZdzpR2HummQiTe1Z8g==/com.nexum.nexuminsights-SLtbz76QGPcCcR_qDuqX3Q==/lib/arm64/libxamarin-app.so" has bad ELF magic: 00000000
09-21 12:42:58.956  5191  5191 E A       : onError
09-21 12:42:58.956  5191  5191 E A       : com.google.android.apps.gsa.shared.speech.b.l: errorCode: 65561, engine: 2
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.staticplugins.bp.a.f.a(PG:23)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.s3.o.hg(PG:13)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.ch.g.a.f.e(PG:9)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.speech.k.a.g.d(PG:162)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.speech.k.a.g.iN(PG:26)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.s3.p.c(PG:102)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.s3.q.run(PG:1)
09-21 12:42:58.956  5191  5191 E A       :      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
09-21 12:42:58.956  5191  5191 E A       :      at java.util.concurrent.FutureTask.run(FutureTask.java:264)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.shared.util.c.a.e.run(PG:12)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.shared.util.c.a.bg.run(PG:3)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.shared.util.c.a.bg.run(PG:3)
09-21 12:42:58.956  5191  5191 E A       :      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
09-21 12:42:58.956  5191  5191 E A       :      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
09-21 12:42:58.956  5191  5191 E A       :      at java.lang.Thread.run(Thread.java:1012)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.shared.util.c.a.l.run(PG:42)
09-21 12:42:58.956  5191  5191 E A       : Caused by: com.google.android.apps.gsa.shared.speech.b.n: errorCode: 65586, engine: 2
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.s3.o.hg(PG:6)
09-21 12:42:58.956  5191  5191 E A       :      ... 14 more
09-21 12:42:58.956  5191  5191 E A       : Caused by: com.google.android.apps.gsa.shared.speech.b.j: errorCode: 401, engine: 2
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.assistant.shared.n.i.b(PG:30)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.s3.producers.j.hq(PG:11)
09-21 12:42:58.956  5191  5191 E A       :      at com.google.android.apps.gsa.speech.k.a.g.d(PG:135)
09-21 12:42:58.956  5191  5191 E A       :      ... 12 more
09-21 12:42:58.956  5191  5191 W A       : Failed to sync device settings.
09-21 12:42:58.956  5191  5191 I A       : Retrying to sync device settings.
09-21 12:42:58.957  6229  6229 D AndroidRuntime: Shutting down VM
09-21 12:42:58.960  6229  6229 E AndroidRuntime: FATAL EXCEPTION: main
09-21 12:42:58.960  6229  6229 E AndroidRuntime: Process: com.nexum.nexuminsights, PID: 6229
09-21 12:42:58.960  6229  6229 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/~~x0-xZdzpR2HummQiTe1Z8g==/com.nexum.nexuminsights-SLtbz76QGPcCcR_qDuqX3Q==
/lib/arm64/libxamarin-app.so" has bad ELF magic: 00000000

The app gets deployed to the android simulator but crashes when opening it.

MacBook Pro 13" M1 2020

  • Host: macOS Sequoia 15.6.1 (Apple Silicon)
  • IDE: VS Code 1.104.0
  • Framework: .NET 9
  • Targets: Android 15 + iOS 18.6
dotnet --info
.NET SDK:
 Version:           9.0.305
 Commit:            3fc74f3529
 Workload version:  9.0.300-manifests.993c7b89
 MSBuild version:   17.14.21+8929ca9e3

Ambiente de runtime:
 OS Name:     Mac OS X
 OS Version:  15.6
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/9.0.305/

Cargas de trabalho do .NET instaladas:
 [maui-android]
   Origem da Instalação: SDK 9.0.300
   Versão do Manifesto:    9.0.82/9.0.100
   Caminho do Manifesto:       /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maui/9.0.82/WorkloadManifest.json
   Tipo de Instalação:        FileBased

 [maui]
   Origem da Instalação: SDK 9.0.300
   Versão do Manifesto:    9.0.82/9.0.100
   Caminho do Manifesto:       /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maui/9.0.82/WorkloadManifest.json
   Tipo de Instalação:        FileBased

Configurado para usar loose manifests ao instalar novos manifestos.

Host:
  Version:      9.0.9
  Architecture: arm64
  Commit:       893c2ebbd4

.NET SDKs installed:
  9.0.305 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  x64   [/usr/local/share/dotnet/x64]

Environment variables:
  Not set

global.json file:
  Not found
sdkmanager --list_installed
[=======================================] 100% Fetch remote repository...       
Installed packages:
  Path                                                           | Version | Description                         | Location                                                      
  -------                                                        | ------- | -------                             | -------                                                       
  build-tools;30.0.3                                             | 30.0.3  | Android SDK Build-Tools 30.0.3      | build-tools/30.0.3                                            
  cmdline-tools;5.0                                              | 5.0     | Android SDK Command-line Tools      | cmdline-tools/5.0                                             
  emulator                                                       | 36.1.9  | Android Emulator                    | emulator                                                      
  patcher;v4                                                     | 1       | SDK Patch Applier v4                | patcher/v4                                                    
  platform-tools                                                 | 36.0.0  | Android SDK Platform-Tools          | platform-tools                                                
  platforms;android-35                                           | 2       | Android SDK Platform 35             | platforms/android-35                                          
  system-images;android-35-ext14;google_apis_playstore;arm64-v8a | 1       | Google Play ARM 64 v8a System Image | system-images/android-35-ext14/google_apis_playstore/arm64-v8a

Steps to Reproduce

  1. Create a MAUI project on VSCode using the MAUI extensions suggested steps
  2. Change platform targets to net9.0-ios,net9.0-android
  3. run attached script run-android.sh: starts the emulator and installs the app
  4. open the app on the emulator

[Project .csproj

sh used to build and load app

](https://github.com/user-attachments/files/22453340/NexumInsights.-.copia_csproj.txt)

Link to public reproduction project repository

No response

Version with bug

9.0.100 SR10

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 15

Did you find any workaround?

No. I tried to rebuild the workloads and also downgrade to android 34, but the current version only allows 35 and 36.

Relevant log output

Metadata

Metadata

Assignees

Labels

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