草庐IT

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

coder 2023-12-22 原文

所以我尝试在我的应用程序中实现一个 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/

有关android - 带有奇怪 logcat 错误的 Google Maps V2 加载 map 失败的更多相关文章

  1. ruby-on-rails - Rails 常用字符串(用于通知和错误信息等) - 2

    大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje

  2. ruby - 如何在续集中重新加载表模式? - 2

    鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende

  3. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

  4. ruby - RuntimeError(自动加载常量 Apps 多线程时检测到循环依赖 - 2

    我收到这个错误:RuntimeError(自动加载常量Apps时检测到循环依赖当我使用多线程时。下面是我的代码。为什么会这样?我尝试多线程的原因是因为我正在编写一个HTML抓取应用程序。对Nokogiri::HTML(open())的调用是一个同步阻塞调用,需要1秒才能返回,我有100,000多个页面要访问,所以我试图运行多个线程来解决这个问题。有更好的方法吗?classToolsController0)app.website=array.join(',')putsapp.websiteelseapp.website="NONE"endapp.saveapps=Apps.order("

  5. ruby - 即使失败也继续进行多主机测试 - 2

    我已经构建了一些serverspec代码来在多个主机上运行一组测试。问题是当任何测试失败时,测试会在当前主机停止。即使测试失败,我也希望它继续在所有主机上运行。Rakefile:namespace:specdotask:all=>hosts.map{|h|'spec:'+h.split('.')[0]}hosts.eachdo|host|begindesc"Runserverspecto#{host}"RSpec::Core::RakeTask.new(host)do|t|ENV['TARGET_HOST']=hostt.pattern="spec/cfengine3/*_spec.r

  6. ruby-on-rails - 如何在 Rails View 上显示错误消息? - 2

    我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c

  7. 使用 ACL 调用 upload_file 时出现 Ruby S3 "Access Denied"错误 - 2

    我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file

  8. ruby-on-rails - 错误 : Error installing pg: ERROR: Failed to build gem native extension - 2

    我克隆了一个rails仓库,我现在正尝试捆绑安装背景:OSXElCapitanruby2.2.3p173(2015-08-18修订版51636)[x86_64-darwin15]rails-v在您的Gemfile中列出的或native可用的任何gem源中找不到gem'pg(>=0)ruby​​'。运行bundleinstall以安装缺少的gem。bundleinstallFetchinggemmetadatafromhttps://rubygems.org/............Fetchingversionmetadatafromhttps://rubygems.org/...Fe

  9. ruby - #之间? Cooper 的 *Beginning Ruby* 中的错误或异常 - 2

    在Cooper的书BeginningRuby中,第166页有一个我无法重现的示例。classSongincludeComparableattr_accessor:lengthdef(other)@lengthother.lengthenddefinitialize(song_name,length)@song_name=song_name@length=lengthendenda=Song.new('Rockaroundtheclock',143)b=Song.new('BohemianRhapsody',544)c=Song.new('MinuteWaltz',60)a.betwee

  10. ruby-on-rails - 每次我尝试部署时,我都会得到 - (gcloud.preview.app.deploy) 错误响应 : [4] DEADLINE_EXCEEDED - 2

    我是Google云的新手,我正在尝试对其进行首次部署。我的第一个部署是RubyonRails项目。我基本上是在关注thisguideinthegoogleclouddocumentation.唯一的区别是我使用的是我自己的项目,而不是他们提供的“helloworld”项目。这是我的app.yaml文件runtime:customvm:trueentrypoint:bundleexecrackup-p8080-Eproductionconfig.ruresources:cpu:0.5memory_gb:1.3disk_size_gb:10当我转到我的项目目录并运行gcloudprevie

随机推荐