Google マップ V2 を自分のアプリケーションに統合する際に、クラス フラグメントの膨張に直面してエラーが発生しました。
私は、
- SHA1 ハッシュを取得し、Android 用のマップ キーを作成しました。
- google-play-services をライブラリ プロジェクトとしてインポートし (ワークスペースにコピー)、参照ライブラリとして追加しました。
さまざまな解決策を検討しましたが、私の問題を解決するものは何もありません。誰でもこれについて私を助けることができますか?ヘルプは本当にかなりのものです。前もって感謝します!
04-07 09:14:56.387: E/AndroidRuntime(13151): FATAL EXCEPTION: main
04-07 09:14:56.387: E/AndroidRuntime(13151): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.toyota.dealerparking/com.toyota.dealerparking.GMapActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.os.Looper.loop(Looper.java:130)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.app.ActivityThread.main(ActivityThread.java:3687)
04-07 09:14:56.387: E/AndroidRuntime(13151): at java.lang.reflect.Method.invokeNative(Native Method)
04-07 09:14:56.387: E/AndroidRuntime(13151): at java.lang.reflect.Method.invoke(Method.java:507)
04-07 09:14:56.387: E/AndroidRuntime(13151): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-07 09:14:56.387: E/AndroidRuntime(13151): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-07 09:14:56.387: E/AndroidRuntime(13151): at dalvik.system.NativeStart.main(Native Method)
04-07 09:14:56.387: E/AndroidRuntime(13151): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-07 09:14:56.387: E/AndroidRuntime(13151): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.app.Activity.setContentView(Activity.java:1657)
04-07 09:14:56.387: E/AndroidRuntime(13151): at com.toyota.dealerparking.GMapActivity.onCreate(GMapActivity.java:11)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
04-07 09:14:56.387: E/AndroidRuntime(13151): ... 11 more
04-07 09:14:56.387: E/AndroidRuntime(13151): 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
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-07 09:14:56.387: E/AndroidRuntime(13151): ... 19 more
04-07 09:14:56.387: E/AndroidRuntime(13151): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment in loader dalvik.system.PathClassLoader[/data/app/com.toyota.dealerparking-2.apk]
04-07 09:14:56.387: E/AndroidRuntime(13151): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-07 09:14:56.387: E/AndroidRuntime(13151): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-07 09:14:56.387: E/AndroidRuntime(13151): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-07 09:14:56.387: E/AndroidRuntime(13151): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
04-07 09:14:56.387: E/AndroidRuntime(13151): ... 22 more
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.toyota.dealerparking"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.toyota.dealerparking.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="com.toyota.dealerparking.permission.MAPS_RECEIVE" />
<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" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are 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" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.toyota.dealerparking.GMapActivity"
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.maps.v2.API_KEY"
android:value="my-key" />
</application>
</manifest>
GMapActivity.java
package com.toyota.dealerparking;
import android.app.Activity;
import android.os.Bundle;
public class GMapActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
}
}
map.xml
<?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" />