我在尝试将Google地图应用到我的应用时遇到问题,请参阅下面的详细信息,我们将不胜感激。
Activity.xml(activity_locate_store):
<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.SupportMapFragment"/>
Activity.java(LocateStore):
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class LocateStore extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_locate_store);
}
Mainfest.xml
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my_key_goes_here" />
<meta-data
android:name="com.google.android.gms.v2"
android:value="4242000" />
来自Google Lib的Android价值(Google Play服务 - 资源/价值):
<resources>
<integer name="google_play_services_version">4242000</integer>
logcat的:
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment 04-10 17:23:41.787: E/AndroidRuntime(794):
Caused by: android.support.v4.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
Logcat更新:
04-10 17:41:47.130: E/ActivityThread(625): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d16440 that was originally bound here
04-10 17:41:47.130: E/ActivityThread(625): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d16440 that was originally bound here
04-10 17:41:47.130: E/ActivityThread(625): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
04-10 17:41:47.130: E/ActivityThread(625): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
04-10 17:41:47.130: E/ActivityThread(625): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
04-10 17:41:47.130: E/ActivityThread(625): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
04-10 17:41:47.130: E/ActivityThread(625): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
04-10 17:41:47.130: E/ActivityThread(625): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
04-10 17:41:47.130: E/ActivityThread(625): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
04-10 17:41:47.130: E/ActivityThread(625): at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
04-10 17:41:47.130: E/ActivityThread(625): at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
04-10 17:41:47.130: E/ActivityThread(625): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
04-10 17:41:47.130: E/ActivityThread(625): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
04-10 17:41:47.130: E/ActivityThread(625): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
04-10 17:41:47.130: E/ActivityThread(625): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-10 17:41:47.130: E/ActivityThread(625): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-10 17:41:47.130: E/ActivityThread(625): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-10 17:41:47.130: E/ActivityThread(625): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-10 17:41:47.130: E/ActivityThread(625): at java.lang.Thread.run(Thread.java:856)
04-10 17:41:47.160: E/StrictMode(625): null
04-10 17:41:47.160: E/StrictMode(625): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d16440 that was originally bound here
04-10 17:41:47.160: E/StrictMode(625): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
04-10 17:41:47.160: E/StrictMode(625): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
04-10 17:41:47.160: E/StrictMode(625): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
04-10 17:41:47.160: E/StrictMode(625): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
04-10 17:41:47.160: E/StrictMode(625): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
04-10 17:41:47.160: E/StrictMode(625): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
04-10 17:41:47.160: E/StrictMode(625): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
04-10 17:41:47.160: E/StrictMode(625): at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
04-10 17:41:47.160: E/StrictMode(625): at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
04-10 17:41:47.160: E/StrictMode(625): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
04-10 17:41:47.160: E/StrictMode(625): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
04-10 17:41:47.160: E/StrictMode(625): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
04-10 17:41:47.160: E/StrictMode(625): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-10 17:41:47.160: E/StrictMode(625): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-10 17:41:47.160: E/StrictMode(625): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-10 17:41:47.160: E/StrictMode(625): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-10 17:41:47.160: E/StrictMode(625): at java.lang.Thread.run(Thread.java:856)
04-10 17:41:47.160: W/ActivityManager(290): Unbind failed: could not find connection for android.os.BinderProxy@40ebb860
04-10 17:41:47.180: E/ActivityThread(625): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d16098 that was originally bound here
04-10 17:41:47.180: E/ActivityThread(625): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d16098 that was originally bound here
04-10 17:41:47.180: E/ActivityThread(625): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
04-10 17:41:47.180: E/ActivityThread(625): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
04-10 17:41:47.180: E/ActivityThread(625): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
04-10 17:41:47.180: E/ActivityThread(625): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
04-10 17:41:47.180: E/ActivityThread(625): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
04-10 17:41:47.180: E/ActivityThread(625): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
04-10 17:41:47.180: E/ActivityThread(625): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
04-10 17:41:47.180: E/ActivityThread(625): at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
04-10 17:41:47.180: E/ActivityThread(625): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
04-10 17:41:47.180: E/ActivityThread(625): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
04-10 17:41:47.180: E/ActivityThread(625): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
04-10 17:41:47.180: E/ActivityThread(625): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-10 17:41:47.180: E/ActivityThread(625): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-10 17:41:47.180: E/ActivityThread(625): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-10 17:41:47.180: E/ActivityThread(625): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-10 17:41:47.180: E/ActivityThread(625): at java.lang.Thread.run(Thread.java:856)
: E/(): Device disconnected
Logcat Update2:
04-10 18:10:30.357:E / AndroidRuntime(794):引起:android.view.InflateException:二进制XML文件行#2:错误膨胀类片段 04-10 18:10:30.357:E / AndroidRuntime(794):引起:java.lang.IllegalStateException:应用程序的AndroidManifest.xml中的元数据标签没有正确的值。预期4242000但找到0.您必须在元素中包含以下声明:
答案 0 :(得分:1)
Google的文档可能已过时,但developers.google.com/maps/documentation/android / ...表示元数据项的名称应为:“com.google.android.gms.version”。您是否尝试过更改元数据名称?