Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Cannot find libmonosgen-2.0.so when including generated .aar file into Android Studio #785

Open
datoml opened this issue Nov 20, 2020 · 1 comment
Milestone

Comments

@datoml
Copy link

datoml commented Nov 20, 2020

Steps to Reproduce

  1. Build a simple .net standard library with a Greeting method.
  2. Run embeddinator with the following command Embeddinator-4000.exe bin\Release\ClassLibrary.dll --gen=Java --platform=Android --outdir=androidoutput -c
  3. Import the generated AAR file into Android Studio
  4. Add the newly generated project as dependency implementation project(':ClassLibrary')
  5. Run the project and deploy it to your Android phone

Expected Behavior

App should start and methods from the AAR should be useable in Java code.

Actual Behavior

Application is crashing during the start because libmonosgen-2.0.so could not be found.

A/monodroid: cannot find libmonosgen-2.0.so in app_libdir: /data/app/com.example.myapplication-ASOprlzzZzqQRUEvuPcnfQ==/lib/arm64 nor in previously printed locations.
    Do you have a shared runtime build of your app with AndroidManifest.xml android:minSdkVersion < 10 while running on a 64-bit Android 5.0 target? This combination is not supported.
    Please either set android:minSdkVersion >= 10 or use a build without the shared runtime (like default Release configuration).

Environment

OS: Windows 10 - 1809
Visual Studio 2019
Embeddinator-4000 version 0.4.0 via nuget
CompileSdkVersion: 30
BuildToolsVersion "30.0.2"
NDKVersion: R21

Did I miss something during setting up the project in Android Studio?
Thank you in advance.

@datoml
Copy link
Author

datoml commented Nov 20, 2020

Update
What I found out so far to make it work.
You need to have Android NDK 15 to be able to compile an AAR.
All versions later will result in compile errors.

Then import the generated AAR in Android Studio as a new module.
Go to the Android manifest and set this option:
android:extractNativeLibs="true"

This makes the libmonosgen-2.0.so available for your application.

The final step is to go to your app's build.gradle and add

    aaptOptions {
        noCompress 'dll'
    }

@rolfbjarne rolfbjarne added this to the Future milestone Dec 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants