admin管理员组文章数量:1392081
I'm trying to set up the Mapbox SDK for use in Android Studio, which requires authentication setup. In every example I can find, it's supposed to be set up approximately like this in the dependencyResolutionManagement
block in settings.gradle
:
maven {
url = uri("URL HERE")
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = "" // private token here.
}
}
This is just giving a build error and the authentication basic(BasicAuthentication)
seems to be the problem. This call is in every example I can find, but the basic()
function seems to be returning the wrong type, and anyways I cannot for the life of me find the docs for that function, including what package it's in so that I can import the correct one.
Since every examples gives this code, I have tried to build the project using the setup with basic()
, but I'm getting the error message:
Classifier 'BasicAuthentication' does not have a companion object, and thus must be initialized here
This seems to result from basic()
being defined as returning a "SafeList
" object, which seems completely wrong as the parameter of the authentication()
method is to be an Action
object. So I can't "find" or import the correct basic()
function.
I'm trying to set up the Mapbox SDK for use in Android Studio, which requires authentication setup. In every example I can find, it's supposed to be set up approximately like this in the dependencyResolutionManagement
block in settings.gradle
:
maven {
url = uri("URL HERE")
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = "" // private token here.
}
}
This is just giving a build error and the authentication basic(BasicAuthentication)
seems to be the problem. This call is in every example I can find, but the basic()
function seems to be returning the wrong type, and anyways I cannot for the life of me find the docs for that function, including what package it's in so that I can import the correct one.
Since every examples gives this code, I have tried to build the project using the setup with basic()
, but I'm getting the error message:
Classifier 'BasicAuthentication' does not have a companion object, and thus must be initialized here
This seems to result from basic()
being defined as returning a "SafeList
" object, which seems completely wrong as the parameter of the authentication()
method is to be an Action
object. So I can't "find" or import the correct basic()
function.
2 Answers
Reset to default 1So I found out that every guide I looked at, assumed that Gradle setup was done with Groovy (in settings.gradle
), while I was using Kotlin (hence editing settings.gradle.kts
), and did not realize this. To update the auth setup accordingly with the correct syntax for Kotlin:
dependencyResolutionManagement {
repositories {
maven(url = uri("URL HERE")) {
credentials {
username = "username"
password = "" // private token here.
}
authentication.create<BasicAuthentication>("basic")
}
}
}
From your description you are missing a repositories
block. It should look like this:
dependencyResolutionManagement {
repositories {
maven {
url = uri("URL HERE")
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = "" // private token here.
}
}
}
}
Here, basic
is not a regular function but the name a of domain object of type BasicAuthentication
you are creating inside the AuthenticationContainer
. You should be able to call it whatever you like.
本文标签:
版权声明:本文标题:android - How do I fix a basic(BasicAuthentication) call in Gradle authentication setup when it is not documented and not workin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744781012a2624712.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
settings.gradle
(Groovy syntax) and notsettings.gradle.kts
(Kotlin syntax)? – CommonsWare Commented Mar 11 at 17:05