2014-01-31 41 views
1

這是一個新手問題,但即使遵循Google指南,我也遇到了這個問題。

看地圖時,這個把我的應用程序崩潰:

java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable

它只能與三星Galaxy S III,我想一些其他的像三星Galaxy ACE,三星WIFI發生5.0和其他一些不會發生

1.-我添加了我的項目庫。 enter image description here

2:我有我的構建路徑的jar: enter image description here

enter image description here

3 .-我也跟着開始在谷歌地圖V2爲Android:

AndroidManifest.xml的一部分

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

    <!-- Only this application can receive the messages and registration result --> 
    <permission android:name="my.package.example.permission.C2D_MESSAGE" android:protectionLevel="signature" /> 
    <uses-permission android:name="my.package.example.permission.C2D_MESSAGE" /> 

    <!-- This app has permission to register and receive message --> 
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 

    <!-- Send the registration id to the server --> 
    <uses-permission android:name="android.permission.INTERNET" /> 

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 

    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
    <uses-permission android:name="android.permission.WAKE_LOCK" /> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 

    <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/MyTheme" > 

      <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="AIzaSyBCYlMBZVuvPtCQm9mznppJTCnBbH8QRFI"/> 


     <activity ... 

我的活動代碼(mappa.class),它崩潰

 @Override 
    public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
    if (layout != null) { 
      ViewGroup parent = (ViewGroup) layout.getParent(); 
      if (parent != null) 
       parent.removeView(layout); 
    } 
    try { 
    // HERE IT'S WHEN IT CRASHES!! THE FOLLOWING LINE 
     layout = inflater.inflate(R.layout.fragmentmappa, container, false); 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

我的佈局fragmentmappa.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/RelativeLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

<fragment 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.SupportMapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

</RelativeLayout> 

在此先感謝。

+0

'java.lang.NoClassDefFoundError:com.google.android.gms.R $ styleable'通常認爲你沒有正確引用庫項目。你能再次覈對嗎?但快照張貼好看 – Raghunandan

+0

是啊,這就是問題...即使在很多設備上它的工作 –

+1

看起來你的代碼中的一切都很好,嘗試清理和構建,然後卸載並安裝應用程序。看看它是否有效。 – TheLittleNaruto

回答

2

,似乎一切都在你的代碼精,做以下操作:

  1. 乾淨,並建立和

  2. 則先卸載,然後安裝應用程序。

然後看看它是否有效。

+0

我不相信這解決了這個錯誤。沒有從三星圖書館的類錯誤從這個解決。 – coolcool1994

+0

hihihihi xD我能說什麼!這只是不確定性的問題? @ coolcool1994 – TheLittleNaruto

相關問題