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

Support DSOs embedded in the .apk #2154

Merged
merged 2 commits into from
Sep 17, 2018
Merged

Commits on Sep 15, 2018

  1. Support DSOs embedded in the APK

    Context: dotnet#1906
    Fixes: dotnet#1906
    
    Android API 23 introduced a new way of dealing with the native shared libraries
    shipped in the APK. Before that API level, the libraries would be always
    extraced and placed in the application data directory, thus occupying more space
    than necessary. API 23 added a new manifest `<application>` element attribute,
    `android:extractNativeLibs`, which if set makes Android not extract the
    libraries to the filesystem. API 23 added a way to load those libraries directly
    from the APK. In order to support that there are a few requirements which this
    commit implements:
    
      * DSO (`.so`) files must be stored uncompressed in the APK
      * `<application android:extractNativeLibs="false"/>` must be present
      * DSOs in the APK must be aligned on the memory page boundary (the `-p` flag
        passed to `zipalign` takes care of that
    
    This commit also implements `libmonodroid` suport for loading our DSOs directly
    from the APK. This operation mode is enabled by the presence of the
    `__XA_DSO_IN_APK` environment variable. This variable is inserted into the
    application's environment by way of placing it in the environment file (a file
    part of the XA project that is marked with the `AndroidEnvironment` build
    action). In that mode, the DSOs are *no longer* looked up in the application
    data directory but only in the override directories (if the APK is built in
    Debug configuration) and in the APK itself.
    
    Currently, in order to activate the above mode, one has to perform the following
    actions manually:
    
      * Add the `android:extractNativeLibs="false"` attribute to the `<application>`
        element in the `Properties/AndroidManifest.xml` file
    
      * Add the following property to the project file:
    
          <AndroidStoreUncompressedFileExtensions>.so</AndroidStoreUncompressedFileExtensions>
    
      * Add an android environment file to the project with a line which says
    
          __XA_DSO_IN_APK=1
    
    After that the application should work in the embedded DSO mode without
    problems.
    
    A couple of tests are provided to test building and execution of embedded DSO
    application on device, as well as to validate the built APK.
    grendello committed Sep 15, 2018
    Configuration menu
    Copy the full SHA
    853c7c5 View commit details
    Browse the repository at this point in the history

Commits on Sep 17, 2018

  1. Configuration menu
    Copy the full SHA
    8a2ca61 View commit details
    Browse the repository at this point in the history