0

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?

Paul
  • 135
  • 1
  • 4
  • 17
  • please post your xml.. – DJphy Jul 14 '15 at 05:32
  • 1
    Maybe you can try clean the project and build it again – bjiang Jul 14 '15 at 17:01
  • Thanks for your help I'm update the error messaging and insert the xml file for your help. – Paul Jul 15 '15 at 23:49
  • I have an almost exact issue. Res ID and Thread.java:818 are the same. Still figuring out what happens: my app has a problem with map setup on onResume and onStart - config changes, app in bg than resumed, etc.. - and i see this exception firing in such cases. What's your specific problem? Could be useful to know, maybe we can identify the source. – Manzotin Jul 21 '15 at 15:12
  • I'm notice that on the first boot the app work without a problem, but on resume I have the problem. I'm going to try and send the message Thanks a lot – Paul Jul 21 '15 at 15:28
  • I'm using openjdk 1.7.0_79 over ubuntu, that could be a problem ?, because the resource id is not the R.java – Paul Jul 25 '15 at 16:22

2 Answers2

1

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.

Pang
  • 9,564
  • 146
  • 81
  • 122
Sandeep Devhare
  • 440
  • 1
  • 6
  • 16
1

Remove Images from drawable-v24 and place those images inside drawable,because they support only API 24 and up.

Manju S B
  • 101
  • 1
  • 4