Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY] on

2019-07-26 03:45发布

问题:

I have a Glass GDK app (open-source on Github) that works fine on XE12.

I got the XE16 update yesterday, and now when I run gradlew installDebug to deploy to Glass, I get the message:

:onebusaway-android:installDebug
pkg: /data/local/tmp/onebusaway-android-debug-unaligned.apk Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY]

Here are the changes I've made to update to XE16:

  1. I've changed my compileSdkVersion to "Google Inc.:Glass Development Kit Preview:19"
  2. I've updated the gdk.jar in the /libs folder to the file from <android-sdk>/add-ons/addon-google_gdk-google-19/libs
  3. Added <uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT"/> to manifest for pre-production voice commands

(I actually made these changes prior to receiving the XE16 update myself, based on reports of it failing on XE16 from others - so I can confirm that with the above changes the app still works fine on XE12).

I'm using this third-party progress bar library, but from what I can tell from the release notes nothing has changed with the GestureDetector or Gesture Glass classes, which are the only Glass-specific classes it relies on.

My Glassware is an immersive Activity, so I'm not relying on TimelineManager or Cards (which changed in XE16).

EDIT

I've tried removing the third-party progress bar, but that doesn't seem to have any affect - still the same error.

I've also updated to Android Studio 0.5.5, no luck deploying from there either (as opposed to running gradlew installDebug from command-line). Also tried removing /libs/gdk.jar since this isn't required in Android Studio 0.5.5, still no change.

回答1:

If you have any <uses-library> elements that aren't supported by Glass in your AndroidManifest.xml, you must include the android:required="false" attribute, or remove the element completely, for your app to install on XE16. This is a change in behavior from XE12.

According to the Android docs:

If <uses-library> element is present and its android:required attribute is set to true, the PackageManager framework won't let the user install the application unless the library is present on the user's device...The default android:required value is "true".

I borrowed code from a normal Android app for my Glass app, and I had a leftover element buried in the manifest:

<uses-library android:name="com.google.android.maps"/>

Since I didn't include the android:required="false", XE 16 is correctly preventing the app from installing.

Apparently XE12 didn't enforce this, and installed the app anyway.

After either adding the android:required="false"attribute:

<uses-library android:name="com.google.android.maps"
              android:required="false"/>

...or removing this <uses-library> element completely, the app now installs correctly on XE16.