java.lang.NoSuchFieldError:Lcom/google/android/gms/R$styleable类中没有类型I的静态字段MapAttrs_liteMode;

java.lang.NoSuchFieldError:Lcom/google/android/gms/R$styleable类中没有类型I的静态字段MapAttrs_liteMode;,java,android,google-maps-android-api-2,Java,Android,Google Maps Android Api 2,我正在尝试使用Google Maps v2运行应用程序,但它给我带来了错误,我不知道为什么: java.lang.NoSuchFieldError: No static field MapAttrs_liteMode of type I in class Lcom/google/android/gms/R$styleable; or its superclasses (declaration of 'com.google.android.gms.R$styleable' appears in /

我正在尝试使用Google Maps v2运行应用程序,但它给我带来了错误,我不知道为什么:

java.lang.NoSuchFieldError: No static field MapAttrs_liteMode of type I in class Lcom/google/android/gms/R$styleable; or its superclasses (declaration of 'com.google.android.gms.R$styleable' appears in /data/app/com.example.OKM-1/base.apk)
        at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
        at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
        at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2169)
        at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:300)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:381)
        at android.app.Activity.setContentView(Activity.java:2144)
        at com.example.OKM.presentation.view.MainMapActivity.onCreate(MainMapActivity.java:21)
        at android.app.Activity.performCreate(Activity.java:5933)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
        at android.app.ActivityThread.access$800(ActivityThread.java:149)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:211)
        at android.app.ActivityThread.main(ActivityThread.java:5317)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)
我的项目中添加了Google Play服务(Rev.25)和支持v4。 这是我的密码:

舱单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.OKM">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21"/>

<permission
        android:name="com.example.OKM.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

<uses-permission android:name="com.example.OKM.permission.MAPS_RECEIVE" />

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

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission    android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

<application android:icon="@drawable/icon"
             android:label="@string/app_name"
             android:allowBackup="true">
    <activity android:name=".presentation.view.MainMapActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    <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="@string/mapsKey" />
</application>


</manifest>

你知道什么是错的吗?如果您想了解更多信息,请通知我

我认为您在库和模块中都有相同名称或名称的布局 正在使用重复的资源id扩展多个xml布局

在play services库中查找地图属性并替换为以下代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <declare-styleable name="MapAttrs">
    <attr name="mapType" format="enum">
      <enum name="none" value="0"/>
      <enum name="normal" value="1"/>
      <enum name="satellite" value="2"/>
      <enum name="terrain" value="3"/>
      <enum name="hybrid" value="4"/>



    </attr>
    <attr name="cameraBearing" format="float"/>
    <attr name="cameraTargetLat" format="float"/>
    <attr name="cameraTargetLng" format="float"/>
    <attr name="cameraTilt" format="float"/>
    <attr name="cameraZoom" format="float"/>
    <attr name="liteMode" format="boolean"/>



    <attr name="uiCompass" format="boolean"/>
    <attr name="uiRotateGestures" format="boolean"/>
    <attr name="uiScrollGestures" format="boolean"/>
    <attr name="uiTiltGestures" format="boolean"/>
    <attr name="uiZoomControls" format="boolean"/>
    <attr name="uiZoomGestures" format="boolean"/>
    <attr name="useViewLifecycle" format="boolean"/>
    <attr name="zOrderOnTop" format="boolean"/>
    <attr name="uiMapToolbar" format="boolean"/>
    <attr name="ambientEnabled" format="boolean"/>
  </declare-styleable>

</resources>

通过SDK管理器将您的Google存储库更新到版本15应该可以解决问题并消除对变通方法的需求。需要一个项目

安卓SDK


这也在中提到。

只需重命名您的本地样式名称即可精确重命名此样式MapAttrs_liteMode另一位开发人员在创建与库[1]中相同的文件名时遇到问题:[2]:
<?xml version="1.0" encoding="utf-8"?>
<resources>
   <declare-styleable name="MapAttrs">
    <attr name="mapType" format="enum">
      <enum name="none" value="0"/>
      <enum name="normal" value="1"/>
      <enum name="satellite" value="2"/>
      <enum name="terrain" value="3"/>
      <enum name="hybrid" value="4"/>



    </attr>
    <attr name="cameraBearing" format="float"/>
    <attr name="cameraTargetLat" format="float"/>
    <attr name="cameraTargetLng" format="float"/>
    <attr name="cameraTilt" format="float"/>
    <attr name="cameraZoom" format="float"/>
    <attr name="liteMode" format="boolean"/>



    <attr name="uiCompass" format="boolean"/>
    <attr name="uiRotateGestures" format="boolean"/>
    <attr name="uiScrollGestures" format="boolean"/>
    <attr name="uiTiltGestures" format="boolean"/>
    <attr name="uiZoomControls" format="boolean"/>
    <attr name="uiZoomGestures" format="boolean"/>
    <attr name="useViewLifecycle" format="boolean"/>
    <attr name="zOrderOnTop" format="boolean"/>
    <attr name="uiMapToolbar" format="boolean"/>
    <attr name="ambientEnabled" format="boolean"/>
  </declare-styleable>

</resources>