Reputation: 31
I am new to Android programming and working on a project in Eclipse.I tried the first tutorial'HelloWorld',and got this error:
Could not find class 'com.esri.android.map.MapView', referenced from method com.esri.arcgis.android.samples.helloworld.HelloWorldActivity.onCreate
Does there have to be a layout named MapView
? If so, I do not have in my project. Could you please tell me how can I get it into the project?
I also have all source folders in the project. Even mapview, don't know why it's showing this kind of error. I need help with this project and I need to complete it within a few days, but I'm stuck due to this error and can't proceed. I'm facing this same problem in all my projects, even though every one of them I tried is a sample provided by ArcGIS.
Here is the code:
package com.esri.arcgis.android.samples.helloworld;
import android.app.Activity;
import android.os.Bundle;
import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISTiledMapServiceLayer;
public class HelloWorldActivity extends Activity {
MapView map = null;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Retrieve the map and initial extent from XML layout
map = (MapView)findViewById(R.id.map);
// Add dynamic layer to MapView
map.addLayer(new ArcGISTiledMapServiceLayer("" +
"http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
}
protected void onPause() {
super.onPause();
map.pause();
}
protected void onResume() {
super.onResume();
map.unpause();
}
}
Upvotes: 2
Views: 3295
Reputation: 26289
The following pertains to ArcGIS Runtime SDK for Android 1.1.1 but may also apply to other versions of the ArcGIS Runtime SDK:
Upvotes: 2
Reputation: 401
I had a similar issue with the sample. I had to re-add the ArcGIS library to the project several times because Eclipse kept dropping it or it would be classified as a persisted container when the project loaded.
If it was listed as a persisted container I first removed it from the build path
Then to fix it I did the following: right-clicked on the project name in the PackageExplorer -> click build path -> add libraries -> select the ArcGIS library and click next
Hope this helps.
Upvotes: 1
Reputation: 15358
i am also a newbie overhere so i am not pretty sure but i think HelloWorldActivity should extend MapActivity instead of Activity.
Upvotes: 0
Reputation: 11113
It sounds like you have not imported the MapView properly, verify you have this import in the HelloWorldActivity.java:
import com.google.android.maps.MapView;
And looking at the Hello mapview tutorial it looks like they dont mention this.
In eclipse you can hit Ctrl+Shift+O to update your missing imports.
Upvotes: 0