gpt4 book ai didi

Android 谷歌地图 fragment 崩溃

转载 作者:太空狗 更新时间:2023-10-29 14:22:42 25 4
gpt4 key购买 nike

如 Google 教程所述,我已将 Google Maps V2 嵌入到我的应用程序中。

切换到 map fragment 时出现以下错误。

03-08 12:52:01.600: E/AndroidRuntime(30314):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2105)

03-08 12:52:01.600: E/AndroidRuntime(30314): FATAL EXCEPTION: main

03-08 12:52:01.600: E/AndroidRuntime(30314): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{de.arvidg.exampleactionbartabs/de.arvidg.exampleactionbartabs.StartActivity}:
java.lang.ClassNotFoundException: de.arvidg.exampleactionbartabs.StartActivity

这是源码

package de.arvidg.exampleactionbartabs;

import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.maps.MapActivity;

import data.Device;
import data.Mission;
import de.arvidg.exampleactionbartabs.R;
import logic.FetchData;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

public class MapFrag extends MapFragment {

protected FetchData thread;
protected Device device;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

final View lView = inflater.inflate(R.layout.map, container,
false);

return lView;

}

public void setDumb() {

}

public Device getDevice() {
return device;
}

public void setDevice(Device device) {
this.device = device;
}

}


<?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"
class="com.google.android.gms.maps.SupportMapFragment"/>

我的 list

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.arvidg.exampleactionbartabs"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="14" />

<permission
android:name="de.arvidg.exampleactionbartabs.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />

<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />

<uses-permission android:name="de.arvidg.exampleactionbartabs.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".StartActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MapFrag"
android:label="Map"
android:theme="@android:style/Theme.Holo" >
<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.maps.v2.API_KEY"
android:value="removed" />

<uses-library android:name="com.google.android.maps" />
</application>

</manifest>

最佳答案

改变

android:name="com.google.android.gms.maps.MapFragment"/>

android:name="com.google.android.gms.maps.SupportMapFragment"/> activity_main.xml

和改变

公共(public)类 MainActivity 扩展 Activity

public class MainActivity extends FragmentActivity in MainActivity.java

这两个修复对我有用。

关于Android 谷歌地图 fragment 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15293450/

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