问题
I've never made an Android app before and I'm this isn't a great start. I made a blank project on Android studios as a test and tried to run the program on my Huawei P33 phone. When I attempt to build and install the program, I get the following messages;
Failed to commit install session 389180709 with command cmd package install-commit 389180709. Error: INSTALL_FAILED_MISSING_SHARED_LIBRARY: Package couldn't be installed in /data/app/com.example.myapplication-segdjrVZj4KvtCNaJ5W5oQ==: Package com.example.myapplication requires unavailable shared library com.google.android.things; failing!
Session 'app': Installation did not succeed. The application could not be installed: INSTALL_FAILED_MISSING_SHARED_LIBRARY Retry
I've spent about an hour and a half googling, but no one has seemed to have the same issue with the Android Things library.
In 'AndroidManifest.xml', if I change <uses-library android:name="com.google.android.things" />
to <uses-library android:name="com.google.android" />
, the app installs but does nothing and crashes as soon as it is opened.
回答1:
You can add android:required="false" flag to your manifest file and the application should be able to start.
<uses-library
android:name="com.google.android.maps"
android:required="false"/>
Then you have to make sure to protect your code from throwing an exception in places where you need it
回答2:
Given that you've never made an Android app before, it's likely that you picked an Android Things template on the new project Wizard. Just create a new project and make sure to select just phone and tablet, not Android Things.
来源:https://stackoverflow.com/questions/58617556/install-failed-missing-shared-library-error-when-trying-to-run-android-app