Zygote在大于等于6.0的Android版本中,String#value字段不存在Android错误

时间:2018-07-03 22:01:40

标签: android google-maps

我正在使用Google API构建地图应用程序。我收到此错误:

E / zygote:Android版本> = 6.0上不存在String#value字段

我不知道该如何摆脱。我搜索了包括以下内容在内的所有网站:

The String#value field is not present on Android versions >= 6.0

也未发布解决方案。

但是我没有使用任何类型的火力基地。我将不胜感激。

Logcat出现错误:

com.google.android.gms.maps_dynamite的选定远程版本,版本> =     220     07-03 21:40:15.346 22106-     22106 / com.example.sislarodriguez.aplicacionessimilaresv1 W /合子:     不支持的类加载器     07-03 21:40:15.356 22106-     22106 / com.example.sislarodriguez.aplicacionessimilaresv1 W /合子:正在跳过     由于不支持的类加载器,重复类检查     07-03 21:40:15.385 22106-     22106 / com.example.sislarodriguez.aplicaciones相似v1     I / Google Maps Android API:Google Play服务客户端版本:12451000     07-03 21:40:15.393 22106-    22106 / com.example.sislarodriguez.aplicaciones相似v1    I / Google Maps Android API:Google Play服务软件包版本:12685026    07-03 21:40:15.478 22106-     22106 / com.example.sislarodriguez.aplicacionessimilaresv1 E / zygote:    在Android版本> = 6.0 中不存在String#value字段    07-03 21:40:15.572 22106-    22111 / com.example.sislarodriguez.aplicacionessimilaresv1 I /合子:完整    代码缓存收集,代码= 494KB,数据= 295KB    07-03 21:40:15.575 22106-    22111 / com.example.sislarodriguez.aplicacionessimilaresv1 I /合子:代码后    缓存收集,代码= 493KB,数据= 263KB    07-03 21:40:15.663 22106-    22148 / com.example.sislarodriguez.aplicacionessimilaresv1    D / NetworkSecurityConfig:未使用平台指定网络安全配置    默认    07-03 21:40:15.712 22106-    22111 / com.example.sislarodriguez.aplicacionessimilaresv1 I /合子:部分     代码缓存收集,代码= 494KB,数据= 271KB     收集代码缓存后,代码= 494KB,数据= 271KB     将代码缓存容量增加到2MB

我在其中加载地图的片段。

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class FragmentShops extends Fragment {

MapView mMapView;
private GoogleMap googleMap;


@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_shops, container, false);

    mMapView = (MapView) view.findViewById(R.id.mapView);
    mMapView.onCreate(savedInstanceState);

    mMapView.onResume();

    try {
        MapsInitializer.initialize(getActivity().getApplicationContext());
    } catch (Exception e) {
        e.printStackTrace();
    }

    mMapView.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap mMap) {

            googleMap = mMap;
            //googleMap.setMyLocationEnabled(false);

            // For dropping a marker at a point on the Map
            LatLng simi = new LatLng(19.37,-99.14);
            googleMap.addMarker(new MarkerOptions().position(simi).title("Marker Title").snippet("Marker Description"));

            // For zooming automatically to the location of the marker
            CameraPosition cameraPosition = new CameraPosition.Builder().target(simi).zoom(15).build();
            googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
        }
    });


    return view;
}

@Override
public void onResume() {
    super.onResume();
    mMapView.onResume();
}

@Override
public void onPause() {
    super.onPause();
    mMapView.onPause();
}

@Override
public void onDestroy() {
    super.onDestroy();
    mMapView.onDestroy();
}

@Override
public void onLowMemory() {
    super.onLowMemory();
    mMapView.onLowMemory();
}
}

我的布局片段

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".FragmentShops">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_marginBottom="4dp"
    android:layout_marginLeft="4dp"
    android:layout_marginRight="4dp"
    android:layout_marginTop="4dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:layout_marginBottom="2dp"
        android:background="@drawable/sb_ovalframe">

        <AutoCompleteTextView
            android:id="@+id/au_searchunit"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_weight="2.5"
            android:background="@android:color/transparent"
            android:completionThreshold="1"
            android:gravity="start"
            android:imeOptions="actionSearch"
            android:inputType="text"
            android:hint="@string/shopsearch"
            android:textSize="@dimen/title_size" />

        <ImageButton
            android:id="@+id/btn_searchunit"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:background="@drawable/btn_searchoval"
            android:gravity="center"
            app:srcCompat="@drawable/icon_search" />
    </TableRow>

    <ImageView
        android:id="@+id/separator"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        app:srcCompat="@android:color/darker_gray"
        android:contentDescription="@string/separator"
        android:layout_marginBottom="4dp"/>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="1dp">

        <com.google.android.gms.maps.MapView
            android:id="@+id/mapView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </FrameLayout>


</LinearLayout>
</android.support.constraint.ConstraintLayout>

我的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sislarodriguez.aplicacionessimilaresv1">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".StartActivity"
        android:theme="@style/StartScreenTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" />
    <activity android:name=".LoginActivity" />
    <activity
        android:name=".StatusJobs"
        android:label="@string/notificaciones"
        android:theme="@style/ActiveBar" />

     <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="MQpD4IjP84dibMQpD4qwbIjP8h1uxHT4NOTREAL" /> 

    <activity android:name=".ConfigNotificationActivity"></activity>
</application>

</manifest>

我的build.gradle模块应用

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.example.sislarodriguez.aplicacionessimilaresv1"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/MPAndroidChart-v3.0.3.jar')
implementation 'com.android.support:cardview-v7:27.1.1'
}

谢谢。

2 个答案:

答案 0 :(得分:1)

在Android 9上运行我的应用程序时,我遇到了类似的问题。这个答案对我有用:https://stackoverflow.com/a/52181547/6363572

您可以尝试在AndroidManifest.xml中添加以下行:

<uses-library android:name="org.apache.http.legacy" android:required="false"/>

答案 1 :(得分:0)

我遇到了类似的问题,可以通过在启用并更新Google Play的模拟器中运行该问题来解决。 (如果没有更新的Google Play商店,则无法运行Google地图。)

基本上创建一个具有Google Play(而不仅仅是Google API)的新虚拟设备。或者,在实际设备上使用USB调试。

有关详细信息,请参见This Question