Bug 5748 - [Regression?] Not all native libraries are extracted on installation
Summary: [Regression?] Not all native libraries are extracted on installation
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.2.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-06-19 10:55 UTC by Jonathan Pryor
Modified: 2013-02-25 15:24 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Scratch.MixedAbiNativeLibs.zip (27.20 KB, application/zip)
2012-06-19 23:27 UTC, Jonathan Pryor
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jonathan Pryor 2012-06-19 10:55:24 UTC
Mailing list thread:

http://lists.ximian.com/pipermail/monodroid/2012-June/010902.html
Comment 1 Jonathan Pryor 2012-06-19 23:27:06 UTC
Created attachment 2092 [details]
Scratch.MixedAbiNativeLibs.zip

Test case.

Build + install with Mono for Android 4.2.2. Result:

> $ adb shell ls -l /data/data/Scratch.MixedAbiNativeLibs/lib
> -rwxr-xr-x system   system      77340 2012-06-19 23:20 libmonodroid.so
> -rwxr-xr-x system   system      10232 2012-06-19 16:52 libfoo.so

Result: all libraries are installed.

Build + install with Mono for Android 4.2.3. Result:

> $ adb shell ls -l /data/data/Scratch.MixedAbiNativeLibs/lib
> -rwxr-xr-x system   system      77340 2012-06-19 23:20 libmonodroid.so

We're missing a native library. Oops.

Further note that this behavior is (currently) only seen on Android 2.3.3, and does NOT happen on Android 4.0. (I haven't tested any other API levels.)
Comment 2 Jonathan Pryor 2012-06-19 23:46:25 UTC
This looks to be an Android bug, brought about because of #5091 (and fixed in Android v4.0).

If I take Attachment 2092 [details] and edit the Project Properties so that the Debug build includes both armeabi and armeabi-v7a runtimes:

> $ unzip -l bin/Debug/Scratch.MixedAbiNativeLibs-Signed.apk
> Archive:  bin/Debug/Scratch.MixedAbiNativeLibs-Signed.apk
>   Length     Date   Time    Name
>  --------    ----   ----    ----
>       648  06-19-12 23:31   META-INF/MANIFEST.MF
>       769  06-19-12 23:31   META-INF/ANDROIDD.SF
>       782  06-19-12 23:31   META-INF/ANDROIDD.RSA
>      2200  06-19-12 23:31   res/drawable/icon.png
>       552  06-19-12 23:31   res/layout/main.axml
>      2748  06-19-12 23:31   AndroidManifest.xml
>      1052  06-19-12 23:31   resources.arsc
>    159944  06-19-12 23:31   classes.dex
>     10232  06-19-12 16:52   lib/armeabi/libfoo.so
>     77340  06-19-12 23:31   lib/armeabi/libmonodroid.so
>     77256  06-19-12 23:31   lib/armeabi-v7a/libmonodroid.so
>  --------                   -------
>    333523                   11 files

THEN it installs "improperly":

> $ adb shell ls -l /data/data/Scratch.MixedAbiNativeLibs/lib
> -rwxr-xr-x system   system      77256 2012-06-19 23:31 libmonodroid.so

Note that libfoo.so is missing, and the issue is also present in Mono for Android 4.2.2.

So the actual problem is that if both armeabi and armeabi-v7a directories are present, Android only extracts _one_ of them. This is actually reported as an Android issue, WorkingAsIntended:

    http://code.google.com/p/android/issues/detail?id=9089

(However, given that they've changed that behavior in v4.0, I don't think it "worked as intended" for long...)
Comment 3 Jonathan Pryor 2012-06-20 08:27:31 UTC
Another more "compatible" idea is to only add x86 to Debug builds for API levels >= 14, and leave ARM as-is. This would be less surprising to existing projects.
Comment 4 Jonathan Pryor 2012-06-20 11:58:48 UTC
Fixed in d63d8159: shared runtime installs will include only armeabi and x86 by default, not armeabi, armeabi-v7a, and x86.
Comment 5 Jeremy Kolb 2013-02-25 12:13:04 UTC
I'm seeing this on a Galaxy S III running 4.1.1.  Xamarin: 4.4.55.  It's happening in one app and not the other.  I'm trying to install a libutils_armv5te.so (in armeabi) and it's in the APK but not installing but other libraries are.
Comment 6 Jonathan Pryor 2013-02-25 15:24:20 UTC
This bug (#5748) was "re-introduced" in Mono for Android 4.4; this is intentional and By Design, largely because armeabi is broken on SMP machines, which is ~all current and future consumer hardware, so having a Broken By Design default is...well, broken.

http://docs.xamarin.com/releases/android/mono_for_android_4/mono_for_android_4.4

@jkolb: Please see the CPU Architecture documentation:

http://docs.xamarin.com/guides/android/advanced_topics/cpu_architecture

It's possible that Android has changed things (again!) regarding which native libraries are extracted from the .apk; it would be handy to know what the difference is between your two apps, e.g. which ABIs they support. (Better: the contents of `unzip -l path/to/ap.apk` for each app.)