[英]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.