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

I am new to android programming and am trying to use a map with my current location, but when I look at the 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

Java code in MapsActiviy class:

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 an 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?

0


source to share


1 answer


I got the same error, but I solved it in a simple way! check your xml layout if it looks like abc.xml (xlarge-mdpi) and then just delete it and create a new abc.xml in the default layout folder so it doesn't like the previous one. if the answer helps you. vote! happy coding!



0


source







All Articles