Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin Android 9.4.99.22 couldn't load 64-bit libjnigraphics.so library #3096

Closed
bksingapore90 opened this issue May 15, 2019 · 6 comments
Closed
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.

Comments

@bksingapore90
Copy link

bksingapore90 commented May 15, 2019

Steps to Reproduce

  1. Install Xamarin Android 9.4.99.22 here on mac os : https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/519/Azure/)
  2. Make android app bundle format (*.aab)
  3. use .aab file to install on 64-bit supported device.

p/s : I'm trying alpha version Xamarin Android 9.4.99.22 to use Android App Bundle . Maybe above issue is a problem in alpha version but I would like to know how to fix. thank you !

Expected Behavior

The lib libjnigraphics.so should be loaded in /system/lib64/

Actual Behavior

[Mono] DllImport error loading library '/system/lib/libjnigraphics.so': 'dlopen failed: "/system/lib/libjnigraphics.so" is 32-bit instead of 64-bit'.

The lib libjnigraphics.so was loaded in /system/lib/.
This is 32-bit version , exception happens and app is terminated

Version Information

Visual Studio Professional 2019 for Mac
Version 8.0.5 (build 9)
Installation UUID: ba84b1c5-7178-423e-a5b4-44326c73b523
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.6.0.2 (d16-0 / 040682909)

Package version: 600000006

Mono Framework MDK
Runtime:
Mono 6.0.0.6 (2019-02/12cadb2b21d) (64-bit)
Package version: 600000006

NuGet
Version: 4.8.2.5835

.NET Core
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.9
2.1.8
2.1.7
2.1.2
2.1.1
2.0.5
1.1.2
1.1.1
1.0.5
1.0.4
SDK: /usr/local/share/dotnet/sdk/2.1.505/Sdks
SDK Versions:
2.1.505
2.1.504
2.1.503
2.1.302
2.1.301
2.1.4
1.0.4
1.0.3
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.0.0/lib/mono/msbuild/15.0/bin/Sdks

Xamarin.Profiler
Version: 1.6.9
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode 10.2.1 (14490.122)
Build 10E1001

Xamarin.Mac
Version: 5.8.0.0 (Visual Studio Professional)
Hash: 0aa84521
Branch: d16-0
Build date: 2019-04-02 16:01:19-0400

Xamarin.iOS
Version: 12.8.0.2 (Visual Studio Professional)
Hash: f2248ae6
Branch: d16-0
Build date: 2019-04-23 11:59:04-0400

Xamarin Designer
Version: 4.17.4.418
Hash: 3d086e814
Branch: remotes/origin/d16-0
Build date: 2019-04-01 09:20:10 UTC

Xamarin.Android
Version: 9.4.99.23 (Visual Studio Professional)
Android SDK: /Users/thanhlinh9191/Library/Android/sdk
Supported Android versions:
5.0 (API level 21)
6.0 (API level 23)
7.1 (API level 25)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.2
SDK Build Tools Version: 28.0.2

Build Information:
Mono: mono/mono@d04d534d113
Java.Interop: xamarin/java.interop/master@fd77553
LibZipSharp: grendello/LibZipSharp/master@caa0c74
LibZip: nih-at/libzip@b95cf3f
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/master@4f717b6

Microsoft Mobile OpenJDK
Java SDK: /Users/thanhlinh9191/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android Device Manager
Version: 1.2.0.14
Hash: 86df26f
Branch: remotes/origin/d16-0
Build date: 2019-04-05 16:58:56 UTC

Xamarin Inspector
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

Build Information
Release ID: 800050009
Git revision: d9d7eed60cb59740ba55c04bfe9c39ac57014c12
Build date: 2019-04-26 10:08:19+00
Build branch: master
Xamarin extensions: 5efedb990d786142d3b54351c01ce867af7b7680

Operating System
Mac OS X 10.14.3
Darwin 18.2.0 Darwin Kernel Version 18.2.0
Thu Dec 20 20:46:53 PST 2018
root:xnu-4903.241.1~1/RELEASE_X86_64 x86_64

Log File

[Choreographer] Skipped 133 frames! The application may be doing too much work on its main thread.
[Mono] DllImport attempting to load: 'libjnigraphics.so'.
[Mono] DllImport error loading library './libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library './libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library './libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library '/system/lib/libjnigraphics.so': 'dlopen failed: "/system/lib/libjnigraphics.so" is 32-bit instead of 64-bit'.
[Mono] DllImport error loading library '/system/lib/libjnigraphics.so': 'dlopen failed: "/system/lib/libjnigraphics.so" is 32-bit instead of 64-bit'.
[Mono] DllImport error loading library '/system/lib/libjnigraphics.so': 'dlopen failed: "/system/lib/libjnigraphics.so" is 32-bit instead of 64-bit'.
[Mono] DllImport error loading library 'libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library 'libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library 'libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library 'libjnigraphics.so': '(null)'.
[Mono] DllImport unable to load library '(null)'.
[Mono] DllImport attempting to load: 'libjnigraphics.so'.
[Mono] DllImport error loading library './libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library './libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library './libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library '/system/lib/libjnigraphics.so': 'dlopen failed: "/system/lib/libjnigraphics.so" is 32-bit instead of 64-bit'.
[Mono] DllImport error loading library '/system/lib/libjnigraphics.so': 'dlopen failed: "/system/lib/libjnigraphics.so" is 32-bit instead of 64-bit'.
[Mono] DllImport error loading library '/system/lib/libjnigraphics.so': 'dlopen failed: "/system/lib/libjnigraphics.so" is 32-bit instead of 64-bit'.
[Mono] DllImport error loading library 'libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library 'libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library 'libjnigraphics.so': '(null)'.
[Mono] DllImport error loading library 'libjnigraphics.so': '(null)'.
[Mono] DllImport unable to load library '(null)'.
Thread finished: #2
Thread finished: #21
Thread finished: #18
Thread finished: #26
Thread finished: #17
Thread started: #28
[Mono] DllImport attempting to load: '/system/lib64/liblog.so'.
[Mono] DllImport loaded library '/system/lib64/liblog.so'.
[Mono] DllImport searching in: '/system/lib64/liblog.so' ('/system/lib64/liblog.so').
[Mono] Searching for '__android_log_print'.
[Mono] Probing '__android_log_print'.
[Mono] Found as '_android_log_print'.
Thread started: #29
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.DllNotFoundException: libjnigraphics.so
[MonoDroid] at (wrapper managed-to-native) Android.Runtime.JNIEnv.AndroidBitmap_lockPixels(intptr,intptr,intptr&)
[MonoDroid] at Android.Runtime.JNIEnv.AndroidBitmap_lockPixels (System.IntPtr jbitmap, System.IntPtr& addrPtr) [0x00000] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:2069
[MonoDroid] at Android.Graphics.Bitmap.LockPixels () [0x00000] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Mono.Android/Android.Graphics/Bitmap.cs:44
[MonoDroid] at SkiaSharp.Views.Android.SKCanvasView.OnDraw (Android.Graphics.Canvas canvas) [0x000ae] in :0
[MonoDroid] at Android.Views.View.n_OnDraw_Landroid_graphics_Canvas
(System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_canvas) [0x00011] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Mono.Android/obj/Release/android-28/mcw/Android.Views.View.cs:16062
[MonoDroid] at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.101(intptr,intptr,intptr)
Thread started: #30
[art] JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_throw'.
[Mono] Probing 'java_interop_jnienv_throw'.
[Mono] Found as 'java_interop_jnienv_throw'.
[MonoDroid] UNHANDLED EXCEPTION:

@bksingapore90 bksingapore90 changed the title use android app bundle , Xamarin anroid Xamarin Android 9.4.99.22 could load correct 64-bit .so library use android app bundle , Xamarin Android 9.4.99.22 could load correct 64-bit .so library May 15, 2019
@bksingapore90 bksingapore90 changed the title use android app bundle , Xamarin Android 9.4.99.22 could load correct 64-bit .so library use android app bundle , Xamarin Android 9.4.99.22 couldn't load correct 64-bit .so library May 17, 2019
@grendello grendello added the Area: App+Library Build Issues when building Library projects or Application projects. label May 20, 2019
@grendello grendello added this to the Under Consideration milestone May 20, 2019
@jonathanpeppers
Copy link
Member

Hi @bksingapore90,

Do you know where this native library is coming from? How is it added to your project?

[Mono] DllImport error loading library '/system/lib/libjnigraphics.so': 'dlopen failed: "/system/lib/libjnigraphics.so" is 32-bit instead of 64-bit'.

Is it coming from a NuGet package or an AndroidNativeLibrary in your project?

In the meantime, I'll try to repro this myself. I can probably use any sample with a native library: sqlite or something.

@jonathanpeppers
Copy link
Member

SQLite-Net seemed to work fine: master...jonathanpeppers:bundletool-nativelibraries

It looks like your stacktrace started with SkiaSharp:

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.DllNotFoundException: libjnigraphics.so
[MonoDroid] at (wrapper managed-to-native) Android.Runtime.JNIEnv.AndroidBitmap_lockPixels(intptr,intptr,intptr&)
[MonoDroid] at Android.Runtime.JNIEnv.AndroidBitmap_lockPixels (System.IntPtr jbitmap, System.IntPtr& addrPtr) [0x00000] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:2069
[MonoDroid] at Android.Graphics.Bitmap.LockPixels () [0x00000] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Mono.Android/Android.Graphics/Bitmap.cs:44
[MonoDroid] at SkiaSharp.Views.Android.SKCanvasView.OnDraw (Android.Graphics.Canvas canvas) [0x000ae] in :0
[MonoDroid] at Android.Views.View.n_OnDraw_Landroid_graphics_Canvas (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_canvas) [0x00011] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Mono.Android/obj/Release/android-28/mcw/Android.Views.View.cs:16062
[MonoDroid] at (wrapper dynamic-method) 

I'll try a SkiaSharp sample next.

@jonathanpeppers
Copy link
Member

jonathanpeppers commented May 21, 2019

Ok, I can reproduce the problem with this sample: https://github.com/mono/SkiaSharp/tree/master/samples/Basic/Android/SkiaSharpSample
(I just changed it to use the NuGet instead of building SkiaSharp from source: SkiaSharpSample.zip)

@bksingapore90 it seems like I can see the problem with APKs, too? Seems like it isn't anything to do with app bundles, it's just happening with latest xamarin-android/master?

@bksingapore90
Copy link
Author

bksingapore90 commented May 22, 2019

Do you know where this native library is coming from? How is it added to your project?

yes, in my case . it happens with Skiasharp library.
but simply , you can reproduce with this code in Xamarin.Android project (this code will load libjnigraphics.so - this is Android library available on device , I don't add it manually)

var bitmap = Android.Graphics.Bitmap.CreateBitmap(500, 500, Android.Graphics.Bitmap.Config.Argb8888);
bitmap.LockPixels();

@bksingapore90 it seems like I can see the problem with APKs, too? Seems like it isn't anything to do with app bundles, it's just happening with latest xamarin-android/master?

@jonathanpeppers yes, in furthermore investigation , I see it seems the problem is not in app bundle process. It is the problem with latest xamarin-android/master itself.
When you run debug (when aapt2 is enabled ) with above code, the problem still happens

@jonathanpeppers jonathanpeppers changed the title use android app bundle , Xamarin Android 9.4.99.22 couldn't load correct 64-bit .so library Xamarin Android 9.4.99.22 couldn't load 64-bit libjnigraphics.so library May 22, 2019
@jonathanpeppers
Copy link
Member

This is odd, I can add this test to Mono.Android-Tests.csproj and it works:

public void LockPixels ()
{
    var bitmap = Bitmap.CreateBitmap (500, 500, Bitmap.Config.Argb8888);
    bitmap.LockPixels ();
}

But if I add the code to a new project, I'm seeing the crash: BitmapTest.zip

@jonathanpeppers
Copy link
Member

@bksingapore90 this should be fixed by: #3117

Give latest build from master a shot, and let us know. Thanks a lot, you helped us fix this before we shipped!

@ghost ghost locked as resolved and limited conversation to collaborators Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

No branches or pull requests

3 participants