在我的 logcat 中,我在服务器调用期间有这样的行:
Rejecting re-init on previously-failed class java.lang.Class<okhttp3.internal.platform.ConscryptPlatform$platformTrustManager$2>: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/conscrypt/ConscryptHostnameVerifier;
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.conscrypt.ConscryptHostnameVerifier" on path: DexPathList[[zip file "/data/app/package-JHk9QBF7PSIufoXeKqbmNA==/base.apk"],nativeLibraryDirectories=[/data/app/package-JHk9QBF7PSIufoXeKqbmNA==/lib/x86, /system/lib, /system/vendor/lib]]
Run Code Online (Sandbox Code Playgroud)
一段时间后我可以看到这样的消息:
okhttp.OkHttpClient: <-- HTTP FAILED: java.net.SocketTimeoutException: timeout
Run Code Online (Sandbox Code Playgroud)
我检查了我的设备上的互联网运行良好。应用程序没有崩溃,但我无法发送任何请求。例如,这一周一切都运行良好,但现在却损坏了:(如何修复此错误?
我的 gradle 应用程序文件:
buildscript {
ext.kotlin_version = '1.3.71'
repositories { jcenter() }
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlinx-serialization'
apply plugin: 'com.google.gms.google-services'
android { …Run Code Online (Sandbox Code Playgroud) 我正在通过 Google 的 Android 开发人员代码实验室为 unscramble 应用程序工作。我正在尝试将我的变量初始化wordsList为一个空的可变字符串列表:
private var wordsList: MutableList<String> = mutableListOf()
但是,在调试过程中,我看到wordsListis的值null而不是像[]. 我在 kotlin playground 中测试了代码,它应该是[]. 我附上了一张 android studio 向我展示的截图。我做错了什么,为什么我没有看到预期的行为?

这是我的项目的 gradle 文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.21"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual …Run Code Online (Sandbox Code Playgroud) 也许这个问题以前被问过,但我没有找到解决我的问题的方法。所以,我有一个像这样的数字general count,我必须得到除法的结果。但是,如果结果包含余数,我必须增加结果。我尝试创建自己的函数:
private fun mod(count: Int): Double {
val mainCount: Double
val remainder = count % 50
mainCount = if (remainder > 0) {
count.toDouble() / 50+1
} else {
count.toDouble() / 50
}
return mainCount
}
Run Code Online (Sandbox Code Playgroud)
但这没有帮助,然后我使用了这个功能:
val df = DecimalFormat("0")
df.roundingMode = RoundingMode.HALF_EVEN
Log.i("m", df.format(count/50).toString())
Run Code Online (Sandbox Code Playgroud)
但在日志中我得到了没有余数的主号码。例如我有这样的东西:
main count - 112
result of division - 2.24
what I want to get - 3
Run Code Online (Sandbox Code Playgroud)
也许我做错了什么?
例如我们有这样的数组:
val listArr = listOf(1,2,3,4,5,6,7)
Run Code Online (Sandbox Code Playgroud)
最后我们收到:
1,2,3,4,5,6,7
Run Code Online (Sandbox Code Playgroud)
也许可以这样写:
val listArr = listOf(1..7)
Run Code Online (Sandbox Code Playgroud)
并得到类似的结果。还是现在不可能?