Unfortunately, the application has stopped using google map api v2 for Android

I tried three days, but the problem is not solved! I made the application using Google v2 API maps, I successfully activated it ...

Now, when I run my program, it shows this error: "Unfortunately, the applications have stopped"

please help, what is this error?

Here is the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.maps"
    android:versionCode="1"
    android:versionName="1.0" >

    <permission
        android:name="com.example.maps.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <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"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
     Google Maps Android API v2, but are recommended. -->
    <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="com.example.maps.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="AIzaSyCKewNqqmmp2gwcLuefCAXrTRdQjm-6t-U" />
    </application>

</manifest>

Here is the 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
        android:id="@+id/map"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:clickable="true" />

</RelativeLayout>

Here is the main function:

package com.example.maps;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

public class MainActivity extends FragmentActivity{

SupportMapFragment mMap;
private GoogleMap googleMap;

  @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    googleMap = (SupportMapFragment) getSupportFragmentManager() //Now, here showing an error "cannot convert from SupportMapFragment to GoogleMap" and can't run this program.
            .findFragmentById(R.id.map).getMap();
  }
}

Here is the log file:

02-19 05:08:50.393: I/Process(1405): Sending signal. PID: 1405 SIG: 9
02-19 05:15:42.608: E/dalvikvm(1447): Could not find class 'com.google.android.gms.maps.SupportMapFragment', referenced from method com.example.maps.MainActivity.onCreate
02-19 05:15:42.608: E/dalvikvm(1447): Could not find class 'com.google.android.gms.maps.SupportMapFragment', referenced from method com.example.maps.MainActivity.onCreate
02-19 05:15:42.608: W/dalvikvm(1447): VFY: unable to resolve check-cast 728 (Lcom/google/android/gms/maps/SupportMapFragment;) in Lcom/example/maps/MainActivity;
02-19 05:15:42.696: D/dalvikvm(1447): VFY: replacing opcode 0x1f at 0x0012
02-19 05:15:43.308: D/AndroidRuntime(1447): Shutting down VM
02-19 05:15:43.308: W/dalvikvm(1447): threadid=1: thread exiting with uncaught exception (group=0xa4be8648)
02-19 05:15:43.348: E/AndroidRuntime(1447): FATAL EXCEPTION: main
02-19 05:15:43.348: E/AndroidRuntime(1447): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maps/com.example.maps.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.os.Looper.loop(Looper.java:137)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.ActivityThread.main(ActivityThread.java:5103)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at java.lang.reflect.Method.invokeNative(Native Method)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at java.lang.reflect.Method.invoke(Method.java:525)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at dalvik.system.NativeStart.main(Native Method)
02-19 05:15:43.348: E/AndroidRuntime(1447): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.Activity.setContentView(Activity.java:1895)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at com.example.maps.MainActivity.onCreate(MainActivity.java:17)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.Activity.performCreate(Activity.java:5133)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
02-19 05:15:43.348: E/AndroidRuntime(1447):     ... 11 more
02-19 05:15:43.348: E/AndroidRuntime(1447): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.Fragment.instantiate(Fragment.java:592)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.Fragment.instantiate(Fragment.java:560)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.Activity.onCreateView(Activity.java:4738)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
02-19 05:15:43.348: E/AndroidRuntime(1447):     ... 21 more
02-19 05:15:43.348: E/AndroidRuntime(1447): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file "/data/app/com.example.maps-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.maps-2, /system/lib]]
02-19 05:15:43.348: E/AndroidRuntime(1447):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-19 05:15:43.348: E/AndroidRuntime(1447):     at android.app.Fragment.instantiate(Fragment.java:582)
02-19 05:15:43.348: E/AndroidRuntime(1447):     ... 24 more
02-19 05:15:53.760: I/Process(1447): Sending signal. PID: 1447 SIG: 9
+3
source share
4 answers

In your code, you must inflate your card into GoogleMap, which itself has now become Fragment, except that you are inflating it onto SupportMapFragment.

Change the following lines:

 mMap = (SupportMapFragment) getSupportFragmentManager()
    .findFragmentById(R.id.map);

    googleMap = mMap.getMap();

As below:

 googleMap = (SupportMapFragment) getSupportFragmentManager()
    .findFragmentById(R.id.map).getMap();

GoogleMap, SupportMapFragment. SupportMapFragment, , Fragment . getMap(), GoogleMap.

:

, .

play-services-libs . enter image description here

.

enter image description here

0

Google , ,

0

xml

android:name="com.google.android.gms.maps.SupportMapFragment"

class="com.google.android.gms.maps.SupportMapFragment"

manifest application tag

<meta-data
     android:name="com.google.android.gms.version"
     android:value="@integer/google_play_services_version" />

google-play-sevice-lib ,

enter image description herecheck ur API-Keygenerated in Google consoleusing SHA-1 computer, ur package name

EDIT:

How to import google_play_services_libmake sureur project and library present in same worksapce

0
source

the right shot decided to answer , unfortunately, when the application was stopped while running the google play api services:

Primary activity:

import com.google.android.gms.location.LocationListener;

instead

 import android.location.LocationListener;

use them in dependencies: (build gradle file)

    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.google.android.gms:play-services:11.0.1'
    compile 'com.android.support:multidex:1.0.0'

Android manifest file:

  <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />

   <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
0
source

All Articles