的NoSuchMethodError com.google.android.gms.internal.gfgoogle、com、NoSuchMethodError、android

2023-09-04 06:41:17 作者:童話ゝ漸漸融化了

我有一个难以解决的问题。我发表我的应用程序上玩,一切都没有问题,但问题是,有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)

我只知道这个错误,因为游戏给我看了,但它不可能看到它在哪里。此外,我还有一个信息。这里是东西:当用户选择看到抽屉菜单地图和错误是在第一时间,他选择了它发生

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.

下面是该片段的code:

Here is the code of this fragment:

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异常缺失。纵观的javadoc ,有分别加入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 。 请不要使用最新的谷歌播放服务库,但使用的Froyo版本代替。 Change the minSdkVersion in your app's manifest to 9. Don't use the latest Google Play Services library, but use the Froyo version in stead.

,后者则可以在SDK管理器中找到。它添加了最后更新因为Froyo的支持(安卓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:

使用现在运行Android 2.3(姜饼)设备的97%以上,或   新平台的版本,我们放弃对Froyo的从这种支持   在谷歌播放服务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).