android, google map api v2 error - android

I am trying to develop one app for Google map v2. i followed the all the instructions. i generate API_KEY and placed it into android manifest file also.
On the "Order and Export" tab I checked "Android Private Libraries" on my project. I also did this for the library project it references.
But i get the error when i run app in emulator as well as android device also. my log cat fallow the error like
10-09 03:02:37.905: E/PAUSE(2949): TIMERS!
10-09 03:02:37.921: W/dalvikvm(2949): VFY: unable to find class referenced in signature (Lcom/google/android/gms/maps/GoogleMap;)
10-09 03:02:37.921: I/dalvikvm(2949): Could not find method com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable, referenced from method com.zarrin.negar.LocationActivity.checkGooglePlayServicesForUpdate
10-09 03:02:37.921: W/dalvikvm(2949): VFY: unable to resolve static method 3699: Lcom/google/android/gms/common/GooglePlayServicesUtil;.isGooglePlayServicesAvailable (Landroid/content/Context;)I
10-09 03:02:37.925: D/dalvikvm(2949): VFY: replacing opcode 0x71 at 0x0005
10-09 03:02:37.925: E/dalvikvm(2949): Could not find class 'com.google.android.gms.maps.SupportMapFragment', referenced from method com.zarrin.negar.LocationActivity.initialization
10-09 03:02:37.925: W/dalvikvm(2949): VFY: unable to resolve check-cast 615 (Lcom/google/android/gms/maps/SupportMapFragment;) in Lcom/zarrin/negar/LocationActivity;
10-09 03:02:37.933: D/dalvikvm(2949): VFY: replacing opcode 0x1f at 0x0021
10-09 03:02:37.937: E/dalvikvm(2949): Could not find class 'com.google.android.gms.maps.model.LatLng', referenced from method com.zarrin.negar.LocationActivity.setGps
10-09 03:02:37.941: W/dalvikvm(2949): VFY: unable to resolve new-instance 618 (Lcom/google/android/gms/maps/model/LatLng;) in Lcom/zarrin/negar/LocationActivity;
10-09 03:02:37.941: D/dalvikvm(2949): VFY: replacing opcode 0x22 at 0x0021
10-09 03:02:37.941: E/dalvikvm(2949): Could not find class 'com.google.android.gms.maps.model.LatLng', referenced from method com.zarrin.negar.LocationActivity.setLocation
10-09 03:02:37.945: W/dalvikvm(2949): VFY: unable to resolve new-instance 618 (Lcom/google/android/gms/maps/model/LatLng;) in Lcom/zarrin/negar/LocationActivity;
10-09 03:02:37.945: D/dalvikvm(2949): VFY: replacing opcode 0x22 at 0x001e
10-09 03:02:37.949: D/dalvikvm(2949): DexOpt: unable to opt direct call 0x0f0e at 0x27 in Lcom/zarrin/negar/LocationActivity;.setGps
10-09 03:02:37.949: D/dalvikvm(2949): DexOpt: unable to opt direct call 0x0f10 at 0x37 in Lcom/zarrin/negar/LocationActivity;.setGps
10-09 03:02:37.949: D/dalvikvm(2949): DexOpt: unable to opt direct call 0x0f0e at 0x40 in Lcom/zarrin/negar/LocationActivity;.setGps
10-09 03:02:37.949: I/dalvikvm(2949): Failed resolving Lcom/zarrin/negar/LocationActivity$1; interface 612 'Lcom/google/android/gms/maps/GoogleMap$OnMapClickListener;'
manifest:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.CLEAR_CACHE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<permission
android:name="com.zarrin.negar.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.zarrin.negar.permission.C2D_MESSAGE" />
<permission
android:name="com.zarrin.negar.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.zarrin.negar.permission.MAPS_RECEIVE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
and my activity :
<activity
android:name="com.zarrin.negar.LocationActivity"
android:screenOrientation="portrait"
android:launchMode="singleTop" >
</activity>
meta data :
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my_api_key" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
image of my project's properties :
image 1
image 2

This could be because of your project configuration, or your emulator configuration.
Project
Have you imported as a library Google Play services project from your
SDK?
Emulator
Has your emulator installed Google Play Services? Try running an
emulator with SDK (Google APIs)
Good luck buddy!

Related

How to solve these logcat warning messages ??? Android Studio

I am receiving these warning messages and I not sure how to fix:
02-14 14:01:15.255: I/dalvikvm(10677): Could not find method
android.view.ViewGroup.onNestedScrollAccepted, referenced from method
android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
02-14 14:01:15.255: W/dalvikvm(10677): VFY: unable to resolve virtual
method 11769: Landroid/view/ViewGroup;.onNestedScrollAccepted
(Landroid/view/View;Landroid/view/View;I)V
02-14 14:01:15.255: D/dalvikvm(10677): VFY: replacing opcode 0x6f at
0x0000
02-14 14:01:15.255: I/dalvikvm(10677): Could not find method
android.view.ViewGroup.onStopNestedScroll, referenced from method
android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
02-14 14:01:15.255: W/dalvikvm(10677): VFY: unable to resolve virtual
method 11775: Landroid/view/ViewGroup;.onStopNestedScroll
(Landroid/view/View;)V
02-14 14:01:15.255: D/dalvikvm(10677): VFY: replacing opcode 0x6f at
0x0000
02-14 14:01:15.260: I/dalvikvm(10677): Could not find method
android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll,
referenced from method
android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
02-14 14:01:15.260: W/dalvikvm(10677): VFY: unable to resolve virtual
method 9420:
Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll
()V
02-14 14:01:15.260: D/dalvikvm(10677): VFY: replacing opcode 0x6e at
0x000e
02-14 14:01:15.605: I/dalvikvm(10677): Could not find method
android.content.res.TypedArray.getChangingConfigurations, referenced
from method
android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
02-14 14:01:15.605: W/dalvikvm(10677): VFY: unable to resolve virtual
method 547: Landroid/content/res/TypedArray;.getChangingConfigurations
()I
02-14 14:01:15.605: D/dalvikvm(10677): VFY: replacing opcode 0x6e at
0x0002
02-14 14:01:15.610: I/dalvikvm(10677): Could not find method
android.content.res.TypedArray.getType, referenced from method
android.support.v7.internal.widget.TintTypedArray.getType
02-14 14:01:15.610: W/dalvikvm(10677): VFY: unable to resolve virtual
method 569: Landroid/content/res/TypedArray;.getType (I)I
02-14 14:01:15.610: D/dalvikvm(10677): VFY: replacing opcode 0x6e at
0x0002
My Android Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bkbarbados.com.mygcm" >
<!-- Permissions for GCM -->
<permission
android:name="bkbarbados.com.mygcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="bkbarbados.com.mygcm.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:name=".Global"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".ListPeople"
android:label=" Chat App">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ChatActivity"
android:label=" Chat App"
android:launchMode="singleTop">
</activity>
<!-- Receiver for GCM -->
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="bkbarbados.com.mygcm" />
</intent-filter>
</receiver>
<service android:name=".GcmIntentService" />
</application>
</manifest>
The library you added is not checked in build path. Try this link
Unable to solve virtual method
It can get quite involved to repair. A previous discussion on the problem:
What do these Android logcat warnings mean?

error Api key not found

i am trying to use google maps in my app, i am using google play services in app
MapViewActivity:
public class MapsViewActivity extends FragmentActivity {
// Google Map
private GoogleMap googleMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maps);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* function to load map. If map is not created it will create it for you
* */
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
XMl:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
and getting the following errors :
08-05 16:41:54.384: E/dalvikvm(24979): Could not find class 'gpq', referenced from method gpr.a
08-05 16:41:54.384: W/dalvikvm(24979): VFY: unable to resolve new-instance 4090 (Lgpq;) in Lgpr;
08-05 16:41:54.384: D/dalvikvm(24979): VFY: replacing opcode 0x22 at 0x0000
08-05 16:41:54.404: W/dalvikvm(24979): VFY: unable to resolve static field 20875 (t) in Lyo;
08-05 16:41:54.404: D/dalvikvm(24979): VFY: replacing opcode 0x62 at 0x000e
08-05 16:41:54.404: W/dalvikvm(24979): VFY: unable to resolve static field 20875 (t) in Lyo;
08-05 16:41:54.484: E/AndroidRuntime(24979): FATAL EXCEPTION: main
08-05 16:41:54.484: E/AndroidRuntime(24979): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.careandcure/com.example.careandcure.MapsViewActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
08-05 16:41:54.484: E/AndroidRuntime(24979): at com.example.careandcure.MapsViewActivity.onCreate(MapsViewActivity.java:16)
08-05 16:41:54.484: E/AndroidRuntime(24979): at android.app.Activity.performCreate(Activity.java:4538)
08-05 16:41:54.484: E/AndroidRuntime(24979): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
08-05 16:41:54.484: E/AndroidRuntime(24979): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
08-05 16:41:54.484: E/AndroidRuntime(24979): Caused by: java.lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
08-05 16:41:54.484: E/AndroidRuntime(24979): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.careandcure"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.careandcure.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.careandcure.MapsViewActivity" >
</activity>
<!-- Goolge Maps API Key -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="api_key" />
</application>
</manifest>
I am not getting where I am getting wrong or missing anything and
how to remove please help me in solving this issue.
The Log say you:
Caused by: java.lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
So be sure that you added it in AndroidManifest.xml like in the guide:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="API_KEY"/>
In your manifest file error cause this line
<!-- Goolge Maps API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my api key" />
In value of API key you must add your own API key.
See This link for generate API key
Clearly from your logcat, you have just copy pasted the manifest.xml file. You have to enter your key instead of your API key
Generate your key from google console. And use it in manifest.xml
You will need two metadata for version2 of googlemap
One with api key and another with google service
android:value="#integer/google_play_services_version"
So you should simply copy paste the line. And only try to under stand later.
:-)
Edited:
Change the package name to yours (not of androidhive :-)) Change the line in permission
<permission
android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
To:
<permission
android:name="com.example.careandcure.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
Also why are you using package name of info.androidhive.googlemapsv2 in uses-permission. Change it to your own package name i.e. com.example.careandcure . Hope it's finally your solution.

Google Play Service library and Google Maps

I try to create a simple GoogleMap by Using Google Play Service and Google Maps API. But all the times I get errors...
I´m working with IntelliJ 12.1, here my full Code:
RecorderMap.java
package com.example.GPSApp;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class RecorderMap extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
}
}
map.xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.maps.SupportMapFragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.GPSApp"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="16" />
<permission
android:name="com.example.GPSApp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application android:label="#string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".RecorderMap"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="XXX" />
</application>
</manifest>
I think the Problem is how I include the GooGlePlayService... I´ve tried to add as module, as libary as External Libary but I don't know how to include and to use it right... :(
EDIT:
LogCat
08-28 07:41:59.869: ERROR/AndroidRuntime(23080): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.GPSApp/com.example.GPSApp.RecorderMap}: android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.gms.maps.SupportMapFragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.gms.maps.SupportMapFragment
at android.view.LayoutInflater.createView(LayoutInflater.java:508)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:210)
at android.app.Activity.setContentView(Activity.java:1660)
at com.example.GPSApp.RecorderMap.onCreate(RecorderMap.java:18)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
... 11 more
Caused by: java.lang.NoSuchMethodException: SupportMapFragment(Context,AttributeSet)
at java.lang.Class.getMatchingConstructor(Class.java:643)
at java.lang.Class.getConstructor(Class.java:472)
at android.view.LayoutInflater.createView(LayoutInflater.java:480)
... 20 more
****EDIT2**
Problem solved by using this: java.lang.noclassdeffounderror: com.google.android.gms.R$styleable**
The only thing I find missing in your RecorderMap.java file is that you haven't imported the SupportFragment class. So add this line to it
import com.google.android.gms.maps.SupportMapFragment;
If that doesn't work, then check out the following.
From what you are saying, it means you have already installed the google play services. If not, then try installing it using this link http://developer.android.com/google/play-services/setup.html
After that, referencing the google play services library should be as easy as editing your build.gradle file. The current version of android studio makes this possible. Under dependencies in your build.gradle file, add the following code
compile 'com.google.android.gms:play-services:3.1.36'
You seem to have your API key intact.
Finally, remember you need to test your app on an actual android device and not an emulator. The android API version 2 is not yet able to display maps on emulators.
I think this should be okay for your app to work.

google maps android api v2 using supportmapfragment

I tried to install project present in tutorial:
All It's ok but when run project, logcat say:
"Could not find class 'maps.ag.l', referenced from method maps.ah.an.a"
The map is empty and logcat say:
" Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
I have changed package name from "in.wptrafficanalyzer.locationgooglemapv2demo" to "it.appatwork" and i have got the apikey for android maps apiV2 with my sha1.
I have android 2.3.3
Please help me!
Mainactivity:
package it.appatwork.locationgooglemapv2demo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable (getApplicationContext());
if(status == ConnectionResult.SUCCESS) {
System.out.println("ok");
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
AndoridManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.appatwork.locationgooglemapv2demo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<permission
android:name="it.appatwork.locationgooglemapv2demo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="it.appatwork.locationgooglemapv2demo.permission.MAPS_RECEIVE"/>
<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"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="it.appatwork.locationgooglemapv2demo.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBgkEwv0Z4O2t27avrve_33N33QY0wHNXg"/>
</application>
</manifest>
UPDATE:
this is the logcat output:
07-24 23:11:40.849: W/dalvikvm(6472): VFY: unable to resolve instance field 24
07-24 23:11:41.149: W/dalvikvm(6472): Unable to resolve superclass of Lmaps/p/w; (718)
07-24 23:11:41.149: W/dalvikvm(6472): Link of class 'Lmaps/p/w;' failed
07-24 23:11:41.149: W/dalvikvm(6472): Unable to resolve superclass of Lmaps/aq/as; (5347)
07-24 23:11:41.149: W/dalvikvm(6472): Link of class 'Lmaps/aq/as;' failed
07-24 23:11:41.149: W/dalvikvm(6472): Unable to resolve superclass of Lmaps/ag/l; (4576)
07-24 23:11:41.149: W/dalvikvm(6472): Link of class 'Lmaps/ag/l;' failed
07-24 23:11:41.149: E/dalvikvm(6472): Could not find class 'maps.ag.l', referenced from method maps.ah.an.a
07-24 23:11:41.149: W/dalvikvm(6472): VFY: unable to resolve new-instance 4420 (Lmaps/ag/l;) in Lmaps/ah/an;
07-24 23:11:41.359: I/ApplicationPackageManager(6472): cscCountry is not German : WIN
07-24 23:11:47.069: W/Google Maps Android API(6472): Please add <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> into AndroidManifest.xml to ensure correct behavior under poor connectivity conditions.
07-24 23:11:47.069: I/Google Maps Android API(6472): Failed to contact Google servers. Another attempt will be made when connectivity is established.
07-24 23:11:59.009: W/IInputConnectionWrapper(6472): getExtractedText on inactive InputConnection
07-24 23:11:59.009: W/IInputConnectionWrapper(6472): getExtractedText on inactive InputConnection
07-24 23:12:02.289: E/Google Maps Android API(6472): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
First of all the two problem you are describing are not related one to another, you main problem is here:
Failed to load map. Error contacting Google servers. This is probably
an authentication issue (but could be due to network errors).
This means that you have some kind of problem with you permissions in the manifest file, or with you configuration in the Google API's console.
Please go over all the steps of this two blog post, Google Maps API V2 key and Google Maps API V2, and commit all the steps, if you still have problems post here your code and updated logcat message.
UPDATE:
You package name:
package="it.appatwork.locationgooglemapv2demo"
does not match the package name you specified in the permissions:
permission
android:name="it.appatwork.LocationGoogleMapV2Demo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="it.appatwork.LocationGoogleMapV2Demo.permission.MAPS_RECEIVE"/>
I think it's case-sensitive so try to change it to:
permission
android:name="it.appatwork.locationgooglemapv2demo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="it.appatwork.locationgooglemapv2demo.permission.MAPS_RECEIVE"/>

Google Map API v2 inflator fails on old phones

I have just implemented a map in the application, and it runs flawlessly in a Galaxy S3. Testing my app with an old phone HTC Sense with API8 the app throws a inflator problem. I think it may be related to either the OS or OGL2. isGooglePlayServicesAvailable(this) returns a correct value. Help me here, please:
Activity.java
public class MyActivity extends Activity
{
#Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.initializeInterface();
}
private void initializeInterface() {
final int available = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
this.setContentView(R.layout.main);
}
}
main.xml
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
class="com.google.android.gms.maps.MapFragment"
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/footer"
android:layout_below="#id/header" />
manifest.xml
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.stuff.permission.MAPS_RECEIVE" />
<permission
android:name="com.stuff.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:icon="#drawable/icon"
android:label="#string/application_name" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/map_api_key_device"/>
<activity
android:name=".MyActivity"
android:configChanges="orientation"
android:launchMode="singleTop"
android:theme="#android:style/Theme.NoTitleBar" >
<intent-filter> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Error
12-13 12:14:13.865: E/My ERROR(22878): Binary XML file line #85: Error inflating class fragment
12-13 12:14:13.875: E/android.view.LayoutInflater.createViewFromTag(22878): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
12-13 12:14:13.895: E/android.view.LayoutInflater.rInflate(22878): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
12-13 12:14:13.915: E/android.view.LayoutInflater.inflate(22878): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
12-13 12:14:13.915: E/android.view.LayoutInflater.inflate(22878): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-13 12:14:13.935: E/android.view.LayoutInflater.inflate(22878): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
12-13 12:14:13.945: E/com.android.internal.policy.impl.PhoneWindow.setContentView(22878): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
12-13 12:14:13.945: E/android.app.Activity.setContentView(22878): at android.app.Activity.setContentView(Activity.java:1654)
It has to do with the fact that you are trying to use native API Level 11 fragments on an API Level 8 device. Switch to FragmentActivity and SupportMapFragment if you wish to have your code work on earlier versions than Android 3.0.
I solved this problem by adding the v13 libraries from /extras/android/compatibility/v13 and changing my Activity to FragmentActivity and MapFragment to SupportMapFragment.
for me help app project -> right click -> properties -> android -> project build target -> and chack earlier android release. (with google api)
if you dont have, download one by SDK manager

Categories

Resources