gpt4 book ai didi

java.lang.NoSuchFieldError : No static field MapAttrs_liteMode of type I in class Lcom/google/android/gms/R$styleable; 错误

转载 作者:太空狗 更新时间:2023-10-29 14:55:58 27 4
gpt4 key购买 nike

我正在尝试使用 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 服务(修订版 25)和支持 v4。这是我的代码:

list :

<?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>

...和 Activity :

package com.example.OKM.presentation.view;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.example.OKM.R;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.example.OKM.presentation.presenter.MainMapPresenter;

public class MainMapActivity extends FragmentActivity implements OnMapReadyCallback{
private MainMapPresenter mainMapPresenter;
private SupportMapFragment map;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_map_activity);

if(map == null){
map = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
map.getMapAsync(this);
}



mainMapPresenter = new MainMapPresenter(this);
}

@Override
public void onMapReady(GoogleMap googleMap) {

}
}

你知道哪里可能出错了吗?如果您想了解更多信息,请通知我

最佳答案

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

在 play-services-lib 中找到 map_attrs 并替换为以下代码:

<?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>

关于java.lang.NoSuchFieldError : No static field MapAttrs_liteMode of type I in class Lcom/google/android/gms/R$styleable; 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31393989/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com