Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support DSOs embedded in the .apk (#2154)
Context: #1906 Android v6.0 (API-23) introduced a new way of dealing with the native shared libraries shipped in the `.apk`. Before API-23, the libraries would be always extracted and placed in the application data directory, thus occupying more space than necessary. API-23 added a new `AndroidManifest.xml` attribute, `//application/@android:extractNativeLibs`, which if set to `false` makes Android *not* extract the libraries to the filesystem. API-23 added a way to instead 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 set * DSOs in the `.apk` must be aligned on the memory page boundary; `zipalign -p` takes care of this. This commit also implements `libmonodroid.so` 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 environment variable is inserted into the application's environment by way of placing it in the environment file (a file part of the Xamarin.Android App project that has the `@(AndroidEnvironment)` build action). In this 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 the `.apk` itself. Currently, in order to activate the above mode, one has to perform the following actions manually: 1. Add the `android:extractNativeLibs="false"` attribute to the `<application>/` element in `Properties/AndroidManifest.xml`. 2. Add the following property to the project file: <AndroidStoreUncompressedFileExtensions>.so</AndroidStoreUncompressedFileExtensions> 3. 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`. TODO: fix issue #1906 by "nicely integrating" this support with the Xamarin.Android build system so that the above manual steps are not required. The exact semantics still need to be determined.
- Loading branch information