Error on using the maps library - android

I am trying to run android maps example on my emulator, I have added the library
<uses-library android:name="com.google.android.maps" />
inside the application tag.
When I try to run the application in emulator I get the following error
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
I have set the build path for android to "Google API's"
How to resolve this error?

Actually, you can't run google maps v2 on emulator.
You can check this post for a dirty solution

Right click on your project --> Properties --> Android --> On the library block clik on add and add google-play-services_lib as your project's library. Then to your manifest file add:
<permission
android:name="your_package.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="your_package.permission.MAPS_RECEIVE"/>
Then in your application tag add:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_API_KEY"/>

If you are testing the app in emulator make sure that You have created AVD for emulator with Google Maps-APIs.
In general, this error arises from the fact that Google Maps not installed on your device/emulator.

Related

How to resolve WARNING - for Google map version 1 not available in Android 11

App bundles or APKs in this release use version 1 of the Google Maps SDK, which is not available on Android 11 or higher. Remove this dependency from your app. Google Play may remove support for version 1 of the Google Maps SDK in the future.
We have already migrated to Maps API V2, hence functionality wise there should not be any issues.
I had the same issue even though we have been using latest Maps SDK for Android for years. I had to remove this entry from AndroidManifest.xml
<uses-library android:name="com.google.android.maps" />
In the app's Manifest:
Remove:
<uses-library android:name="com.google.android.maps" />
Add these lines above the <application ... />:
<!--
Android 11 package visibility changes require that apps specify which
set of other packages on the device that they can access. Since this
sample uses Google Maps, specifying the Google Maps package name is
required so that the buttons on the Map toolbar launch the Google Maps
app.
-->
<queries>
<package android:name="com.google.android.apps.maps" />
</queries>
Found those on the official Google's code sample: https://github.com/googlemaps/android-samples/blob/main/ApiDemos/java/app/src/main/AndroidManifest.xml
I'm facing the same 'problem'. But I think it's a false positive. I removed everything from v1 and used v2 for a long time now.
Probably best to create a ticket at Google for this.

Use of google map library on manifest file

Why do we use the below code on our android manifest file.Can anyone please explain?
<uses-library
android:name="com.google.android.maps"
android:required="true" />
Please check this out : uses-library. This will give the clear idea.
uses-library tells the android system that the app requires com.google.android.maps package to be installed in device ie Google maps app
if you put required attribute true, android:required="true" , then the app will be installed only if device has google maps installed in it.

Android Studio Emulator: Authentication failed. Timeout while trying to contact the server

I am trying to learn Android development & doing it the first time to do some hands-on to develop my ideas. I want to load the google map with the current location on the emulator.
Referred SE Questions: Failed to load map. Error contacting Google servers. This is probably an authentication issue
Initially, I faced the problem "won't run unless I update google play service in android studio"
The problem got resolved after changing:
compile 'com.google.android.gms:play-services:9.0+
I also corrected API_KEY by generating the API_KEY from the link given in code file. Now I am not getting that error but still not able to load the map on the emulator. These seem to be connection issue & I added the permission in manifest files as well. But the problem still persists. Kindly guide me & provide your valuable suggestions.
google_maps_api.xml
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=6C:42:DD:0A:5D:D3:E4:5E:79:C9:04:81:3A:7A:70:17:25:37:97:96%3Bcom.example.kapilj3.meetmeapp
You can also add your credentials to an existing key, using this line:
6C:42:DD:0A:5D:D3:E4:5E:79:C9:04:81:3A:7A:70:17:25:37:97:96;com.example.kapilj3.meetmeapp
Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIza_MY_ACTUAL_KEY</string>
</resources>
AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_maps_key" />
add this code to your application manifiest

Google MapFragment is blank (white) with Could not find class 'maps.j.k'

I'm trying to build the official android google map api v2 sample on a (gingerbread 2.3.5) phone .
I added android-support-v4.jar to official sample project.
I took the sample from the official tutorial in <android-sdk>/extras/google-play-services/samples/maps
I copied the sample app in Eclipse, reference the google-play-services_lib project as an Android library, and build the whole thing with the Android SDK 4.1.2 (api 16).
Unfortunately, ahen I launch the app the map is blank and I don't have any exception or message.
The only thing I got are those suspicious lines in the logcat :
Unable to resolve superclass of Lmaps/a/du; (411)
Link of class 'Lmaps/a/du;' failed
Unable to resolve superclass of Lmaps/a/ej; (2363)
Link of class 'Lmaps/a/ej;' failed
Unable to resolve superclass of Lmaps/j/k; (2379)
Link of class 'Lmaps/j/k;' failed
ERR Could not find class 'maps.j.k', referenced from method maps.y.ae.a
VFY: unable to resolve new-instance 3571 (Lmaps/j/k;) in Lmaps/y/ae;
I suspect that my project structure in eclipse 3.8 is somewhat messed up.
I tried the following things (even the most idiotic) to no avail.
1. Invalid api key ?
I generated a "debug.keystore" with keytool and updated the eclipse preference (Android/Build/Keystore).
Of course, I registered that new keystore/SHA1 and get a new api key that I used in the AndroidManifest file
2. Wrong project target ?
I tried to build my two projects with the following targets :
Android 4.2.1
Google Api 4.2.1
3. adding google-play-services_lib as a project dependency
I tried to add google-play-services_lib as a project dependency on top of being added as an android library in the demo build path.
And tick the matching export checkbox.
4. test google maps api v2 on the phone
I downloaded trulia real estate app that is said to use the v2 api on the phone to be sure that the phone is compatible with the new api
Here is the manifest for the sample app
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapdemo"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
<!-- Copied from Google Maps Library/AndroidManifest.xml. -->
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<!-- End of copy. -->
<application
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/demo_title" >
<!-- You must insert your own Google Maps for Android API v2 key in here. -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="XXXXXXXX" />
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".BasicMapActivity"
android:label="#string/basic_map" />
<activity
android:name=".CameraDemoActivity"
android:label="#string/camera_demo" />
<activity
android:name=".EventsDemoActivity"
android:label="#string/events_demo" />
<activity
android:name=".GroundOverlayDemoActivity"
android:label="#string/groundoverlay_demo" />
<activity
android:name=".LayersDemoActivity"
android:label="#string/layers_demo" />
<activity
android:name=".LocationSourceDemoActivity"
android:label="#string/locationsource_demo" />
<activity
android:name=".MarkerDemoActivity"
android:label="#string/marker_demo" />
<activity
android:name=".OptionsDemoActivity"
android:label="#string/options_demo" />
<activity
android:name=".PolygonDemoActivity"
android:label="#string/polygon_demo" />
<activity
android:name=".PolylineDemoActivity"
android:label="#string/polyline_demo" />
<activity
android:name=".ProgrammaticDemoActivity"
android:label="#string/programmatic_demo" />
<activity
android:name=".TileOverlayDemoActivity"
android:label="#string/tile_overlay_demo" />
<activity
android:name=".UiSettingsDemoActivity"
android:label="#string/uisettings_demo" />
<activity
android:name=".RawMapViewDemoActivity"
android:label="#string/raw_mapview_demo" />
<activity
android:name=".RetainMapActivity"
android:label="#string/retain_map" />
<activity
android:name=".MultiMapDemoActivity"
android:label="#string/multi_map_demo" />
</application>
</manifest>
Here are some screenshots of my project structure/build path.
I think maybe you make something wrong when you apply the api KEY.
I have the same problem, and at last I found that I turn on the incorrect service. at https://code.google.com/apis/console/,
There are Google Maps API v2 and Google Maps Android API v2.
You should use Google Maps Android API v2.
I had exactly the same problem (all configurations the same, maps.j.k stuff in the logcat). However, for me choosing Google APIs as build target solved it. But that was Google APIs 4.2, so I suggest that you install the update and try with the more recent target.
I resolved this issue by changing de targetSdkVersion with de last targetSdkVersion avaiable, at the AndroiMainfest.xml file.
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
Are you using ProGuard? Usually class names like "a", "b", etc. are a result of ProGuard obfuscating class names, and maybe the Maps API breaks when that happens. If that's the case, you will either have to disable ProGuard or add some -keep lines to your proguard.cfg file. This post shows what those lines might look like.
In my case it was due to 2 issues
on my phone the latest Google Maps app was not installed (in fact there was no google maps at all)
I didnt have all the required permissions set in my manifest
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
As documented in https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api
http://developer.android.com/sdk/index.html --this is the link for the adt bundle in android..try downloading this and start over again..maybe there's a problem with your ADT.
Check the console API you've enabled Google Maps Android API v2
I was dealing with same issue. I tried to implement the com.example.mapdemo and had a heck of a time.
I copied the code of the BasicMapActivity to a clean new project and made the Libraries look as above.
Basically, I couldn't get either to work. I got the "Authorization failure" error in the debugger.
Then, today, I prepared new keys specifically for each project with the specific com.example.xxx after the semicolon when preparing the key in the Google Console.
I did Project->Clean at every step.
I ran it in debugger first, then just Run. And, if I remember, a few times after making the change to the manifest.
Then, finally, they worked. It seemed, in the end, to require a key for each specific project.
Here's what worked for me. When you use the Google APIs Console to create your API key, be sure to append ;com.example.mapdemo to the SHA1 fingerprint. (I was using something else more appropriate for another app I'm currently developing.) What clued me in on this solution was an authorization error in the LogCat.
In my case I added LocationSource Interface so I can get location data but i forgot to add :
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
at Manifest file.
Don't forget to use separate keys for debug and release version of the app!
If you have already tried everything, try to uninstall and reinstall again your app: on my phone (S3 mini), after the first launch with the wrong key, I corrected it, but it didn't work until a complete uninstallation.
Maybe some sort of caching is used.

com.google.android.maps missing?

new to Android. Checked the FAQs on the SDK site but didn't find anything that was helpful.
I'm learning via a few books w/downloadable code. One of the examples I'd like to get running won't even compile because the IDE can't find/import the com.google.android.maps library/package, which I found odd since I have everything possible installed that the SDK offers. The book info on the publisher site was not helpful either. Any ideas?
I'm using Eclipse (build 20090920-1017) with the ADT 0.9.5 plugin. SDK is fully updated (all available packages installed, including android 1.1 api 2 rev. 1 through android 2.0.1 api6 rev 1, and google apis 3 rev 3 through 6 rev 1.)
Any advice is appreciated.. thanks in advance.
Choose "Google API" project Build Target. And be sure Google API is installed in you Android SDK.
And don't forget to add
<uses-library android:name="com.google.android.maps" />
into tag in ApplicationManifest.xml
Switch to "Google API" as project Build Target works for me.
Project->properties->android,
check GOOGLE API
Install all google API's using sdk manager.
In your manifest,under application element add
<uses-library android:name="com.google.android.maps" />
You have to include jar file for maps also.. Right click on your project and go to build path and then add external archives. locate your sdk. android-sdk-windows\add-ons\addon_google_apis_google_inc_<your api version>\libs\maps
Me too got this Error even though I Inserted
<uses-library android:name="com.google.android.maps"/>
I struggled to solve this problem for a long time...
Then Cleaning and Rebuilding Project solves the Issue
Remember always to add uses library in appication branch. Like this:
I had also the same problem but i had added uses library not in application
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MapsTest"
android:versionCode="1"
android:versionName="1.0.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".MapsTest"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps"/>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
</manifest>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
To develop with google maps I recommend you to use Genymotion instead eclipse emulator.

Categories

Resources