android - java.lang.NoClassDefFoundError : com. google.android.gms.R$styleable 仅当布局文件中存在 map fragment 时

标签 android google-maps-android-api-2 android-maps-v2

当我的布局文件包含 map fragment 时,我收到此错误,如 android v2 api docs 中所述,包括变体,即。在 android:name 属性等中指定类名。

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

但是 当我以编程方式 添加 fragment 时,我不会 收到此错误,即。当我在代码中创建 SupportMapFragment 对象并将其添加到布局文件中的“fragment 容器”元素时。

事实上,当以编程方式添加时它可以正常工作,这让我排除了 SO 上大多数提议的解决方案中所建议的“构建路径”错误 - 我也一次又一次地仔细遵循这些步骤,即。将 google play 服务添加为项目,在 Properties -> Android -> Project 中指定它(我有一个绿色勾号)并且将 google play 服务添加为 jar 等。

有人遇到过这个问题吗?尤其是“以编程方式添加时有效”和“在布局文件中作为 fragment 元素添加时无效”问题?

问候

最佳答案

我遇到了同样的问题,经过多次来回,我编译了 google_play_services 模块,突然间一切正常。试一试,让我知道它是否有效

关于android - java.lang.NoClassDefFoundError : com. google.android.gms.R$styleable 仅当布局文件中存在 map fragment 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17338218/

相关文章:

android - 将背景图像从正常图像淡化为褪色图像

android - 在 Android 的 RecyclerView 中检测动画完成

安卓|谷歌地图 V2 |比例尺/尺子

android - 如何更改标记在 Android Map v2 上的位置

android - 使用基于位置的应用程序跟踪用户

android - fragment 垃圾收集

android.os.FileUriExposedException : <filename> exposed beyond app through Intent. getData() 异常

android - 如何在android后台加载谷歌地图?

android - Google Map v2 检查该点是否包含在区域内

android - 在 Google Map 版本 2 中将可绘制的图像设置为标记