【问题标题】:java.lang.NoClassDefFoundError: com.google.android.gms.R$styleablejava.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
【发布时间】:2017-07-12 10:48:00
【问题描述】:

在 XML 中

<fragment android:id="@+id/map" 
   android:name="in.mpo.mpmobile.KioskListLocation" 
   android:layout_width="match_parent" 
   android:layout_height="wrap_content" 
   class="com.google.android.gms.maps.SupportMapFragment" />

我正在尝试加载谷歌地图,但不幸的是它显示错误

java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable at com.google.android.gms.maps.GoogleMapOptions.createFromAttri‌​butes(未知 来源)在 com.google.android.gms.maps.MapFragment.onInflate(未知 来源)

在构建文件中

dependencies 
{ 
  compile fileTree(include: ['*.jar'], dir: 'libs') 
  compile files('libs/android-support-v4.jar') 
  compile files('libs/google-play-services.jar') 
} 

【问题讨论】:

  • 请添加一些关于您的问题的有用信息,不要只是复制粘贴日志请参阅here 应该如何提问
  • in XML 我正在尝试加载谷歌地图,但不幸的是它显示错误 java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable at com.google .android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source) at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
  • in build File dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile files('libs/android-support-v4.jar') compile files( 'libs/google-play-services.jar') }

标签: android google-maps google-play-services


【解决方案1】:

你可以试试这个吗?

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

【讨论】:

    【解决方案2】:

    在你的 xml 中更改类

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

    【讨论】:

    • 类我删除我的xml文件之后我面临同样的问题:(
    • 用你的替换这个片段
    • 我用你的代替了我的,但是当我在 Android Studio 中测试但在 eclipse Map 中使用一些代码加载时,仍然遇到同样的问题无法在我的应用程序中加载地图。但在 Android Studio 应用程序中使用已被粉碎 :(
    • 你能添加你的类文件吗??
    • xml java or build 你需要哪一个类文件??
    猜你喜欢
    • 2013-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多