3

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?

kenny_k
  • 3,831
  • 5
  • 30
  • 41
  • Can you update your question to include your `AndroidManifest.xml` file? – kenny_k Oct 11 '19 at 18:20
  • Yes @kenny_k , the trouble is found to be in the manifest file as given by ahasbini. this entry: , was in the manifest file and had to be removed before the installation was successful. Thank you. – nomacreates Oct 11 '19 at 23:12

2 Answers2

4

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.

kenny_k
  • 3,831
  • 5
  • 30
  • 41
2

Had a look in the com.github.PhilJay:MPAndroidChart:v3.1.0-alpha repository and did not find any reference to com.google.android.things inside the source code.

You need to remove the below entry in case it's found in the AndroidManifest.xml of your app for it to work on your device again:

<uses-library android:name="com.google.android.things" />
ahasbini
  • 6,761
  • 2
  • 29
  • 45
  • Please make sure you are using a library that works across different CPU's. Please go through the link below to verify this: https://android-developers.googleblog.com/2019/01/get-your-apps-ready-for-64-bit.html – Susheel Tickoo Oct 11 '19 at 11:23
  • @ahasbini, this has solved the issue yes! Thanks a lot! – nomacreates Oct 11 '19 at 23:03