【问题标题】:Zygote The String#value field is not present on Android versions >= 6.0 Android errorZygote The String#value field is not present on Android versions >= 6.0 Android error
【发布时间】:2018-12-12 06:51:18
【问题描述】:

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

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

我不知道如何摆脱这个。我搜索了所有网站,包括:

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/zygote: 不支持的类加载器 07-03 21:40:15.356 22106- 22106/com.example.sislarodriguez.aplicacionessimilaresv1 W/zygote:跳过 由于不支持的类加载器导致重复类检查 07-03 21:40:15.385 22106- 22106/com.example.sislarodriguez.aplicacionessimilaresv1 I/Google Maps Android API:Google Play 服务客户端版本:12451000 07-03 21:40:15.393 22106- 22106/com.example.sislarodriguez.aplicacionessimilaresv1 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/zygote:做完整的 代码缓存集合,代码=494KB,数据=295KB 07-03 21:40:15.575 22106- 22111/com.example.sislarodriguez.aplicacionessimilaresv1 I/zygote:代码后 缓存集合,代码=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/zygote:做部分 代码缓存集合,代码=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'
}

提前致谢。

【问题讨论】:

  • 嗨,你有没有找到解决这个问题的方法?
  • 没有。它还在那里。但似乎该项目是有效的。
  • 是的,看来你是对的。为了将来参考,我的主要问题似乎是我正在重用基于 MapView 的旧机制。一旦我按照文档中的说明切换到 SupportMapFragment,它就会再次开始工作。
  • @RogaLu,遇到同样的问题,如果您找到任何解决方案,请告诉我。虽然项目运行良好。
  • 无解决方案,我完成了项目并没有修复它。对不起,祝你好运。

标签: android google-maps


【解决方案1】:

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

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

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

【讨论】:

    【解决方案2】:

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

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

    详情请见This Question

    【讨论】:

      猜你喜欢
      • 2021-12-28
      • 1970-01-01
      • 2019-01-18
      • 2021-04-28
      • 2016-07-10
      • 1970-01-01
      • 2019-03-11
      • 2012-09-11
      • 1970-01-01
      相关资源
      最近更新 更多