我的应用程序显示空白地图(my app is showing blank map)

2019-09-28 05:02发布

我使用谷歌地图API在我app.The地图是可以正常使用,但现在它得到blanked.Map仍在工作,但不加载map.I是为时间寻找答案,但没有得到任何results.I已经创建了一个新的API在谷歌云平台,并把该API,但仍然不加载地图。 人谁可以帮助我。 谢谢!

这里是空白地图的截图。 地图的屏幕截图

07-21 21:28:59.573 18146-18265/com.example.har.firebaseauthenticationdemo E/Google Maps Android API: Authorization failure.  Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
07-21 21:28:59.575 18146-18265/com.example.har.firebaseauthenticationdemo E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
                                                                                                     Ensure that the "Google Maps Android API v2" is enabled.
                                                                                                     Ensure that the following Android Key exists:
                                                                                                        API Key: AIzaSyDWCP4m0DF57jZU4V8Yr7RFP2-DmhpgL34
                                                                                                        Android Application (<cert_fingerprint>;<package_name>): 0E:0E:68:77:05:BB:76:A3:5C:BC:62:F8:6A:AB:A5:5F:2A:7F:37:5F;com.example.har.firebaseauthenticationdemo
07-21 21:29:00.571 2256-2451/? E/Auth: [GoogleAccountDataServiceImpl] getToken() -> BAD_AUTHENTICATION. Account: <ELLIDED:-895295850>, App: com.google.android.gms, Service: oauth2:https://www.googleapis.com/auth/login_manager
                                       fkq: Long live credential not available.
                                           at fkr.b(:com.google.android.gms@12529024@12.5.29 (040700-192802242):20)
                                           at fkr.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):50)
                                           at fjb.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):35)
                                           at gzf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):8)
                                           at gzf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):160)
                                           at gyf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):2)
                                           at gyc.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):17)
                                           at gyc.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):6)
                                           at cug.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):25)
                                           at cug.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):79)
                                           at cug.onTransact(:com.google.android.gms@12529024@12.5.29 (040700-192802242):8)
                                           at android.os.Binder.transact(Binder.java:627)
                                           at cwl.onTransact(:com.google.android.gms@12529024@12.5.29 (040700-192802242):3)
                                           at android.os.Binder.execTransact(Binder.java:697)
07-21 21:29:00.611 2256-3646/? E/Auth: [GoogleAccountDataServiceImpl] getToken() -> BAD_AUTHENTICATION. Account: <ELLIDED:-895295850>, App: com.google.android.gms, Service: oauth2:https://www.googleapis.com/auth/login_manager
                                       fkq: Long live credential not available.
                                           at fkr.b(:com.google.android.gms@12529024@12.5.29 (040700-192802242):20)
                                           at fkr.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):50)
                                           at fjb.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):35)
                                           at gzf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):8)
                                           at gzf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):160)
                                           at gyf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):2)
                                           at gyc.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):17)
                                           at gyc.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):6)
                                           at cug.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):25)
                                           at cug.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):79)
                                           at cug.onTransact(:com.google.android.gms@12529024@12.5.29 (040700-192802242):8)
                                           at android.os.Binder.transact(Binder.java:627)
                                           at cwl.onTransact(:com.google.android.gms@12529024@12.5.29 (040700-192802242):3)
                                           at android.os.Binder.execTransact(Binder.java:697)
07-21 21:29:00.673 2256-3646/? E/Auth: [GoogleAccountDataServiceImpl] getToken() -> BAD_AUTHENTICATION. Account: <ELLIDED:-895295850>, App: com.google.android.gms, Service: oauth2:https://www.googleapis.com/auth/login_manager
                                       fkq: Long live credential not available.
                                           at fkr.b(:com.google.android.gms@12529024@12.5.29 (040700-192802242):20)
                                           at fkr.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):50)
                                           at fjb.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):35)
                                           at gzf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):8)
                                           at gzf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):160)
                                           at gyf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):2)
                                           at gyc.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):17)
                                           at gyc.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):6)
                                           at cug.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):25)
                                           at cug.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):79)
                                           at cug.onTransact(:com.google.android.gms@12529024@12.5.29 (040700-192802242):8)
                                           at android.os.Binder.transact(Binder.java:627)
                                           at cwl.onTransact(:com.google.android.gms@12529024@12.5.29 (040700-192802242):3)
                                           at android.os.Binder.execTransact(Binder.java:697)
07-21 21:29:00.748 2426-18282/? E/ChromeSync: [Sync,SyncAdapter] Failed to sync.
                                              mbz: fgj: BadAuthentication
                                                  at mfy.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):5)
                                                  at mgm.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):42)
                                                  at mgn.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):22)
                                                  at mgn.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):73)
                                                  at mgn.b(:com.google.android.gms@12529024@12.5.29 (040700-192802242):7)
                                                  at mgl.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):41)
                                                  at nrg.onPerformSync(:com.google.android.gms@12529024@12.5.29 (040700-192802242):5)
                                                  at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:321)
                                               Caused by: fgj: BadAuthentication
                                                  at ffx.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):13)
                                                  at ffw.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):2)
                                                  at ffw.e(:com.google.android.gms@12529024@12.5.29 (040700-192802242):6)
                                                  at ffw.d(:com.google.android.gms@12529024@12.5.29 (040700-192802242):1)
                                                  at ffu.b(:com.google.android.gms@12529024@12.5.29 (040700-192802242):1)
                                                  at nms.b(Unknown Source:6)
                                                  at nlf.b(:com.google.android.gms@12529024@12.5.29 (040700-192802242):5)
                                                  at nlw.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):58)
                                                  at mfy.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):1)
                                                  at mgm.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):42) 
                                                  at mgn.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):22) 
                                                  at mgn.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):73) 
                                                  at mgn.b(:com.google.android.gms@12529024@12.5.29 (040700-192802242):7) 
                                                  at mgl.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):41) 
                                                  at nrg.onPerformSync(:com.google.android.gms@12529024@12.5.29 (040700-192802242):5) 
                                                  at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:321) 
07-21 21:29:03.389 1599-1612/? E/memtrack: Couldn't load memtrack module
07-21 21:29:05.559 1599-1612/? E/memtrack: Couldn't load memtrack module
07-21 21:29:05.574 1599-1612/? E/memtrack: Couldn't load memtrack module
07-21 21:29:12.866 2256-18310/? E/Auth: [GoogleAccountDataServiceImpl] getToken() -> BAD_AUTHENTICATION. Account: <ELLIDED:-895295850>, App: com.google.android.gms, Service: oauth2:https://www.googleapis.com/auth/experimentsandconfigs
                                        fkq: Long live credential not available.
                                            at fkr.b(:com.google.android.gms@12529024@12.5.29 (040700-192802242):20)
                                            at fkr.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):50)
                                            at fjb.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):35)
                                            at gzf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):8)
                                            at gzf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):160)
                                            at gyf.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):2)
                                            at gyc.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):17)
                                            at gyc.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):6)
                                            at cug.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):25)
                                            at cug.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):79)
                                            at ffx.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):6)
                                            at ffw.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):2)
                                            at ffw.e(:com.google.android.gms@12529024@12.5.29 (040700-192802242):6)
                                            at ffu.f(:com.google.android.gms@12529024@12.5.29 (040700-192802242):3)
                                            at ffu.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):4)
                                            at ffu.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):7)
                                            at aenk.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):22)
                                            at aenm.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):130)
                                            at aenm.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):243)
                                            at aenm.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):404)
                                            at com.google.android.gms.phenotype.sync.HeterodyneSyncTaskChimeraService.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):66)
                                            at com.google.android.gms.phenotype.sync.HeterodyneSyncTaskChimeraService.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):20)
                                            at ulu.run(:com.google.android.gms@12529024@12.5.29 (040700-192802242):1)
                                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                                            at java.lang.Thread.run(Thread.java:764)
07-21 21:29:12.884 2256-18310/? E/HeterodyneSyncTaskChime: Failed to get auth token: User intervention required. Notification has been pushed. -- metadata{ service_id: 51 }
                                                           fgk: User intervention required. Notification has been pushed.
                                                               at ffu.f(:com.google.android.gms@12529024@12.5.29 (040700-192802242):10)
                                                               at ffu.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):4)
                                                               at ffu.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):7)
                                                               at aenk.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):22)
                                                               at aenm.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):130)
                                                               at aenm.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):243)
                                                               at aenm.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):404)
                                                               at com.google.android.gms.phenotype.sync.HeterodyneSyncTaskChimeraService.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):66)
                                                               at com.google.android.gms.phenotype.sync.HeterodyneSyncTaskChimeraService.a(:com.google.android.gms@12529024@12.5.29 (040700-192802242):20)
                                                               at ulu.run(:com.google.android.gms@12529024@12.5.29 (040700-192802242):1)
                                                               at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                                                               at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                                                               at java.lang.Thread.run(Thread.java:764)

Answer 1:

确保“谷歌地图API的Android V2”已启用。

  • 转到谷歌控制台 API和搜索地图Android版的API。 并确保已启用它。

确保以下的Android项是否存在:

  • 转到谷歌控制台凭据管理器。 然后加入Android API密钥用于调试和发布。 检查谷歌文件的更多细节。

更新1

  • 从您的logcat的。

07-21 21:28:59.573 18146-18265 / com.example.har.firebaseauthenticationdemo E /谷歌地图API的Android:授权失败。

请参阅https://developers.google.com/maps/documentation/android-api/start对于如何正确设置地图。

更新2

的build.gradle

buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue "string", "google_maps_api_key", "Release_API_KEY"
        }
        debug {
//          KL MBP debug Key
            resValue "string", "google_maps_api_key", "DEBUG_API_KEY"
//          KL Old Machine debug Key
//            resValue "string", "google_maps_api_key", "DEBUG_API_KEY"
        }
    }

AndroidManifest.xml中

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="@string/google_maps_api_key"/>

    <uses-library
        android:name="com.google.android.maps"
        android:required="true" />

更新3

获得SHA1对生成API密钥使用

  • 对于Linux或者MacOS,打开一个终端窗口,输入以下命令:

MacOS和Linux上: ~/.android/

 keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android 
  • 对于Windows Vista和Windows 7,运行:

Windows Vista和Windows 7:

C:\Users\your_user_name\.android\ List the SHA-1 fingerprint:

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

更新4

在Android Studio中,你可以找到没有任何控制台命令所有你的应用程序签名信息:

  1. 打开项目
  2. 从右侧面板中点击摇篮
  3. 在摇篮工程面板打开文件夹:你的项目 - >任务 - > Android的
  4. 运行signingReport任务(双击),你会看到在摇篮控制台中的结果(密钥存储路径,SHA1,MD5等)。


Answer 2:

结交新app.A星期前我做了2天之后的WebView网页视图的应用程序时不会加载任何umntil做出新的一个。



Answer 3:

1.Get谷歌地图API密钥

https://developers.google.com/maps/documentation/android-sdk/signup?authuser=1

2.Place无论是在strings.xml中或Android清单此API密钥

AndroidManifest.xml中

<meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="@string/google_maps_key" />

string.xml

<string name="google_maps_key">YOUR_API_KEY</string>

3.Put SupportMapFragment你希望XML中

<fragment
   android:id="@+id/placesMap"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:layout_marginTop="8dp"
   android:layout_marginBottom="8dp"
   android:tag="@string/tag_places_search_map"
   class="com.google.android.gms.maps.SupportMapFragment" />

最后是Activity

class SampleActivity :
        GoogleMap.OnMarkerClickListener,
        GoogleMap.OnMarkerDragListener,
        GoogleMap.OnInfoWindowClickListener,
        GoogleMap.OnInfoWindowLongClickListener,
        GoogleMap.OnInfoWindowCloseListener,
        OnMapAndViewReadyListener.OnGlobalLayoutAndMapReadyListener,
        GoogleMap.OnMapLoadedCallback
{
    private lateinit var map: GoogleMap

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val mapFragment = supportFragmentManager.findFragmentById(R.id.placesMap) as SupportMapFragment
        OnMapAndViewReadyListener(mapFragment, this)
    }

    internal inner class CustomInfoWindowAdapter : GoogleMap.InfoWindowAdapter {

        // These are both view groups containing an ImageView with id "badge" and two
        // TextViews with id "title" and "snippet".
        private val window: View = layoutInflater.inflate(R.layout.custom_info_window, null)
        private val contents: View = layoutInflater.inflate(R.layout.custom_info_contents, null)

        override fun getInfoWindow(marker: Marker): View? {
             render(marker, window)
            return window
        }

        override fun getInfoContents(marker: Marker): View? {
            render(marker, contents)
            return contents
        }

        private fun render(marker: Marker, view: View) {

            // Set the title and snippet for the custom info window
            val title: String? = marker.title
            val titleUi = view.findViewById<TextView>(R.id.title)

            if (title != null) {
                // Spannable string allows us to edit the formatting of the text.
                titleUi.text = SpannableString(title).apply {
                    setSpan(ForegroundColorSpan(resources.getColor(R.color.text_grey_heading)), 0, length, 0)
                }
            } else {
                titleUi.text = ""
            }

            val snippet: String? = marker.snippet
            val snippetUi = view.findViewById<TextView>(R.id.snippet)
            snippetUi.text = snippet
        }
    }

    override fun onMarkerClick(marker: Marker?): Boolean {
        marker?.zIndex = marker?.zIndex?.plus(1.0f)!!
        val handler = Handler()
        val start = SystemClock.uptimeMillis()
        val duration = 1500

        val interpolator = BounceInterpolator()

        handler.post(object : Runnable {
            override fun run() {
                val elapsed = SystemClock.uptimeMillis() - start
                val t = Math.max(
                        1 - interpolator.getInterpolation(elapsed.toFloat() / duration), 0f)
                marker?.setAnchor(0.5f, 1.0f + 2 * t)

                // Post again 16ms later.
                if (t > 0.0) {
                    handler.postDelayed(this, 16)
                }
            }
        })
        return false
    }

    override fun onMarkerDragEnd(p0: Marker?) {
    }

    override fun onMarkerDragStart(p0: Marker?) {
    }

    override fun onMarkerDrag(p0: Marker?) {
    }

    override fun onInfoWindowClick(marker : Marker) {
        //Toast.makeText(this, "Click Info Window", Toast.LENGTH_SHORT).show()
    }

    override fun onInfoWindowClose(marker : Marker) {
        //Toast.makeText(this, "Close Info Window", Toast.LENGTH_SHORT).show()
    }

    override fun onInfoWindowLongClick(marker : Marker) {
        //Toast.makeText(this, "Info Window long click", Toast.LENGTH_SHORT).show()
    }

    override fun onMapLoaded() {
        addMarkersToMap()
    }

    override fun onMapReady(googleMap: GoogleMap?) {
        map = googleMap ?: return

        with(map) {
            // Hide the zoom controls as the button panel will cover it.
            uiSettings.isZoomControlsEnabled = false

            // Setting an info window adapter allows us to change the both the contents and
            // look of the info window.
            setInfoWindowAdapter(CustomInfoWindowAdapter())

            // Set listeners for marker events.  See the bottom of this class for their behavior.
            setOnMarkerClickListener(this@SampleActivity)
            setOnInfoWindowClickListener(this@SampleActivity)
            setOnMarkerDragListener(this@SampleActivity)
            setOnInfoWindowCloseListener(this@SampleActivity)
            setOnInfoWindowLongClickListener(this@SampleActivity)
            setOnMapLoadedCallback(this@SampleActivity)

            // Override the default content description on the view, for accessibility mode.
            // Ideally this string would be localised.
            setContentDescription("Map with lots of markers.")
        }
    }

    fun addMarkersToMap(data: List<Places>) {
        // create bounds that encompass every location we reference
        val boundsBuilder = LatLngBounds.Builder()

        data.map { place -> boundsBuilder.include(LatLng(place.venue.location.lat!!,place.venue.location.lng)) }
        val bounds = boundsBuilder.build()
        with(map){
            moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50))
        }
        val list : MutableList<PlaceDetails> = mutableListOf<PlaceDetails>()
        for (place in data){
            list.add(PlaceDetails(place.id,LatLng(place.venue.location.lat!!,place.venue.location.lng),
                    place.venue.name,
                    place.getDistance()))
        }

        //add Seattle center as marker on map
        var seattlePD : PlaceDetails = PlaceDetails(TConstants.SEATTLLE_ID,
            LatLng(resources.getString(R.string.seattle_lat).toDouble(), resources.getString(R.string.seattle_long).toDouble()),
                "Seattle","Seattle Center",
                BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN))
        map.addMarker(MarkerOptions()
                .position(seattlePD.position)
                .title(seattlePD.title)
                .snippet(seattlePD.snippet)
                .icon(seattlePD.icon)
                .infoWindowAnchor(seattlePD.infoWindowAnchorX, seattlePD.infoWindowAnchorY)
                .draggable(seattlePD.draggable)
                .zIndex(seattlePD.zIndex))

        for (placeDetails in list){
            var marker = map.addMarker(MarkerOptions()
                    .position(placeDetails.position)
                    .title(placeDetails.title)
                    .snippet("Distance : "+placeDetails.snippet)
                    .icon(placeDetails.icon)
                    .infoWindowAnchor(placeDetails.infoWindowAnchorX, placeDetails.infoWindowAnchorY)
                    .draggable(placeDetails.draggable)
                    .zIndex(placeDetails.zIndex))
            searchViewModel.markerTracker.put(marker.id,placeDetails)
        }
    }
}


文章来源: my app is showing blank map