Android manifest 膨胀类碎片时出错
我试图找出这个问题,从上个月我看到了很多关于它的帖子,但没有找到解决办法,直到现在。 我使用谷歌play服务,支持lib文件,但fragament错误仍然存在; 我想使用谷歌地图,但总是出现以下错误; 这是主要的活动Android manifest 膨胀类碎片时出错,android-manifest,Android Manifest,我试图找出这个问题,从上个月我看到了很多关于它的帖子,但没有找到解决办法,直到现在。 我使用谷歌play服务,支持lib文件,但fragament错误仍然存在; 我想使用谷歌地图,但总是出现以下错误; 这是主要的活动 package com.example.finalmap; import com.google.android.maps.MapActivity; import android.os.
package com.example.finalmap;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends MapActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
这是androidmanifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.finalmap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name="com.example.finalmap.MainActivity"
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="" />
</application>
</manifest>
主要活动
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
尝试更改:
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
到
添加此行
android:layout\u height=“match\u parent”/>
如果您使用的是Google Maps V2,请将其从MapActivity
更改为FragmentActivity
,然后
com.google.android.gms.maps.MapFragment
至com.google.android.gms.maps.SupportMapFragment
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:name="com.example.finalmap.MainActivity" -> add this line
android:layout_height="match_parent"/>