gpt4 book ai didi

android - 带有奇怪 logcat 错误的 Google Maps V2 加载 map 失败

转载 作者:太空宇宙 更新时间:2023-11-03 10:22:25 25 4
gpt4 key购买 nike

所以我尝试在我的应用程序中实现一个 map fragment 。该应用程序在我的 Galaxy S4 上运行良好,但无法在我的 Xperia Z 上运行。 fragment 显示为空白,没有 map 。 LogCat 指出:

07-31 00:20:07.265: E/Google Maps Android API(8763): Failed to load map. Error contacting
Google servers. This is probably an authentication issue (but could be due to network errors).

所以我检查了 Google-play-services_lib 的引用是否正确,我确实这么认为。所有权限都可以,一切都应该正常工作。 (我假设身份验证问题是伪造的,因为它在 S4 上工作?)。

然后我在没有过滤器的情况下检查了 logcat,我收到了一堆毫无意义的文本:

07-31 00:23:45.398: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_POSITION_REPORT_IND_V02
07-31 00:23:45.438: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.438: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x74211aa0
07-31 00:23:45.448: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.448: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x7331d878
07-31 00:23:45.458: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.458: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x74211aa0
07-31 00:23:45.458: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.458: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x74211aa0
07-31 00:23:45.478: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.478: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x7331d878
07-31 00:23:45.478: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.478: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x7331d878
07-31 00:23:45.488: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_GNSS_SV_INFO_IND_V02
07-31 00:23:45.488: E/LocSvc_afw(705): I/<=== sv_status_cb - line 1043 14

它就这样一直持续下去。我无法理解它。如果我删除与 map 相关的所有内容,错误就会停止。所以它与触发错误的谷歌地图有关。以下是包含 Gmaps 代码的类:

.java 文件:

package com.nordoid.tracephone;

import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

public class Mfragment_main extends Fragment
{
TextView settings;
TextView home;
TextView friends;
final int RQS_GooglePlayServices = 1;
MapFragment myMapFragment;
private GoogleMap map;

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}

@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
View view = inflater.inflate(R.layout.mainmenu_main, container, false);

map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map1)).getMap();
map.setMyLocationEnabled(true);
setUpMap();

/*** Statiske posisjoner til MAPS ***/

final LatLng Pune = new LatLng(58.341907, 8.584957);
@SuppressWarnings("unused")
Marker pune = map.addMarker(new MarkerOptions()
.position(Pune)
.title("Friend 1")
.snippet("Christian")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));

final LatLng Pune1 = new LatLng(58.421157,7.400101);
@SuppressWarnings("unused")
Marker pune1 = map.addMarker(new MarkerOptions()
.position(Pune1)
.title("Friend 2")
.snippet("Howie")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_VIOLET)));

final LatLng Pune2 = new LatLng(36.724576,-4.452317);
@SuppressWarnings("unused")
Marker pune2 = map.addMarker(new MarkerOptions()
.position(Pune2)
.title("Christian på ferie!")
.snippet("Partyyløva.")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
return view;
}

private void setUpMap()
{
// Enable MyLocation Layer of Google Map
map.setMyLocationEnabled(true);

// Get LocationManager object from System Service LOCATION_SERVICE
LocationManager locationManager = (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);

// Create a criteria object to retrieve provider
Criteria criteria = new Criteria();

// Get the name of the best provider
String provider = locationManager.getBestProvider(criteria, true);

// Get Current Location
Location myLocation = locationManager.getLastKnownLocation(provider);

// Get latitude of the current location
double latitude = 60.0426;//myLocation.getLatitude();

// Get longitude of the current location
double longitude = 6.3286;//myLocation.getLongitude();

// Create a LatLng object for the current location
LatLng latLng = new LatLng(latitude, longitude);

// Show the current location in Google Map
map.moveCamera(CameraUpdateFactory.newLatLng(latLng));

// Zoom in the Google Map
map.animateCamera(CameraUpdateFactory.zoomTo(3));

// map.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title("You are here!"));
}

}

.xml 文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/slider"
android:orientation="vertical" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.32" >

<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="216dp"
android:layout_height="75dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="381dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="18dp"
android:layout_marginTop="83dp"
android:background="@drawable/inputfield"
android:gravity="left"
android:paddingTop="0dp" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:paddingLeft="7dp"
android:paddingTop="5dp"
android:text="QUICK TRACK"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#33b5e5" />

<SearchView
android:id="@+id/searchView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:iconifiedByDefault="false"
android:paddingBottom="20dp"
android:paddingLeft="-15dp" >

</SearchView>

</RelativeLayout>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/relativeLayout1"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/relativeLayout1"
android:layout_alignTop="@+id/relativeLayout1"
android:layout_marginBottom="50dp"
android:layout_marginTop="113dp"
android:background="@drawable/inputfield" >

<fragment
android:id="@+id/map1"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="14dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginTop="3dp"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

还有我的 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nordoid.tracephone"
android:versionCode="9"
android:versionName="1.1.45" >

<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="16" />

<permission
android:name="com.nordroid.tracephone.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="com.nordroid.tracephone.permission.MAPS_RECEIVE"/>
<uses-feature android:name="android.hardware.camera"/>


<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<uses-feature
android:name="android.hardware.screen.portrait"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>

<activity android:name="com.nordoid.tracephone.install.MainInstaller"
android:configChanges="orientation"
android:label="@string/title_activity_main"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo.Light.NoActionBar"
android:windowSoftInputMode="stateUnchanged"
>

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
<activity
android:name="com.nordoid.tracephone.Settings"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity
android:name="com.nordoid.tracephone.MainMenu"
android:configChanges="orientation"
android:theme="@android:style/Theme.Holo.Light.NoActionBar"
android:windowSoftInputMode="stateVisible|adjustPan"
android:screenOrientation="portrait" />
<activity
android:name="com.nordoid.tracephone.background.ReceiveSMS2VideoActivityHidden"
android:theme="@style/Theme.someName" />
<activity
android:name="com.nordoid.tracephone.background.CameraActivityHidden"
android:theme="@style/Theme.someName2" />
<activity
android:name="com.nordoid.tracephone.FriendList"
android:theme="@style/Theme.someName2" />
<activity
android:name="com.nordoid.tracephone.googleplay"
android:theme="@style/Theme.someName2" />
<activity
android:name="com.nordoid.tracephone.Friend"
android:theme="@style/Theme.someName2" />
<activity android:name="com.nordoid.tracephone.background.CameraPreviewHidden" >

</activity>
<activity android:name="com.tapfortap.TapForTapActivity" />

<receiver
android:name="com.nordoid.tracephone.background.hidden_gps_and_mail"
android:enabled="true" >
<intent-filter>
<action android:name="intent.action.HIDDEN_GPS_AND_MAIL" >
</action>
</intent-filter>
</receiver>
<receiver
android:name="com.nordoid.tracephone.background.ReceiveSMS"
android:exported="true" >
<intent-filter android:priority="1000" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<receiver
android:name="com.nordoid.tracephone.background.ReceiveSMS2"
android:exported="true" >
<intent-filter android:priority="1000" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="THE MAPS API KEY"/>
</application>
</manifest>

我知道可怕的编码,现在非常困惑。对不起!

最佳答案

This may be the answer:

Note: You cannot inflate a layout into a fragment when that layout includes a fragment. Nested fragments are only supported when added to a fragment dynamically.

此外,在玩嵌套 fragment 时,请使用 getChildFragmentManager()

在你的情况下,它可能在 Galaxy S4 上工作(但它不应该,但你很幸运),但在 Xperia Z 上不起作用。

关于android - 带有奇怪 logcat 错误的 Google Maps V2 加载 map 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17958642/

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