Thursday, September 9, 2010

[android-developers] Google Maps API and Android app.

Hi everyone,

I am following a tutorial on adding google maps into and android app
and it keeps quitting unexpectantly. I have added the correct
permissions and uses and created a new AVD using the google api build
target but i guess i am missing something else, hope someone can help
and thanks in advance

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="*******************************************"
/>
</LinearLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hello.map.view"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/
app_name">

<activity android:name=".HelloMapView" android:label="@string/
app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-
permission>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-
permission>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"></uses-
permission>
</manifest>

HelloMapView.java

ackage com.hello.map.view;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

import android.os.Bundle;
import android.widget.LinearLayout;

public class HelloMapView extends MapActivity {
/** Called when the activity is first created. */
LinearLayout linearLayout;
MapView mapView;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);

mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}

Error Log

09-09 21:23:11.817: INFO/Process(695): Sending signal. PID: 695 SIG: 9
09-09 21:23:13.318: INFO/Process(672): Sending signal. PID: 672 SIG: 9
09-09 21:23:13.417: WARN/InputManagerService(67): Window already
focused, ignoring focus gain of:
com.android.internal.view.IInputMethodClient$Stub$Proxy@440d6168
09-09 21:23:14.016: INFO/ActivityManager(67): Process
com.zermatt.travel.guide (pid 672) has died.
09-09 21:23:14.067: INFO/ActivityManager(67): Process
com.hello.map.view (pid 695) has died.
09-09 21:23:16.990: WARN/ActivityManager(67): Activity destroy timeout
for HistoryRecord{440c13a0 com.hello.map.view/.HelloMapView}
09-09 21:23:44.257: INFO/AndroidRuntime(706): NOTE: attach of thread
'Binder Thread #4' failed
09-09 21:23:47.887: INFO/ActivityManager(67): Starting activity:
Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x10000000
cmp=com.hello.map.view/.HelloMapView }
09-09 21:23:48.097: INFO/AndroidRuntime(715): NOTE: attach of thread
'Binder Thread #3' failed
09-09 21:23:48.528: INFO/ActivityManager(67): Start proc
com.hello.map.view for activity com.hello.map.view/.HelloMapView:
pid=722 uid=10037 gids={3003, 1015}
09-09 21:23:51.217: WARN/dalvikvm(722): threadid=1: thread exiting
with uncaught exception (group=0x4001d800)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): FATAL EXCEPTION: main
09-09 21:23:51.247: ERROR/AndroidRuntime(722):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.hello.map.view/com.hello.map.view.HelloMapView}:
java.lang.NullPointerException
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2663)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2679)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
android.os.Looper.loop(Looper.java:123)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
android.app.ActivityThread.main(ActivityThread.java:4627)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
java.lang.reflect.Method.invokeNative(Native Method)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
java.lang.reflect.Method.invoke(Method.java:521)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
dalvik.system.NativeStart.main(Native Method)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): Caused by:
java.lang.NullPointerException
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
com.hello.map.view.HelloMapView.onCreate(HelloMapView.java:20)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1047)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2627)
09-09 21:23:51.247: ERROR/AndroidRuntime(722): ... 11 more
09-09 21:23:51.297: WARN/ActivityManager(67): Force finishing
activity com.hello.map.view/.HelloMapView
09-09 21:23:51.826: WARN/ActivityManager(67): Activity pause timeout
for HistoryRecord{440d7c90 com.hello.map.view/.HelloMapView}
09-09 21:24:00.497: INFO/Process(722): Sending signal. PID: 722 SIG: 9
09-09 21:24:00.557: INFO/ActivityManager(67): Process
com.hello.map.view (pid 722) has died.
09-09 21:24:00.617: WARN/InputManagerService(67): Window already
focused, ignoring focus gain of:
com.android.internal.view.IInputMethodClient$Stub$Proxy@43f511d0
09-09 21:24:03.628: WARN/ActivityManager(67): Activity destroy timeout
for HistoryRecord{440d7c90 com.hello.map.view/.HelloMapView}
09-09 21:24:22.687: INFO/EventLogService(231): Aggregate from
1284062061836 (log), 1284062061836 (data)

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment