android - Getting error "java.lang.RuntimeException: Unable to start activity" in my app -
my application worked yesterday, cant figure out why stopped working. thing tried doing create signed apk. had create new google maps key , place manifest file. done following google developers tutorial. when try run app start up, click button , force closes.
this error log:
03-20 23:31:33.636 10036-10036/project.sharethefare e/androidruntime﹕ fatal exception: main process: project.sharethefare, pid: 10036 java.lang.runtimeexception: unable start activity componentinfo{project.sharethefare/project.sharethefare.currentlocation}: android.view.inflateexception: binary xml file line #9: error inflating class fragment @ android.app.activitythread.performlaunchactivity(activitythread.java:2658) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2725) @ android.app.activitythread.access$900(activitythread.java:172) @ android.app.activitythread$h.handlemessage(activitythread.java:1422) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:145) @ android.app.activitythread.main(activitythread.java:5834) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1388) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1183) caused by: android.view.inflateexception: binary xml file line #9: error inflating class fragment @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:770) @ android.view.layoutinflater.rinflate(layoutinflater.java:813) @ android.view.layoutinflater.inflate(layoutinflater.java:511) @ android.view.layoutinflater.inflate(layoutinflater.java:415) @ android.view.layoutinflater.inflate(layoutinflater.java:366) @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:428) @ android.app.activity.setcontentview(activity.java:2241) @ project.sharethefare.currentlocation.oncreate(currentlocation.java:24) @ android.app.activity.performcreate(activity.java:6221) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1119) @ android.app.activitythread.performlaunchactivity(activitythread.java:2611) at android.app.activitythread.handlelaunchactivity(activitythread.java:2725) at android.app.activitythread.access$900(activitythread.java:172) at android.app.activitythread$h.handlemessage(activitythread.java:1422) at android.os.handler.dispatchmessage(handler.java:102) at android.os.looper.loop(looper.java:145) at android.app.activitythread.main(activitythread.java:5834) at java.lang.reflect.method.invoke(native method) at java.lang.reflect.method.invoke(method.java:372) at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1388) at com.android.internal.os.zygoteinit.main(zygoteinit.java:1183) caused by: java.lang.runtimeexception: api key can specified once. recommended use meta-data tag name: com.google.android.maps.v2.api_key in <application> element of androidmanifest.xml @ com.google.maps.api.android.lib6.gmm6.c.g.a(unknown source) @ com.google.maps.api.android.lib6.c.i.a(unknown source) @ com.google.maps.api.android.lib6.c.el.a(unknown source) @ com.google.maps.api.android.lib6.c.ab.a(unknown source) @ com.google.maps.api.android.lib6.c.aa.a(unknown source) @ com.google.android.gms.maps.internal.x.ontransact(sourcefile:107) @ android.os.binder.transact(binder.java:380) @ com.google.android.gms.maps.internal.imapfragmentdelegate$a$a.oncreateview(unknown source) @ com.google.android.gms.maps.supportmapfragment$a.oncreateview(unknown source) @ com.google.android.gms.dynamic.a$4.b(unknown source) @ com.google.android.gms.dynamic.a.a(unknown source) @ com.google.android.gms.dynamic.a.oncreateview(unknown source) @ com.google.android.gms.maps.supportmapfragment.oncreateview(unknown source) @ android.support.v4.app.fragment.performcreateview(fragment.java:1786) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:920) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1104) @ android.support.v4.app.fragmentmanagerimpl.addfragment(fragmentmanager.java:1206) @ android.support.v4.app.fragmentmanagerimpl.oncreateview(fragmentmanager.java:2159) @ android.support.v4.app.fragmentactivity.oncreateview(fragmentactivity.java:297) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:734) at android.view.layoutinflater.rinflate(layoutinflater.java:813) at android.view.layoutinflater.inflate(layoutinflater.java:511) at android.view.layoutinflater.inflate(layoutinflater.java:415) at android.view.layoutinflater.inflate(layoutinflater.java:366) at com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:428) at android.app.activity.setcontentview(activity.java:2241) at project.sharethefare.currentlocation.oncreate(currentlocation.java:24) at android.app.activity.performcreate(activity.java:6221) at android.app.instrumentation.callactivityoncreate(instrumentation.java:1119) at android.app.activitythread.performlaunchactivity(activitythread.java:2611) at android.app.activitythread.handlelaunchactivity(activitythread.java:2725) at android.app.activitythread.access$900(activitythread.java:172) at android.app.activitythread$h.handlemessage(activitythread.java:1422) at android.os.handler.dispatchmessage(handler.java:102) at android.os.looper.loop(looper.java:145) at android.app.activitythread.main(activitythread.java:5834) at java.lang.reflect.method.invoke(native method) at java.lang.reflect.method.invoke(method.java:372) at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1388) at com.android.internal.os.zygoteinit.main(zygoteinit.java:1183)
this currentlocation class:
package project.sharethefare; import android.content.intent; import android.support.v4.app.fragmentactivity; import android.os.bundle; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.supportmapfragment; import com.google.android.gms.maps.model.latlng; import android.location.location; import android.view.view; public class currentlocation extends fragmentactivity { private googlemap mmap; // might null if google play services apk not available. //________________________________________________________________________________________ @override protected void oncreate(bundle savedinstancestate) { //auto generated super.oncreate(savedinstancestate); setcontentview(r.layout.activity_current_location); setupmapifneeded(); //part of google maps api mmap.setmylocationenabled(true); //creates new homescreen } @override protected void onresume() { //auto generated super.onresume(); setupmapifneeded(); //set map if not created } /** * sets map if possible (i.e., google play services apk correctly * installed) , map has not been instantiated.. ensure ever * call {@link #setupmap()} once when {@link #mmap} not null. * <p/> * if isn't installed {@link supportmapfragment} (and * {@link com.google.android.gms.maps.mapview mapview}) show prompt user * install/update google play services apk on device. * <p/> * user can return fragmentactivity after following prompt , correctly * installing/updating/enabling google play services. since fragmentactivity may not * have been destroyed during process (it * stopped or paused), {@link #oncreate(bundle)} may not called again should call * method in {@link #onresume()} guarantee called. */ private void setupmapifneeded() { // null check confirm have not instantiated map. if (mmap == null) { // try obtain map supportmapfragment. mmap = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.curlocmap)) .getmap(); // check if successful in obtaining map. if (mmap != null) { setupmap(); } } } /** * can add markers or lines, add listeners or move camera. in case, * add marker near africa. * <p/> * should called once , when sure {@link #mmap} not null. */ //call method continuously check current location private void setupmap() { mmap.setonmylocationchangelistener(mylocationchangelistener); } //called above. used update users position on map private googlemap.onmylocationchangelistener mylocationchangelistener = new googlemap.onmylocationchangelistener() { @override public void onmylocationchange(location location) { //create new latitude , longitude point latlng loc = new latlng(location.getlatitude(), location.getlongitude()); //make global variables on home screen == current location homescreen.curlat = location.getlatitude(); homescreen.curlong = location.getlongitude(); homescreen.curlocset = true; //animate camera zoom in on position when found mmap.animatecamera(cameraupdatefactory.newlatlngzoom(loc, 16.0f)); } }; public void backtohome(view view){ // called when button clicked. returns homescreen activity intent intent = new intent(currentlocation.this,homescreen.class); startactivity(intent); } }
this corresponding xml file:
<linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" xmlns:android="http://schemas.android.com/apk/res/android" android:background="#000"> <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_margintop="60dp" android:layout_marginbottom="50dp" android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/curlocmap" tools:context="project.sharethefare.currentlocation" android:name="com.google.android.gms.maps.supportmapfragment"/> <button android:layout_width="wrap_content" android:layout_height="50dp" android:layout_marginleft="30dp" android:layout_marginright="30dp" android:layout_marginbottom="70dp" android:text="@string/set_cur_loc" android:textsize="20sp" android:onclick="backtohome" android:background="@drawable/button_design" android:textstyle="bold"/> </linearlayout>
and manifest file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="project.sharethefare" > <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" /> <uses-feature android:glesversion="0x00020000" android:required="true" /> <!-- access_coarse/fine_location 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" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".homescreen" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> </intent-filter> </activity> <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="" /> <activity android:name=".currentlocation" android:label="@string/title_activity_current_location" > </activity> <activity android:name=".destination" android:label="@string/title_activity_maps" > </activity> <activity android:name=".share" android:label="@string/title_activity_share" > </activity> <activity android:name=".splashscreen" 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.geo.api_key" android:value=""/> </application> </manifest>
caused by: java.lang.runtimeexception: api key can specified once. recommended use meta-data tag name: com.google.android.maps.v2.api_key in <application> element of androidmanifest.xml
based upon error message, delete manifest:
<meta-data android:name="com.google.android.geo.api_key" android:value="aizasycgocmqbnnbud_6heb5dmtfhxpaxmmjjtk"/>
Comments
Post a Comment