嗨,我是Android开发的新手,我正在尝试在我的应用程序中集成地图视图,它是 给出错误。我已经获得了我的api密钥并进行了双重检查。 我已将我的代码与布局文件和日志文件一起粘贴。任何人都可以帮忙。 感谢。
MainActivity.java
package com.vitarkasolutions.tracker;
import android.os.Bundle;
import com.google.android.gms.maps.MapView;
import com.google.android.maps.MapActivity;
public class MainActivity extends MapActivity {
MapView mapview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapview=(MapView)findViewById(R.id.myMapView);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
activity_main.xml
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/cordinates "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Your Location X- and Y- "
/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/cordinates "
android:layout_alignTop="@+id/cordinates "
android:layout_marginRight="46dp"
android:layout_marginTop="56dp"
android:text="Button" />
<com.google.android.maps.MapView
android:id="@+id/myMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button1"
android:layout_marginTop="24dp"
android:apiKey="mymapkey"
android:clickable="true"
android:enabled="true" >
</com.google.android.maps.MapView>
</RelativeLayout>
Logcat
04-06 17:56:28.489: E/AndroidRuntime(1798): FATAL EXCEPTION: main
04-06 17:56:28.489: E/AndroidRuntime(1798): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.vitarkasolutions.tracker/com.vitarkasolutions.tracker.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.vitarkasolutions.tracker.MainActivity" on path: DexPathList[[zip file "/data/app/com.vitarkasolutions.tracker-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.vitarkasolutions.tracker-2, /vendor/lib, /system/lib]]
04-06 17:56:28.489: E/AndroidRuntime(1798): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
04-06 17:56:28.489: E/AndroidRuntime(1798): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2403)
04-06 17:56:28.489: E/AndroidRuntime(1798): at android.app.ActivityThread.access$600(ActivityThread.java:165)
04-06 17:56:28.489: E/AndroidRuntime(1798): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
04-06 17:56:28.489: E/AndroidRuntime(1798): at android.os.Handler.dispatchMessage(Handler.java:107)
04-06 17:56:28.489: E/AndroidRuntime(1798): at android.os.Looper.loop(Looper.java:194)
04-06 17:56:28.489: E/AndroidRuntime(1798): at android.app.ActivityThread.main(ActivityThread.java:5391)
04-06 17:56:28.489: E/AndroidRuntime(1798): at java.lang.reflect.Method.invokeNative(Native Method)
04-06 17:56:28.489: E/AndroidRuntime(1798): at java.lang.reflect.Method.invoke(Method.java:525)
04-06 17:56:28.489: E/AndroidRuntime(1798): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
04-06 17:56:28.489: E/AndroidRuntime(1798): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
04-06 17:56:28.489: E/AndroidRuntime(1798): at dalvik.system.NativeStart.main(Native Method)
04-06 17:56:28.489: E/AndroidRuntime(1798): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.vitarkasolutions.tracker.MainActivity" on path: DexPathList[[zip file "/data/app/com.vitarkasolutions.tracker-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.vitarkasolutions.tracker-2, /vendor/lib, /system/lib]]
04-06 17:56:28.489: E/AndroidRuntime(1798): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
04-06 17:56:28.489: E/AndroidRuntime(1798): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-06 17:56:28.489: E/AndroidRuntime(1798): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-06 17:56:28.489: E/AndroidRuntime(1798): at android.app.Instrumentation.newActivity(Instrumentation.java:1119)
04-06 17:56:28.489: E/AndroidRuntime(1798): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
04-06 17:56:28.489: E/AndroidRuntime(1798): ... 11 more
答案 0 :(得分:0)
该行应该可以帮到你:
"Caused by: java.lang.ClassNotFoundException: Didn't find class "com.vitarkasolutions.tracker.MainActivity" on path: DexPathList[[zip file "/data/app/com.vitarkasolutions.tracker-2.apk"],nativeLibraryDirectories=[/data/app- lib/com.vitarkasolutions.tracker-2, /vendor/lib, /system/lib]]"