Reputation: 2903
I know this could trun out into a very stupid question, so please don't throw me off just by looking at the title. The weirdest thing is happening to me once i try to start a MapActivity extended class with my Android application.
I know there are lots of questoins on this, i did my research but most of them are focused on checking the names to correspond, none of them have worked for me.
Even though i updated my manifest the class is there i get a ClassNotFound exception...
Let me know what i am doing wrong please.
Android Manifest:
<activity
android:name="ro.gebs.captoom.activities.LocationActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
LocationActivity class:
package ro.gebs.captoom.activities;
import android.os.Bundle;
import com.example.captoom.R;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
public class LocationActivity extends MapActivity {
MapView mapView = null;
MyLocationOverlay myLocationOverlay = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// main.xml contains a MapView
setContentView(R.layout.preview_location);
// extract MapView from layout
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
// create an overlay that shows our current location
myLocationOverlay = new MyLocationOverlay(this, mapView);
// add this overlay to the MapView and refresh it
mapView.getOverlays().add(myLocationOverlay);
mapView.postInvalidate();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
@Override
protected void onResume() {
super.onResume();
// when our activity resumes, we want to register for location updates
myLocationOverlay.enableMyLocation();
}
@Override
protected void onPause() {
super.onPause();
// when our activity pauses, we want to remove listening for location
// updates
myLocationOverlay.disableMyLocation();
}
}
And the error log:
07-31 09:35:34.227: E/AndroidRuntime(14613): FATAL EXCEPTION: main
07-31 09:35:34.227: E/AndroidRuntime(14613): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.captoom/ro.gebs.captoom.activities.LocationActivity}: java.lang.ClassNotFoundException: ro.gebs.captoom.activities.LocationActivity
07-31 09:35:34.227: E/AndroidRuntime(14613): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
07-31 09:35:34.227: E/AndroidRuntime(14613): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
07-31 09:35:34.227: E/AndroidRuntime(14613): at android.app.ActivityThread.access$700(ActivityThread.java:140)
07-31 09:35:34.227: E/AndroidRuntime(14613): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
07-31 09:35:34.227: E/AndroidRuntime(14613): at android.os.Handler.dispatchMessage(Handler.java:99)
07-31 09:35:34.227: E/AndroidRuntime(14613): at android.os.Looper.loop(Looper.java:137)
07-31 09:35:34.227: E/AndroidRuntime(14613): at android.app.ActivityThread.main(ActivityThread.java:4921)
07-31 09:35:34.227: E/AndroidRuntime(14613): at java.lang.reflect.Method.invokeNative(Native Method)
07-31 09:35:34.227: E/AndroidRuntime(14613): at java.lang.reflect.Method.invoke(Method.java:511)
07-31 09:35:34.227: E/AndroidRuntime(14613): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
07-31 09:35:34.227: E/AndroidRuntime(14613): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
07-31 09:35:34.227: E/AndroidRuntime(14613): at dalvik.system.NativeStart.main(Native Method)
07-31 09:35:34.227: E/AndroidRuntime(14613): Caused by: java.lang.ClassNotFoundException: ro.gebs.captoom.activities.LocationActivity
07-31 09:35:34.227: E/AndroidRuntime(14613): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-31 09:35:34.227: E/AndroidRuntime(14613): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-31 09:35:34.227: E/AndroidRuntime(14613): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-31 09:35:34.227: E/AndroidRuntime(14613): at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
07-31 09:35:34.227: E/AndroidRuntime(14613): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
07-31 09:35:34.227: E/AndroidRuntime(14613): ... 11 more
Please note that my build also targets Google API platform if that makes a difference...
EDIT I excluded the google play services library i had also included in my project, the error log changes into this:
07-31 09:51:44.433: E/AndroidRuntime(14918): FATAL EXCEPTION: main
07-31 09:51:44.433: E/AndroidRuntime(14918): java.lang.NoClassDefFoundError: ro.gebs.captoom.activities.LocationActivity
Thanks!
Upvotes: 0
Views: 3114
Reputation: 8251
May be its a Build Path Configuration problem.I also faced the same problem once.I did the following to solve the issue.
1.Right click on your project and go to Java Build Path.
2.Click on Order and Export tab.
3.Check Android Private Libraries and other 3rd part libraries if you have added.
4.Press ok and clean the project.
I hope it will solve the issue.
Upvotes: 0