gpt4 book ai didi

android - NoSuchMethodError com.google.android.gms.internal.g.f

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:25:11 25 4
gpt4 key购买 nike

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

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 向我展示了这个错误,但我无法看到它在哪里。另外,我还有一个信息。事情是这样的:当用户选择在抽屉菜单中查看 map 并且错误发生在他第一次选择时,就会发生这种情况。

这是这个 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();
}
}

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

最佳答案

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

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

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

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

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

至少有两种方案可以解决问题:

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

后者您可以在 SDK 管理器中找到。它是用 last update 添加的因为对 Froyo (Android 2.2) 的支持被删除了。引用链接的博客文章:

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).

关于android - NoSuchMethodError com.google.android.gms.internal.g.f,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20081385/

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