在Google地图中获取例外

时间:2014-02-25 06:19:32

标签: android google-maps android-maps-v2

我试图找到两个位置之间的距离。但是我得到了运行时异常。这是例外:

异常

02-25 11:07:46.663: E/AndroidRuntime(11533): FATAL EXCEPTION: main
02-25 11:07:46.663: E/AndroidRuntime(11533): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{in.wptrafficanalyzer.locationdistancetimemapv2/in.wptrafficanalyzer.locationdistancetimemapv2.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "in.wptrafficanalyzer.locationdistancetimemapv2.MainActivity" on path: DexPathList[[zip file "/data/app/in.wptrafficanalyzer.locationdistancetimemapv2-2.apk"],nativeLibraryDirectories=[/data/app-lib/in.wptrafficanalyzer.locationdistancetimemapv2-2, /vendor/lib, /system/lib]]
02-25 11:07:46.663: E/AndroidRuntime(11533):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at android.app.ActivityThread.access$600(ActivityThread.java:162)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at android.os.Handler.dispatchMessage(Handler.java:107)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at android.os.Looper.loop(Looper.java:194)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at android.app.ActivityThread.main(ActivityThread.java:5371)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at java.lang.reflect.Method.invokeNative(Native Method)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at java.lang.reflect.Method.invoke(Method.java:525)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at dalvik.system.NativeStart.main(Native Method)
02-25 11:07:46.663: E/AndroidRuntime(11533): Caused by: java.lang.ClassNotFoundException: Didn't find class "in.wptrafficanalyzer.locationdistancetimemapv2.MainActivity" on path: DexPathList[[zip file "/data/app/in.wptrafficanalyzer.locationdistancetimemapv2-2.apk"],nativeLibraryDirectories=[/data/app-lib/in.wptrafficanalyzer.locationdistancetimemapv2-2, /vendor/lib, /system/lib]]
02-25 11:07:46.663: E/AndroidRuntime(11533):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
02-25 11:07:46.663: E/AndroidRuntime(11533):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2260)
02-25 11:07:46.663: E/AndroidRuntime(11533):    ... 11 more

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="in.wptrafficanalyzer.locationdistancetimemapv2"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />


    <uses-permission android:name="android.permission.INTERNET"/>

     <permission
          android:name="in.wptrafficanalyzer.locationdistancetimemapv2.permission.MAPS_RECEIVE"
          android:protectionLevel="signature" />

    <uses-permission android:name="in.wptrafficanalyzer.locationdistancetimemapv2.permission.MAPS_RECEIVE" />

    <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="in.wptrafficanalyzer.locationdistancetimemapv2.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


         <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyBSHraq2LIl8_1IwbSXjF1lnmMQZv" />

    </application>

</manifest>

我无法找到什么是例外以及它为什么会发生。请帮助我

1 个答案:

答案 0 :(得分:1)

我过去遇到了同样的问题,检查build path,你的jar文件中没有你的jar文件。

  1. 右键单击您的项目,选择"Build Path" -> "Configure Build Path..."
  2. 在“Order and Export”标签中,选中“Android Private Libraries”选项。
  3. 希望它有效。