我正在使用 Gradle 版本 4.10.3(需要 Android 支持),并尝试将测试预编译脚本放入我的buildSrc文件夹中,以便与项目中的各种模块一起使用。这是我的基本代码设置:
//maven-deploy.gradle.kts, a custom precompiled plugin under
// buildSrc\src\main\kotlin\maven-deploy.gradle.kts
plugins {
maven
signing
}
//a test task
tasks {
register("hello") {
doLast {
println("hello")
}
}
}
//buildSrc build.gradle.kts
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}
repositories {
jcenter()
}
//main project root's build.gradle.kts
plugins {
base
kotlin("jvm") version Vof.kotlin apply false
kotlin("android") version Vof.kotlin apply false
kotlin("android.extensions") version Vof.kotlin apply false
id("kotlinx-serialization") version Vof.kotlin apply false
id("maven-deploy")
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
error:Plugin [id: 'maven-deploy'] was not …Run Code Online (Sandbox Code Playgroud) 我正在构建一个自定义的gradle.kts脚本,该脚本将对我们所有的各个模块进行maven发布到sonatype存储库,但是遇到一个奇怪的错误。这是我maven-deploy.gradle.kts文件的内容:
plugins {
`maven-publish`
signing
}
publishing {
//expression 'publishing' cannot be invoked as a function.
//The function invoke() is not found
}
Run Code Online (Sandbox Code Playgroud)
我可以在maven-deploy.gradle.kts文件中正常运行任务,但不能尝试使用publishinggradle文档中的函数。有任何想法吗?我正在使用gradle版本4.10.3(我需要Android支持)。该maven-deploy.gradle.kts文件位于我的主项目的文件中buildSrc/src/main/kotlin,并正在其中添加。id("maven-deploy")build.gradle.kts
我的应用程序要求用户在其设置中启用“提高的位置准确性”。不幸的是,我无法找出正确的方法来真正进入正确的菜单,并且一旦设置完成就让后退按钮返回我的应用程序。
这是我所拥有的:
private fun checkLocationSettingsAsync() {
viewModel.launch(Dispatchers.IO) {
val locationSettings = client.checkLocationSettings(
locationBuilder.build()
).asDeferred()
locationSettings.asTask().addOnSuccessListener {
//location settings are already high accuracy
locationSettingsOkay = true
}.addOnFailureListener { e ->
if (e is ResolvableApiException) {
//location settings not satisfied, request to make them higher
runCatching {
val intent = Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)
startActivityForResult(intent, LOCATION_ACCURACY_ACCESS_CODE)
}.onFailure {
println(it.stackTrace)
}
}
}
locationSettings.await()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
when (requestCode) {
LOCATION_ACCURACY_ACCESS_CODE -> {
if (resultCode …Run Code Online (Sandbox Code Playgroud)