Reputation: 1949
I am trying to do a google maps activity but I get a LogCat error and my app crashes. I used the coding provided by android when I registered my API key so I don't know why it doesn't work. I need help solving this.
LogCat
08-10 11:04:38.854: W/dalvikvm(702): Unable to resolve superclass of Lcom/maps/google/Main; (402)
08-10 11:04:38.854: W/dalvikvm(702): Link of class 'Lcom/maps/google/Main;' failed
08-10 11:04:38.854: D/AndroidRuntime(702): Shutting down VM
08-10 11:04:38.854: W/dalvikvm(702): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-10 11:04:38.874: E/AndroidRuntime(702): FATAL EXCEPTION: main
08-10 11:04:38.874: E/AndroidRuntime(702): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.maps.google/com.maps.google.Main}: java.lang.ClassNotFoundException: com.maps.google.Main
08-10 11:04:38.874: E/AndroidRuntime(702): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
08-10 11:04:38.874: E/AndroidRuntime(702): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-10 11:04:38.874: E/AndroidRuntime(702): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-10 11:04:38.874: E/AndroidRuntime(702): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-10 11:04:38.874: E/AndroidRuntime(702): at android.os.Handler.dispatchMessage(Handler.java:99)
08-10 11:04:38.874: E/AndroidRuntime(702): at android.os.Looper.loop(Looper.java:137)
08-10 11:04:38.874: E/AndroidRuntime(702): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-10 11:04:38.874: E/AndroidRuntime(702): at java.lang.reflect.Method.invokeNative(Native Method)
08-10 11:04:38.874: E/AndroidRuntime(702): at java.lang.reflect.Method.invoke(Method.java:511)
08-10 11:04:38.874: E/AndroidRuntime(702): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-10 11:04:38.874: E/AndroidRuntime(702): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-10 11:04:38.874: E/AndroidRuntime(702): at dalvik.system.NativeStart.main(Native Method)
08-10 11:04:38.874: E/AndroidRuntime(702): Caused by: java.lang.ClassNotFoundException: com.maps.google.Main
08-10 11:04:38.874: E/AndroidRuntime(702): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
08-10 11:04:38.874: E/AndroidRuntime(702): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-10 11:04:38.874: E/AndroidRuntime(702): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-10 11:04:38.874: E/AndroidRuntime(702): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
08-10 11:04:38.874: E/AndroidRuntime(702): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
08-10 11:04:38.874: E/AndroidRuntime(702): ... 11 more
XML File
<RelativeLayout 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" >
<com.google.android.maps.MapView
android:id="@+id/MView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="02ooeHTBsCB6ez4yyEGFEyiuNCz5hTHubgxBMfg" />
</RelativeLayout>
Java file
package com.maps.google;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class Main extends MapActivity {
MapView map;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map = (MapView)findViewById(R.id.MView);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Upvotes: 3
Views: 6742
Reputation: 1723
Make sure you have included the following line in your application manifest:
<uses-library android:required="true" android:name="com.google.android.maps" />
and make sure it's in the correct place. My problem (had similar error messages) was that I had put this in there but like the uses-permission stuff it was just under the root element manifest, when in fact the uses-library element is suppose to be placed under the application element. In case I wasn't clear enough see the part: Configuring the application manifest from Sameers link.
Upvotes: 5
Reputation: 12642
add <uses-library
like this in your manifest
file.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.package.name">
...
<application android:name="MyApplication" >
<uses-library android:name="com.google.android.maps" />
...
</application>
...
</manifest>
Upvotes: 11
Reputation: 34544
Have you included the google map classes in your project?
You will need to add the maps jar file to your project.
The jar can be found in your
{ANDROID-SDK_HOME}\add-ons\addon_google_apis_google_inc_*\libs
directory.
Here are two other questions that would possibly help you with your situation.
Upvotes: 0