它曾经工作,然后我认为当我将Eclipse更新为API 19时它就破了。现在当我尝试运行我的Maps Activity时,我收到错误:android.view.InflateException: Binary XML file line #15: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
所以我开始尝试重新创建我的地图找到here教程的活动。所以现在我回到刚刚显示的地图。这是我在布局中得到的:
<fragment
android:id="@+id/map_wcbc_FRAG"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
这是活动:
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class WCBCMap extends FragmentActivity {
final int RQS_GooglePlayServices = 1;
private GoogleMap myMap;
Button back_BTN;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wcbc_map);
back_BTN = (Button) findViewById(R.id.backMap_wcbc_btn);
FragmentManager myFragmentManager = getSupportFragmentManager();
SupportMapFragment mySupportMapFragment = (SupportMapFragment) myFragmentManager
.findFragmentById(R.id.map_wcbc_FRAG);
myMap = mySupportMapFragment.getMap();
// --- back button
back_BTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent plI = new Intent(
"com....BUTTON_INTERFACE");
startActivity(plI);
finish();
}
});
// --- end back button
}// --- END onCreate
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.splash, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_legalnotices:
String LicenseInfo = GooglePlayServicesUtil
.getOpenSourceSoftwareLicenseInfo(getApplicationContext ());
AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(
WCBCMap.this);
LicenseDialog.setTitle("Legal Notices");
LicenseDialog.setMessage(LicenseInfo);
LicenseDialog.show();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onPause() {
super.onPause();
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
int resultCode = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getApplicationContext());
if (resultCode == ConnectionResult.SUCCESS) {
Toast.makeText(getApplicationContext(),
"isGooglePlayServicesAvailable SUCCESS", Toast.LENGTH_LONG)
.show();
} else {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
RQS_GooglePlayServices);
}
}
}
这里是清单相关信息:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="com.myapp.wcbc.permission.MAPS_RECEIVE"
android:protectionLevel="signature" >
</permission>
<uses-permission android:name="com.myapp.wcbc.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" />
<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" />
.... <meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my API Key is here" />
</application>
我的目标是Android 4.22,我不需要定位Google API 4.22吗?我在那里有Google Play服务和支持v4库。所以任何人都可以看到为什么地图不会膨胀?
答案 0 :(得分:1)
新版Google Play服务库(包括地图v2)不再支持API Level 8(Froyo)。现在是姜饼+。
您可以使用旧版本的播放服务库,也可以在自己的应用中删除对Froyo的支持。
http://android-developers.blogspot.com/2013/10/google-play-services-40.html