gpt4 book ai didi

android map View 崩溃应用程序

转载 作者:行者123 更新时间:2023-11-29 18:24:20 26 4
gpt4 key购买 nike

我刚开始学习 android 的开发。

我设置了一个带有基本 TextView 的测试应用程序,当您单击它时,它会更改文本。效果很好。所以我决定使用 mapview 对 google map 做一些有趣的事情。

我已按照文档中的说明进行操作,并查看了 demomaps 演示应用程序,但是当我在 AVD 中启动我的应用程序时(指向正确的来源,谷歌 API lvl3)我得到“应用程序意外停止.请再试一次”,当我在 Debug模式下启动时,我得到的唯一错误是“找不到源”

以下是我的代码的一些摘录:

观看次数

<?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>

list

<?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>

我的源.java基本上是默认的

我在 linux 机器上使用 ADT 在 eclipse 中进行开发

如果您需要任何其他信息,请告诉我

谢谢!

编辑: 有关我收到的错误的更多信息。

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]

此外,有趣的是,android SDK 中的 demomaps 演示应用程序不会崩溃(尽管 map 数据从未加载,即使它具有互联网访问权限)

最佳答案

你的manifest文件有错误,下面的代码应该在application标签中,而不是

<uses-library android:name="com.google.android.maps" />

所以修改后会是

<?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>

关于android map View 崩溃应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3296381/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com