gpt4 book ai didi

java - 由 : android. support.v4.app.Fragment$InstantiationException 引起:无法实例化 fragment

转载 作者:行者123 更新时间:2023-12-01 13:09:31 29 4
gpt4 key购买 nike

我在尝试在我的应用中实现 Google map 时遇到问题,请参阅下面的详细信息,我们将不胜感激。

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 值(value)(Google Play 服务 - res/value):

<resources>
<integer name="google_play_services_version">4242000</integer>

日志猫:

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更新2:

04-10 18:10:30.357: E/AndroidRuntime(794): 导致: android.view.InflateException: 二进制 XML 文件行 #2: 膨胀类 fragment 时出错04-10 18:10:30.357: E/AndroidRuntime(794): 原因: java.lang.IllegalStateException: 应用程序的 AndroidManifest.xml 中的元数据标记没有正确的值。预期为 4242000,但实际结果为 0。元素中必须包含以下声明:

最佳答案

Google 的文档可能已过时,但developers.google.com/maps/documentation/android/… 表示元数据项的名称应为:“com.google.android.gms.version”。您是否尝试过将元数据名称更改为该名称?

关于java - 由 : android. support.v4.app.Fragment$InstantiationException 引起:无法实例化 fragment ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22995106/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com