android - java.lang.NoClassDefFoundError : com. google.android.gms.R$styleable(已添加项目!!)

标签 android google-maps noclassdeffounderror

这是一个新手问题,但即使按照 Google 指南我也遇到了这个问题。

我的应用在查看 map 时崩溃,抛出以下异常:

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

它只发生在 Samsung Galaxy S III 上,我正在尝试其他一些设备,例如 Samsung Galaxy ACE、Samsung WIFI 5.0 和其他一些设备,但没有发生>.

1.- 我已经添加了我的项目库。 enter image description here

2.- 我的构建路径上有 jar: enter image description here

enter image description here

3.- 我已遵循 Google Maps V2 for 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 ...

我的 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>

提前致谢。

最佳答案

您的代码似乎一切正常,请执行以下操作:

  1. 清理和构建

  2. 然后先卸载再安装应用。

看看它是否有效。

关于android - java.lang.NoClassDefFoundError : com. google.android.gms.R$styleable(已添加项目!!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21480116/

相关文章:

java - 将字符串地址转换为 lat 和 lng 大约需要 1 秒

javascript - 谷歌地图登录混合应用卡住了

java - 在运行时找不到类,但在编译时使用命令行找到类

java - 使用defineClass从字节动态创建类

java - 静态嵌套类访问抛出 NoClassDefFoundError

java - 如何将 created_time 字段值从 Android Studio 中的 Instagram 媒体对象转换为日期

android - 用于加密存储的自定义 ContentProvider

android - 将 android 插件版本(gradle 版本)更新到 3.3.0 后无法解析符号 'R'

android - ViewPager - 无限滚动?

ios - 使用googleMaps api在swift mapView中显示方向按钮