Search code examples
androidandroid-studiompandroidchartandroid-install-apk

App Refuses to Install - INSTALL_FAILED_MISSING_SHARED_LIBRARY


I am new to programming generally please I need some help! My app was installing successfully after every update until i decided to add the 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha' library to the app because i need the user to be able to view some data in form of statistical charts.

The library was synced successfully and have used packages and classes therein successful. But when i try to install the app in my android device it returned this error:

Installation failed with message Failed to commit install session 590492354 with command cmd package
install-commit 590492354. Error: INSTALL_FAILED_MISSING_SHARED_LIBRARY: Package couldn't be installed in
/data/app/com.cenitscitech.www.etimebook-jOP-jv2YuNu7_8qnkfqp-A==: Package com.cenitscitech.www.etimebook requires unavailable shared library com.google.android.things; failing!.

It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing." I have pasted a screenshot here:

The Error message:

I uninstalled the existing version of the apk, cleared some memory space but keep on getting the same message! What should I do next please?


Solution

  • You are most likely installing on a device that is not an Android Things device. I suspect the library you added either has some transitive dependency on com.google.android.things, or something else changed in your project.

    To get around this, you must do the following 2 things:

    1. Mark that Android Things is not required on the device in your AndroidManifest.xml file:

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

    (tools:replace is not strictly required, but it just there in case something in the manifest merge process overrides your setting.)

    2. In your app's code, before making any calls to the Things APIs, make sure that they are available on the current device. This can be tested with the following code snippet:

    public boolean isThingsDevice(Context context) {
        final PackageManager pm = context.getPackageManager();
        return pm.hasSystemFeature(PackageManager.FEATURE_EMBEDDED);
    }
    

    Only doing 1 should fix the install problem, but your app will crash if you make any Things API calls on a device that isn't an Android Things device.