2014-02-25 11 views
1

package com.fio.gmapsactivity;java.lang.IllegalAccessError:預驗證類中的類ref已解析爲意外實現

GMapsActivity

import android.os.Bundle; 
    import android.app.Activity; 
    import android.view.Menu; 
    import com.google.android.maps.MapActivity; 
    import com.google.android.maps.MapView; 
    public class GMapsActivity extends MapActivity { 
private MapView mapView; 
    @Override 
public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
setContentView(R.layout.activity_map); 
mapView = (MapView) findViewById(R.id.map_view);  
mapView.setBuiltInZoomControls(true); 
} 
@Override 
protected boolean isRouteDisplayed() { 
    return false; 
} 
} 

activity_map.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 
    <com.google.android.maps.MapView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/map_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:apiKey="AIzaSyB4sGJQVW1hJpOtWnTHvDw5IxV_YOPA9eA" 
    android:clickable="true" 
    android:enabled="true" /> 
    </RelativeLayout> 

Mainfest.xml

<?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.fio.gmapsactivity" 
    android:versionCode="1" 
    android:versionName="1.0" > 
    <uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="18" /> 
    <application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
    android:name="com.fio.gmapsactivity.GMapsActivity" 
    android:label="@string/app_name" > 
    <intent-filter> 
    <action android:name="android.intent.action.MAIN" /> 
    <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
    </activity> 
    <uses-library android:name="com.google.android.maps" /> 
    <meta-data 
    android:name="com.google.android.gms.version" 
    android:value="@integer/google_play_services_version" /> 
    <meta-data 
    android:name="com.google.android.maps.v2.API_KEY" 
    android:value="AIzaSyB4sGJQVW1hJpOtWnTHvDw5IxV_YOPA9eA" /> 
    </application> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    </manifest> 

我有加罐子網絡les(效果,地圖,usb)。但無法map.only顯示錯誤。無法找到錯誤。請幫助我。

錯誤

02-25 02:49:31.993: E/AndroidRuntime(1812): FATAL EXCEPTION: main 
    02-25 02:49:31.993: E/AndroidRuntime(1812): java.lang.IllegalAccessError: Class ref in pre-  verified class resolved to unexpected implementation 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at dalvik.system.DexFile.defineClass(Native Method) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:211) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at dalvik.system.DexPathList.findClass(DexPathList.java:313) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:51) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.Instrumentation.newActivity(Instrumentation.java:1061) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.ActivityThread.access$600(ActivityThread.java:141) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at android.os.Handler.dispatchMessage(Handler.java:99) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at android.os.Looper.loop(Looper.java:137) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.ActivityThread.main(ActivityThread.java:5103) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at java.lang.reflect.Method.invokeNative(Native Method) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at java.lang.reflect.Method.invoke(Method.java:525) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
    02-25 02:49:31.993: E/AndroidRuntime(1812): at dalvik.system.NativeStart.main(Native Method) 

回答

1

恰好碰到了這個自己。當你的類被編譯到classes.dex文件中時,依賴類有一定的規範。當應用程序或測試執行過程中加載classes.dex文件時,相關類看起來不同。通常情況下,這是雙重結果,包括項目中的庫(並且它們是不同的)。既然你提到你添加了jar文件,你可能會刪除所有這些文件,並在出現錯誤時重新添加它們。我建議在運行之間徹底清理你的項目,因爲如果你沒有在構建之間改變你的源文件,構建系統可能不會重新編譯你的classes.dex文件。出於同樣的原因,您可能有時可以成功創建並獲得導致此錯誤的apk。

此外,我可以看到您使用的是Google Play服務。您需要確保僅通過庫項目(僅限Eclipse)或依賴性指令(Gradle)包含該依賴項。如果您爲Google Play服務手動添加了jar,也會導致此問題。

相關問題