简体   繁体   中英

Android Google Play Services error: didn't find class com.google.android.gms.maps.mapfragment on path dexpathlist

I know this issue gets reported pretty frequently, and the simple, oft-recommended solution is to check how I'm referencing the google play services library. However, I'm pretty confident that I've got all my bases covered. I've literally lost sleep over this error, so any advice is certainly appreciated. Thanks in advance.

First, here's my stack trace:

02-06 15:32:12.577: E/AndroidRuntime(17070): java.lang.RuntimeException: Unable to start activity ComponentInfo{raj.wifiapp/raj.wifiapp.MainActivity}: android.view.InflateException: Binary XML file line #29: Error inflating class fragment
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2438)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2497)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.ActivityThread.access$900(ActivityThread.java:168)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1306)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.os.Handler.dispatchMessage(Handler.java:102)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.os.Looper.loop(Looper.java:146)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.ActivityThread.main(ActivityThread.java:5678)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at java.lang.reflect.Method.invokeNative(Native Method)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at java.lang.reflect.Method.invoke(Method.java:515)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at dalvik.system.NativeStart.main(Native Method)
02-06 15:32:12.577: E/AndroidRuntime(17070): Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class fragment
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.view.LayoutInflater.inflate(Native Method)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.Activity.setContentView(Activity.java:2063)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at raj.wifiapp.MainActivity.onCreate(MainActivity.java:58)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.Activity.performCreate(Activity.java:5586)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2402)
02-06 15:32:12.577: E/AndroidRuntime(17070):    ... 12 more
02-06 15:32:12.577: E/AndroidRuntime(17070): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.Fragment.instantiate(Fragment.java:597)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.Fragment.instantiate(Fragment.java:561)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.Activity.onCreateView(Activity.java:5111)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
02-06 15:32:12.577: E/AndroidRuntime(17070):    ... 25 more
02-06 15:32:12.577: E/AndroidRuntime(17070): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: DexPathList[[zip file "/data/app/raj.wifiapp-8.apk"],nativeLibraryDirectories=[/data/app-lib/raj.wifiapp-8, /vendor/lib, /system/lib]]
02-06 15:32:12.577: E/AndroidRuntime(17070):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
02-06 15:32:12.577: E/AndroidRuntime(17070):    at android.app.Fragment.instantiate(Fragment.java:583)
02-06 15:32:12.577: E/AndroidRuntime(17070):    ... 28 more

Here's my manifest:

  <?xml version="1.0" encoding="utf-8"?> <manifest package="raj.wifiapp" android:versionCode="1" android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-sdk android:minSdkVersion="12" android:targetSdkVersion="19" /> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <permission android:name="raj.wifiapp.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="raj.wifiapp.permission.MAPS_RECEIVE" /> <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_FINE_LOCATION" /> <application 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" /> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyAaizOmaOj15uOjUmNA4OnowrOLv88_vKI" /> <activity android:name="raj.wifiapp.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="raj.wifiapp.Tracker"> <category android:name="android.intent.category.Default" /> </activity> </application> </manifest> 

here's my layout:

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:map="http://schemas.android.com/apk/res-auto" android:id="@+id/layout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="14dp" android:text="Switch views" /> <Button android:id="@+id/btn" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="17dp" android:text="Scan" /> <fragment android:id="@+id/map" android:name="com.google.android.gms.maps.MapFragment" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout> 

My reputation is less than 10, so I'm gonna post links to screenshots of my build path.

i.stack.imgur.com slash e9F9d.png

i.stack.imgur.com slash wESAc.png

i.stack.imgur.com slash Vb5Vc.png

The error is occuring because you have not added the Google Play Services library in your app project. Please follow the following tutorial to add Google Play Services in your app to get the Google Maps work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM