android maps view crashes app
I've just started to learn development for the android.
I set up a test app with a basic textview that when you clicked on it, changed text. that worked fine. So I decided I wanted to do something interesting with google maps using mapview.
I've followed the instructions in the documentation, and looked around at the demomaps demo app, but when I launch my app in a AVD (pointed to the correct source, google APIs lvl3) I get "the application has stopped unexpectedly. please try again", when I launch in debug mode, the only error I get is "source not found"
Here are some excerpts from my code:
views
<?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"
>
<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="[ommitted for safety - i have an apikey though]"
/>
</LinearLayout>
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="leblanc.test.HelloCora"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".hello"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-library android:name="com.google.android.maps" />
</manifest>
my source .java is basically default
I am developing in eclipse using the ADT, on a linux machine
let me know if there is any other info you need
Thanks!
EDIT: More information on the error I am getting.
TestApp [Android Application]
DalvikVM [localhost:8619]
Thread [ <3> Main ] (Suspended (exception RuntimeException))
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord) line: 2268
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord) line: 2284
ActivityThread.access$1800(ActivityThread, ActivityThread$ActivityRecord) line: 112
ActivityThread$H.handleMessage(Message) line: 1692
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 3948
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 782
ZygoteInit.main(String[]开发者_开发问答) line: 540
NativeStart.main(String[]) line: not available [native method]
Also, the interesting thing is that the demomaps demo application in the android SDK does not crash (though the map data never loads, even though it has internet access permission)
there is an error in your manifest file, the below code should be in the application tag instead
<uses-library android:name="com.google.android.maps" />
so after the changes it will be
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="leblanc.test.HelloCora"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".hello"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>
I think there is problem in "accessing map from web(google map)".
For accessing web, we have to add "INTERNET PERMISSION" in AndroidMenifest.xml
file.
so add the following line below </application>
tag.
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
精彩评论