简体   繁体   English

为什么在我的项目中实现 mapbox 时会出错?

[英]Why am I getting error when implementing mapbox to my project?

I get this error when trying to implement mapbox to my project.尝试在我的项目中实现 mapbox 时出现此错误。 I did every thing following the official mapbox documentation.我按照官方的 mapbox 文档做了所有的事情。 But when I build the project I get this error.但是当我构建项目时,我得到了这个错误。 I have no idea why the error occurs.我不知道为什么会发生错误。 Can anyone please help.任何人都可以请帮忙。 This is the logcat error.这是 logcat 错误。

> Could not resolve all files for configuration ':app:debugCompileClasspath'.
   > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.2.
     Required by:
         project :app
      > No cached version of com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.2 available for offline mode.
      > No cached version of com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.2 available for offline mode.
      > No cached version of com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.2 available for offline mode.
      > No cached version of com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.2 available for offline mode.

Possible solution:
 - Disable offline mode and rerun the build

This is my mapbox kotlin class这是我的地图框 kotlin class

class mapBoxNav : AppCompatActivity() {

    private var mapView: MapView? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Mapbox.getInstance(this, getString(R.string.access_token))

        setContentView(R.layout.activity_map_box_nav)
        mapView= findViewById(R.id.mapView)
        mapView?.onCreate(savedInstanceState)

        mapView?.getMapAsync{mapboxMap->


        }


    }

    override fun onStart() {
        super.onStart()
        mapView?.onStart()
    }

    override fun onResume() {
        super.onResume()
        mapView?.onResume()
    }

    override fun onPause() {
        super.onPause()
        mapView?.onPause()
    }

    override fun onStop() {
        super.onStop()
        mapView?.onStop()
    }

    override fun onDestroy() {
        super.onDestroy()
        mapView?.onDestroy()
    }

    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)


            mapView?.onSaveInstanceState(outState)

    }

    override fun onLowMemory() {
        super.onLowMemory()
        mapView?.onLowMemory()
    }

}

This is my line of code I have added to build.gradle(project)这是我添加到build.gradle(project)的代码行

    repositories {
        google()
        mavenCentral()

        maven {
            url'https://api.mapbox.com/downloads/v2/releases/maven'
            authentication{
                basic(BasicAuthentication)

            }
            credentials{
                username = 'mapbox'
                password = project.properties['MAPBOX_DOWNLOADS_TOKEN']?:""
            }
        }

        jcenter() // Warning: this repository is going to shut down soon
    }

This is my gradle.build(Module) dependency这是我的gradle.build(Module)依赖项

 implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.2'
maven {
            url'https://api.mapbox.com/downloads/v2/releases/maven'
            authentication{
                basic(BasicAuthentication)

            }
            credentials{
                username = 'mapbox'
                password = project.properties['MAPBOX_DOWNLOADS_TOKEN']?:""
            }
        }

the code part above must be added to settings.gradle上面的代码部分必须添加到settings.gradle

And you must add dependcy to gradle.build(Module) like that而且您必须像这样向 gradle.build(Module) 添加依赖项

implementation   'com.mapbox.maps:android:10.7.0'

Look that link for detailed information.查看该链接以获取详细信息。 2021 MapBox Sdk Inst. 2021 MapBox Sdk 研究所

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 实现 google 登录时,我的 flutter 项目出现错误 - I am getting the error in my flutter project when implementing google sign in 为什么在运行应用程序时出现此错误? - Why am I getting this error when I run my app? 为什么在尝试与我的服务器通信时出现此错误? - Why am i getting this error when trying to communicate with my server? 为什么我在实现 GestureDetector 时出现错误? - Why am I getting an error from implementing GestureDetector? 为什么我的ListFragment中出现此错误? - Why Am I getting this error in my ListFragment? 为什么我无法在 android 中运行我的 flutter 项目,不断出现 gradle 错误? - why i am not able to run my flutter project in android constantly getting gradle error? 为什么我的Android项目中出现IndexOutOfBoundsException? - Why Am I getting an IndexOutOfBoundsException in my Android Project? 尝试在我的 Android 应用程序项目中添加电话身份验证时出现错误 - I am getting error when trying to add phone authentication in my Android app project 为什么在我的android应用程序中创建TelnetClient时出现错误? - Why am i getting an error when when creating a TelnetClient in my android application? 我在我的项目中收到一个已弃用的 API 错误 - i am getting a deprecated API error in my project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM