NoSuchMethodError com.google.android.gms.internal.g.f [英] NoSuchMethodError com.google.android.gms.internal.g.f

查看:33
本文介绍了NoSuchMethodError com.google.android.gms.internal.g.f的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个难题要解决.我已经在 Play 上发布了我的应用程序,一切正常,但问题是有 2 台设备使应用程序崩溃并出现以下错误:

I have a difficult problem to solve. I've published my app on Play and everything is okay, but the problem is that there are 2 devices that crashes the app with the following error:

java.lang.NoSuchMethodError: java.io.IOException.<init>
at com.google.android.gms.internal.g.f(Unknown Source)
at com.google.android.gms.internal.g.b(Unknown Source)
at com.google.android.gms.internal.e.a(Unknown Source)
at com.google.android.gms.internal.e.a(Unknown Source)
at com.google.android.gms.internal.bq.ac(Unknown Source)
at com.google.android.gms.internal.cg$1.run(Unknown Source)
at com.google.android.gms.internal.ch$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)

我只知道这个错误,因为 Play 向我显示,但无法看到它在哪里.此外,我还有一个信息.事情是这样的:当用户选择在抽屉菜单中查看地图并且错误出现在他第一次选择时,就会发生这种情况.

I just know this error because Play shows me, but it's impossible to see where it is. Besides, I have another information. Here is the thing: It happens when the user chooses to see the map in a drawer menu and the error is in the first time he chooses.

这是这个片段的代码:

package br.ufc.ondefica.fragments;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import br.ufc.ondefica.MainActivity;
import br.ufc.ondefica.R;
import br.ufc.ondefica.model.Placemark;
import br.ufc.ondefica.utils.DataHelper;
import br.ufc.ondefica.utils.ParserKML;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

public class UFCMapFragment extends FragmentWithSearch {
    private GoogleMap map;
    private int positionToShow = 3;
    private boolean isDefaultView = true;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.map_layout, container, false);
        ((MainActivity) getActivity()).setTitle(getResources().getStringArray(R.array.sliding_menu)[0]);
        return root;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        map = ((SupportMapFragment) getActivity().getSupportFragmentManager()
                .findFragmentById(R.id.map)).getMap();
        map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
        map.setMyLocationEnabled(true);
        Bundle bundle = getArguments();
        if (bundle != null && bundle.containsKey("positionToShow")) {
            isDefaultView = false;
            positionToShow = bundle.getInt("positionToShow");
        }
        loadMap();
        // Move the camera instantly to the default place to show with a zoom of
        // 15.
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(DataHelper.data.places
                .get(positionToShow).getCoordinates(), 13));
        // Zoom in, animating the camera.
        map.animateCamera(CameraUpdateFactory.zoomTo(16), 4000, null);
    }

    private void loadMap() {
        for (int i = 0; i < DataHelper.data.places.size(); i++) {
            Placemark place = DataHelper.data.places.get(i);
            Marker marker = map.addMarker(new MarkerOptions()
                    .icon(BitmapDescriptorFactory.fromResource(ParserKML
                            .loadMapOfIcons(place.getIconID())))
                    .title(place.getName()).snippet(place.getDescription())
                    .position(place.getCoordinates()));
            if (i == positionToShow && !isDefaultView)
                marker.showInfoWindow();
        }
    }

    public void onDestroyView() {
        super.onDestroyView();
        Fragment fragment = (getFragmentManager().findFragmentById(R.id.map));
        FragmentTransaction ft = getActivity().getSupportFragmentManager()
                .beginTransaction();
        ft.remove(fragment);
        ft.commit();
    }
}

崩溃的设备是:三星 Galaxy ACE (GT-S5830B) 和三星 Galaxy 5 (GT-I5500B).提前致谢,

The devices that crashes are: Samsung Galaxy ACE (GT-S5830B) and Samsung Galaxy 5 (GT-I5500B). Thanks in advance,

推荐答案

stracktrace的第一行给你一个线索:

The first line on the stracktrace give you a clue:

java.lang.NoSuchMethodError: java.io.IOException.<init>

基本上是说 IOException 的一些构造函数丢失了.查看 javadocs,API 级别 9 中添加了两个构造函数:

Basically it's saying that some constructor for IOException is missing. Looking at the javadocs, there are two constructors that were added in API level 9:

public IOException (Throwable cause)
public IOException (String message, Throwable cause)

这应该可以回答您的问题.API 级别 9 是 Android 2.3.因此,堆栈跟踪来自运行 Android 2.2 或更低版本的设备,它缺少上面的两个构造函数.

That should answer your question. API level 9 is Android 2.3. Hence, the stack trace is from a device running Android 2.2 or below, which is missing the two constructors above.

解决问题的方法至少有两种:

There are at least two solutions to solve the problem:

  • 将应用清单中的 minSdkVersion 更改为 9.
  • 不要使用最新的 Google Play 服务库,而是使用 Froyo 版本.

您可以在 SDK 管理器中找到后者.由于支持 Froyo (Android 2.2) 被删除.引用链接的博客文章:

The latter you can find in the SDK Manager. It was added with the last update because support for Froyo (Android 2.2) was dropped. Quote from the linked blog post:

现在超过 97% 的设备运行 Android 2.3 (Gingerbread) 或较新的平台版本,我们从此不再支持 Froyo发布 Google Play 服务 SDK 以使其成为可能未来提供更强大的 API.这意味着你不会能够在运行 Android 2.2 (Froyo) 的设备上使用这些新 API.

With over 97% of devices now running Android 2.3 (Gingerbread) or newer platform versions, we’re dropping support for Froyo from this release of the Google Play services SDK in order to make it possible to offer more powerful APIs in the future. That means you will not be able to utilize these new APIs on devices running Android 2.2 (Froyo).

这篇关于NoSuchMethodError com.google.android.gms.internal.g.f的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆