0

它曾经可以工作,然后我认为当我将 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)所以我开始尝试使用此处找到的教程重新创建我的 Maps Activity 。所以现在我回到只是让地图显示。这是我在布局中得到的:

<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 APIs 4.22 吗?我在那里有 Google Play 服务和支持 v4 库。那么任何人都可以看到为什么地图不会膨​​胀吗?

4

1 回答 1

1

包括地图 v2 在内的新版 Google Play 服务库不再支持 API 级别 8 (Froyo)。现在是姜饼+。

您可以使用旧版本的播放服务库,或者在您自己的应用程序中放弃对 Froyo 的支持。

http://android-developers.blogspot.com/2013/10/google-play-services-40.html

于 2013-11-05T17:30:28.117 回答