ClassNotFoundException: com.google.android.gms.maps.MapFragment with AndroidStudio -
i'm trying use google maps v2 on android app. i'm using android studio; followed steps indicated here: https://developers.google.com/maps/documentation/android/start#overview
in androidmanifest.xml i've:
<uses-sdk android:minsdkversion="12" android:targetsdkversion="16" /> <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" /> <!-- following 2 permissions not required use google maps android api v2, 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" />
on build.gradle i've:
android { compilesdkversion 17 buildtoolsversion "17.0.0" defaultconfig { minsdkversion 12 targetsdkversion 16 } } dependencies { compile 'com.android.support:support-v4:18.0.0' compile 'com.google.android.gms:play-services:3.1.36' }
my first activity:
public class homeactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.home); }
}
my layout:
<?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.google.android.gms.maps.mapfragment" />
i can compile project when try deploy phone i've exception:
09-03 17:28:08.604 9787-9787/? e/androidruntime: fatal exception: main java.lang.runtimeexception: unable start activity componentinfo{it.mobile/it.mobile.homeactivity}: android.view.inflateexception: binary xml file line #2: error inflating class fragment @ android.app.activitythread.performlaunchactivity(activitythread.java:2184) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2211) @ android.app.activitythread.access$600(activitythread.java:149) @ android.app.activitythread$h.handlemessage(activitythread.java:1300) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:153) @ android.app.activitythread.main(activitythread.java:5086) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:821) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:584) @ dalvik.system.nativestart.main(native method) caused by: android.view.inflateexception: binary xml file line #2: error inflating class fragment @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704) @ android.view.layoutinflater.inflate(layoutinflater.java:466) @ android.view.layoutinflater.inflate(layoutinflater.java:396) @ android.view.layoutinflater.inflate(layoutinflater.java:352) @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:258) @ android.app.activity.setcontentview(activity.java:1867) @ it.mobile.homeactivity.oncreate(homeactivity.java:12) @ android.app.activity.performcreate(activity.java:5020) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) @ android.app.activitythread.performlaunchactivity(activitythread.java:2148) ... 11 more caused by: android.app.fragment$instantiationexception: unable instantiate fragment com.google.android.gms.maps.mapfragment: make sure class name exists, public, , has empty constructor public @ android.app.fragment.instantiate(fragment.java:584) @ android.app.fragment.instantiate(fragment.java:552) @ android.app.activity.oncreateview(activity.java:4668) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:680) ... 20 more caused by: java.lang.classnotfoundexception: com.google.android.gms.maps.mapfragment @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:61) @ java.lang.classloader.loadclass(classloader.java:501) @ java.lang.classloader.loadclass(classloader.java:461) @ android.app.fragment.instantiate(fragment.java:574) ... 23 more
in properties of project check export support library , google services library.
thanks
at end solved problem recreating new project in android studio. not sure problem.
Comments
Post a Comment