INSTALL_FAILED_MISSING_SHARED_LIBRARY when using MapView in Android Studio - java

I am trying to use a com.google.android.gms.maps.MapView in my app. It compiles without a problem, but I am getting the following error when launching it from Android Studio:
Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY]
I have tried everything in the main thread for this question.
I have installed the Google APIs
My build target is Google APIs (4.0)
I have <uses-library android:name="com.google.android.gms.maps" /> in my AndroidManifest.xml file's <application> tag
My AVD uses the Google APIs target
My real device has Google play services installed and up-to-date
An error is also visible in the preview pane of my activity file
If I remove the MapView reference and the <uses-library> tag, then the application launches.
This covers everything from the other threads that I can find on this topic. Does anyone know of anything else that might be causing this error?

I have <uses-library android:name="com.google.android.gms.maps" /> in my AndroidManifest.xml file's <application> tag
Delete that, as you made this up, and it is the source of your difficulty. Maps V1 used a <uses-library> element (with a different name); Maps V2 does not.
My AVD uses the Google APIs target
Maps V2 is not supported in the emulator at this time.

Related

Action requested: Declare your Ad ID permission

Today i have got this email:
Last July, we announced Advertising policy changes to help bolster
security and privacy. We added new restrictions on identifiers used by
apps that target children. When users choose to delete their
advertising ID in order to opt out of personalization advertising,
developers will receive a string of zeros instead of the identifier if
they attempt to access the identifier. This behavior will extend to
phones, tablets, and Android TV starting April 1, 2022. We also
announced that you need to declare an AD_ID permission when you update
your app targeting API level to 31 (Android 12). Today, we are sharing
that we will give developers more time to ease the transition. We will
require this permission declaration when your apps are able to target
Android 13 instead of starting with Android 12.
Action Items If you use an advertising ID, you must declare the AD_ID
Permission when your app targets Android 13 or above. Apps that don’t
declare the permission will get a string of zeros. Note: You’ll be
able to target Android 13 later this year. If your app uses an SDK
that has declared the Ad ID permission, it will acquire the permission
declaration through manifest merge. If your app’s target audience
includes children, you must not transmit Android Advertising ID (AAID)
from children or users of unknown age.
My app is not using the Advertising ID. Should i declare the AD_ID Permission in Manifest or not?
Case 1: The app doesn't contain any Ads:
You can simply remove/ignore it by adding tools:node="remove" in the AndroidManifest.xml file.
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
Make sure you have xmlns:tools at the top of AndroidManifest.xml file
Even if another third-party library asks for this specific permission, the build will be forced not to merge it in your final Manifest file.
You can get more info from this SO answer.
Case 2: The app contains Ads:
Add the following to AndroidManifest.xml before </manifest>:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
You can get more information from here.
If your app uses the Google Mobile Ads SDK(Admob) version 20.4.0 or higher, you can skip setting up the permission manually since the SDK automatically declares it
More informations here:
https://developers.google.com/admob/android/quick-start
Case 1: Your App has Ads
Add the following to AndroidManifest.xml before </manifest>:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
Case 2: Your App Doesn't have Ads
At the top of your AndroidManifest.xml make sure you have xmlns:tools on the <manifest ...>. (kudos to this answer) e.g.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mycompany.myapp">
Then, add the following at the bottom of the page, before </manifest> tag:
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
Source:
Google's Doc: https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#public-methods
Google describe here how to solve
https://support.google.com/googleplay/android-developer/answer/6048248?hl=en
Add in manifest
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
If your app doesn't contain ads, make sure you complete the survey on App content page (Policy > App content) in Play Console.
Just select the option: No, my app does not contain ads.
If you don't do that, you won't be able to upload new releases of your app to Google Play.
First of all,
com.google.android.gms.permission.AD_ID can be added by other third party SDK like
Play Services-ads
firebase-analytics etc
So, if you haven't added permission.AD_ID manually, make sure it is not added by any other SDK by checking merged manifest file.
merged-manifest path:
project > app > build > intermediate > merged_manifest > release > AndroidManifest.xml
Now go to your play console > app content > Adverstising ID and
Select NO if your merged manifest doesn't contain AD_ID, else
Select YES and complete next option.
In my case, I used Firebase Analytics only for crash reports etc.
You can set your app to use advertising ID.
And use Analytics only.
Don't worry. All developer who uses Admob for advertisement received this warning. Just make sure you are using Latest Google Mobile Ads SDK(Admob) OR AdMob SDK version higher or equal to 20.4.0 in your build.gradle file. In that case SDK automatically manage it.
Otherwise for older sdk below 20.4.0, we need to manually mention below line in our AndroidManifest.xml
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
There are two different forms:
Ads
Advertising ID
Initially, I got stuck because I did not notice the other. So your app can be in any combination, for example, no ads, but yes, advertising ID.
In this documentation it is explained that Google services can include the advertising ID for other reasons that are not ads: Analytics.
Google Play Services version 4.0 introduced new APIs and an ID for use by advertising and analytics providers. Terms for the use of this ID are below.
And in this other documentation, in the examples section is very clear that ads are understood as what is commonly understood as ads: banners, pop-ups, a tile in the middle of a list, etc.
Analyzing the merged manifest we can see that the library play-services-measurement-api is adding the permission and is related to Analytics. The library manifest looks like this:
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
<application>
<service
android:name="com.google.firebase.components.ComponentDiscoveryService"
android:exported="false" >
<meta-data
android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
</application>
Please notice that library is registering analytics.connector.internal.AnalyticsConnectorRegistrar.
In this case the Ads form must be mark with no but the Adverising ID form must be mark with yes and then the Analytics option.
I have seen people recommending force the manifest to not merge the permission.AD_ID but that would break the Analytics.
I also received today's mail from the PlayStore team to all developers. Asking to declare AD_ID permission.
Since we developed and released our application using Flutter with android targeting to API level 31. I'm using the advertising_identifier: ^0.1.1 plugin to get the advertising client ID. I haven't declared AD_ID permission in my manifest file.
Additionally, apps updating their target API level to 31 (Android 12) and using advertise identifier / advertise id client info fetch will need to declare a Google Play services normal permission in the manifest file as follows:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
Refered,
https://support.google.com/googleplay/android-developer/answer/6048248?hl=en
when you set targetSdkVersion 33 you must need to add the below line in the manifest file
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
if you are not set this, show a warning on the play console when your is in production.

File storage error when trying to display an OpenStreetMap map

My Android app using OpenStreetMap, which has been perfectly working for months, is now not able anymore to display the OpenStreetMap map. Despite the WRITE_EXTERNAL_STORAGE permission granted, I get messages like these :
E/OsmDroid: Unable to start the SQLite tile writer. Check external storage availability.
I/StorageUtils: /storage/emulated/0 is NOT writable
As I am targetting API29 and running on an Android 10 phone, I suppose the problem is related to the new policy about external storage access and the requirement to use the Storage Access Framework. Am I right?
No matter if I am right or wrong, does anyone know how I could fix this?
Because you are targeting Andorid 10 - api 29, the official Android docs states:
Running on Android 10
If your app targets Android 10 (API level 29), opt-out of scoped
storage and continue using the approach for Android 9 and lower to
perform this operation.
So you need to add to the AndroidManifest.xml:
<manifest ... >
<!-- This attribute is "false" by default on apps targeting
Android 10 or higher. -->
<application android:requestLegacyExternalStorage="true" ... >
...
</application>
</manifest>
#blackapps This is not a hack.

Packaging and installing Android Wear Watchface

I've read several other questions regarding this same topic however I am still at my wit's end trying to figure out how to get my Watchface to appear on my Android Wear device, let alone publish it to the Play Store.
The project has a mobile app which houses a blank activity and then the Wear app (Watchface) which houses the activity for the Watchface.
I've attempted the following
signing both Wear and mobile apks and installing then both on my phone (mobile app shows with blank activity but no Wear Watchface available on watch)
installing the signed Wear apk separately (also does not display as a selectable Watchface)
running the Wear Watchface in the Android Studio emulator (works)
making sure that the same permissions exist in both mobile and Wear manifests
ensuring that all project IDs match up and are the same
Any advice or help would be great.
Writing watch face to wear 1.x.x or 2.0 involves extending your Java class to The CanvasWatchFaceService class and registering your watch face in the manifest and also working with the CanvasWatchFaceService.Engine class.
You don't have to create an Activity you will have to create a view and inflate or mostly draw the view in “void onDraw(Canvas canvas, Rect bounds)”. You have to register the service in your manifest like as shown below.
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="#drawable/preview_face" />
<meta-data
android:name=
"com.google.android.wearable.watchface.preview_circular"
android:resource="#drawable/preview_face_circular" />
Also You have to have Wake lock permission
<uses-permission android:name="android.permission.WAKE_LOCK" />
we need to add a special intent filter with the goal that watch.
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
<category
android:name=
"com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
It will be usual signed android apk to publish within playstore no much of difference.
Also there are plenty of resources that will get you started like medium blogs and reddit blogs and so on.
Check this book for more information on Wear : Android wear Projects
After much digging, I was able to get to the solution.
In order for a watch face or a wear apk to be moved on the watch for debugging purposes, one must ensure the following
Ensure all of these items are met in addition to the following.
Turn on debugging in both the Android Wear application as well as on the watch itself. (Debugging on the watch can be turned on by enabling developer options by tapping the build number) You would want to enable debugging over bluetooth
Your phone should also be plugged into to a computer that has adb and enable adb debugging on the device itself.
Typing adb-devices in Command Prompt will list all of the devices found
Connect the debugger to the watch by adb forward tcp:4444 localabstract:/adb-hub
adb connect 127.0.0.1:4444
Ensure that both target and Host are connected by opening the Android Wear companion app, tap settings and viewing the status message that appears under the bluetooth debugging toggle option. It should read Host: connected
Target: connected
adb-devices should now show both the phone and the watch. From here on you can use adb commands to push the wear apk to the watch.
Source

Facebook SDK crashes google-play-services-lib if imported as existing Android source code

I have an extremely strange problem to which finding solution seems to be very tricky. Here's the story:
The application I'm working on uses both Facebook SDK and Google Maps v2. Team mate was working on Google Maps and I was working on Facebook part. When we combine his and mine code it appears that just having FacebookSDK as an imported project in the workspace (not even referenced in Properties|Android|Library section of our app) , straight away makes the app not see the Google Maps library. The work around is to add Google Maps into Java build path, however the application still crashes when we try to access the activity based on Google Maps. Not having Facebook SDK in the workspace makes the Google Maps work. When the app is ran with Google Maps added to the Java build Path, when trying to access the Google Maps activity LogCat shows NoClassDefFoundError exception.
Hope I explained the problem well. If not then let me know what more is required to get closer to fixing this strange problem. Thanks :)
SOLUTION: It seems that adding Java Build Path reference to android_sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs\google_play_services.jar file fixed the issue. Crysis averted. ;)

Using maps from Google

I'm trying to develop an application using Google's maps and I can't get this application to work. I have done all what is described in the tutorial of the "MapView" sample code, including getting a map key associated to the MD5 signature of my "debug.keystore" file but the emulator definitively says that the application has stopped unexpectedly.
This error message appears when I try to process the setContentView line of code.
The only point where I am not sure of doing what must be done is about the signature of my application : as far as I have understood the signing process of an application, in debug mode, there is nothing to do. Is it correct?
I develop in Java using the Netbeans IDE.
Thanks for the time you will spend trying to help me.
First off, I'd recommend you very much to switch to Eclipse where the official Android plugin is available which will actually give you the LogCat (that's phone-side console) and you will always know what's wrong when something doesn't work. I'm not so sure that the plugin for NetBeans works equally well.
Secondly, regarding your crash, it has nothing to do with the API Key (if the key was wrong, you would see an empty map). Two things here from the top of my mind:
the Android version you need is the
"Google APIs", not vanilla "Android"
you didn't mention that Map library in the Manifest
So make sure that the library used with your project is "Google APIs" (of desired version, I'd stick with 2.1 or 2.2) and that there's this line in the Manifest file
<application ...>
...
<uses-library android:name="com.google.android.maps" />
</application>
Other than that, would be awesome to see some stack trace to be 100% sure.

Categories

Resources