我在这里看到其他线程有类似的症状,但没有一个答案能解决我的问题。我正在关注 Google map View 教程,http://developer.android.com/resources/tutorials/views/hello-mapview.html并严格按照所有指示,我不断收到此错误 .. java.lang.ClassNotFoundException: com.goodintechnology.maps.Mymap in loader dalvik.system.PathClassLoader[/data/app/com.goodintechnology.maps-1.apk]
我已经多次从头开始,但每次,只要我将 Activity 更改为 MapActivity,就会抛出错误。应用程序目标是 Google API 2.2,模拟器是相同的,启用了 GPS。我试过将 uses-library 语句放在 Applications 语句之前、之后和中,但这并没有改变任何东西。我什至尝试将声明垂直放置在 list 中。所以,经过大约 8 个小时的处理,我把它交给了你们所有人。这是代码:
AndroidManifest.xml
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Mymap"
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>
和布局main.xml
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="My key that was generated on google is here. trust me"
/>
</LinearLayout>
和 Mymap 类
package com.goodintechnology.maps;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
public class Mymap extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
如前所述,这完全来自 Google map View 教程。
最佳答案
<uses-library android:name="com.google.android.maps" />
必须在
你说你试过了,但你目前的方式,它不会有任何机会,所以先改变它。
关于android - 找不到 MapActivity 类中的 Mapview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5214091/