【问题标题】:Eclipse NoClassDefFoundError on maps [duplicate]地图上的 Eclipse NoClassDefFoundError [重复]
【发布时间】:2013-08-17 09:54:38
【问题描述】:

我正在尝试运行地图,但出现以下错误。看起来我没有正确地声明一些东西。任何人都可以帮忙吗?如以下评论所示,我在项目属性中将 GooglePlayServices 和 Support v13 列为项目库,因此我认为它可能是重复或损坏的参考。我试过 Project Clean 没有效果。

08-17 10:50:03.363: E/AndroidRuntime(23422): FATAL EXCEPTION: main
08-17 10:50:03.363: E/AndroidRuntime(23422): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
08-17 10:50:03.363: E/AndroidRuntime(23422):    at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
08-17 10:50:03.363: E/AndroidRuntime(23422):    at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
08-17 10:50:03.363: E/AndroidRuntime(23422):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:271)
08-17 10:50:03.363: E/AndroidRuntime(23422):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)

我认为交叉引用可能是问题所在,因此我将指向 GooglePlayServices 的指针从外部更改为工作区 jar,因为我已将库添加到工作区。然后我收到以下错误:

08-17 14:20:07.028: E/AndroidRuntime(25258): FATAL EXCEPTION: main
08-17 14:20:07.028: E/AndroidRuntime(25258): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mediloc8.leeds/com.mediloc8.leeds.MyMapView}: java.lang.ClassNotFoundException: com.mediloc8.leeds.MyMapView
08-17 14:20:07.028: E/AndroidRuntime(25258):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1892)
08-17 14:20:07.028: E/AndroidRuntime(25258):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)

My Manifest 对 MyMapView 有以下声明:

<activity android:name="com.mediloc8.leeds.MyMapView"
     android:screenOrientation="portrait"
     android:label="@string/map">
     <intent-filter>
    <action android:name="com.mediloc8.leeds.MyMapView" />
         <category android:name="android.intent.category.DEFAULT" />

  </intent-filter>
         </activity>

【问题讨论】:

  • 您必须添加 GooglePlayServices 库项目并支持 lib v4(如果对旧版本使用支持 mapfragment)到项目依赖项。
  • 我不确定它是否重复,因为我将 GooglePlayServices 作为项目中的 jar 以及支持 lib v13。我认为可能是工作区和项目中的某个地方我可能有重复的引用。
  • 我已经通过将 GooglePlayServices 库项目添加为引用项目来修复它 - 即使 jar 是外部的。奇怪!

标签: android eclipse google-maps noclassdeffounderror


【解决方案1】:

检查 google play 服务库是否已添加到您的项目中。 右键单击项目 -> 属性 -> java buildpath -order 并导出选择谷歌播放服务。

【讨论】:

    【解决方案2】:

    这是由于GooglePlayServices没有作为库添加到项目中

    检查this 以在您的项目中设置GooglePlayServices 库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多