java.lang.RuntimeException: Unable to instantiate activity ComponentInfo…

Hello,
I am trying to integrate Google Map in my application that I am working on and I ran into this nicely said error:
FATAL EXCEPTION: main
[2010-12-23 01:34:03 - Emulator] E/AndroidRuntime( 304): java.lang.RuntimeException:

Unable to instantiate activity ComponentInfo{com.package_contact.map/com.package_contact.map.MainActivity}: java.lang.ClassNotFoundException: com.package_contact.map.MainActivity in loader dalvik.system.PathClassLoader[/data/appcom.package_contact.google.map-1.apk]

This is my XML:

< com .google.android.maps.MapView 		
android:id="@+id/mapView" android:layout_width="fill_parent" 		
android:layout_height="fill_parent" android:enabled="true" 		

android:clickable="true" android: apiKey="your_received_key" />

This is a snippet from the Manifest XML:

< application android:icon="@drawable/icon" 
android:label="@string/app_name">
< uses - library android:name="com.google.android.maps" / >
< activity android:name=".MainActivity" android:label="@string/app_name">
< intent-filter>
< action android:name="android.intent.action.MAIN"  / >
< category android:name="android.intent.category.LAUNCHER" / >
< / intent-filter>
< / activity>
...............

And a snippet of code from the Java class:

// Obtain handles to UI objects
final MapView mapView = (MapView) findViewById(R.id.mapView);
....

At this moment the code runs with no errors, but before I made the mistake of moving in

the manifest xml file this line : down some lines to “group” some lines(permissions all together, activities all together) but it was a stupid mistake not understanding that this means ” my declared activity USES this library”. So…after one hour of thinking what did I do wrong and googling about it, i found this this and then realised I started right

but … :) Keep in mind(I sure will) to add whatever libraries you are using in your application between

the declaration lines of the application itself in the AndroidManifest.xml file. If you still get the title error message, feel free to leave a comment here.

Enjoy!
Posted in Android by gabriela.radu at December 23rd, 2010.
Tags: ,

Leave a Reply