简体   繁体   中英

android.content.res.Resources$NotFoundException: Resource ID #0x7f020278

I'm new to Android programing, and am trying to use a map with my current location, but when I look at logcat, I see the following error:

RunTimeException android.content.res.Resources$NotFoundException: Resource ID #0x7f020278 at android.content.res.Resources.getValue(Resources.java:2329) at android.content.res.Resources.startRC(Resources.java:1057) at android.app.ActivityThread$mRunnable.run(ActivityThread.java:2477) at java.lang.Thread.run(Thread.java:818) 07-15 18:40:16.624 13526-13526 com.example.paul.mapasxavo E/ViewRootImpl﹕ sendUserActionEvent() mView == null

The Java code in the MapsActiviy class is:

public class MapsActivity extends FragmentActivity {
    // Might be null if Google Play services APK is not available.
    private GoogleMap mMap; 
    private SensorManager sensorManager;
    private Sensor accelerometer;
    LocationManager locationManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
        setUpMapIfNeeded();
    }

    @Override
    protected void onResume() {
        super.onResume();
        setUpMapIfNeeded();
    }

    private void setUpMap() {
        LOCATION_SERVICE locationManager = 
            (LocationManager)getSystemService(LOCATION_SERVICE);
        Criteria criteria = new Criteria();
        String provider = locationManager.getBestProvider(criteria, true);
        Location location = locationManager.getLastKnownLocation(provider);
        mMap.clear();
        LatLng currentPosition = new LatLng(location.getLatitude(), location.getLongitude());
        mMap.addMarker(new MarkerOptions().position(currentPosition).title("Yo"));

        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentPosition, 13));
        mMap.setMyLocationEnabled(true);
        Log.v("MapaActivity", currentPosition.toString());
    }
}

This is the XML File

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:id="@+id/map"
    tools:context="com.example.paul.mapasxavo.MapsActivity"
    android:name="com.google.android.gms.maps.SupportMapFragment" />

What am I doing wrong?

I solved the same error by this simple way. Check your XML layout if it looks like abc.xml(xlarge-mdpi), then simply delete it and create new one abc.xml in default layout folder . Make sure it should not like previous one.

从drawable-v24中删除图片,然后将这些图片放入drawable中,因为它们仅支持API 24及更高版本。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM