我在我的项目中使用org.jetBrains.kotlin:kotlin反射库(包含在gradle依赖项中)。
该应用程序一直没有任何问题,但是在将android插件升级到最新版本3.1.0之后,该应用程序开始在一个设备上崩溃(Nexus 5,Android4.4.3)。日志如下:
E/AndroidRuntime:致命异常: kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin反射实现在运行时找不到。确保在kotlin.jvm.internal.ClassReference.error(ClassReference.kt:86) at k
我尝试在库模块中使用Kotlin,而不是在app模块中使用它。app模块只使用Java,不使用库中的任何Kotlin类。Gradle不会编译hoever:
Error:(2, 1) A problem occurred evaluating project ':<Library>'.
> Plugin with id 'kotlin-android' not found.
我做了一些更改以包括Kotlin:
{库根目录}/ build.gradle
buildscript {
ext.kotlin_version = '1.1.3-2&
我正在使用Android 4.1.2在macOS上更新一个现有的、基于Java的Android应用程序。我现在第一次为这个项目增加了Kotlin的支持。虽然Kotline代码可以在没有任何问题的情况下使用,但代码中的断点不起作用:
// Kotlin file Utils.kt
package com.example.myApp
fun doSomething(a: Int, b: Int): Int {
Log.d("Debug", "I did something...")
val sum = a + b
return sum
}
在暂停了我的应用程序项目(在iOS和安卓手机和平板电脑上运行)大约6个月之后,我现在更新了Android (包括颤振等)。我的应用程序的进一步开发。android更新对于iOS模拟器来说没有问题。但是,当我试图使用Android仿真程序运行它时,我现在得到了很多错误:
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
..。错误列表以以下内容结尾:
在使用并运行应用程序时,我遇到了一个非常奇怪的问题,我得到了以下错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':shared_preferences:extractDebugAnnotations'.
> Could not resolve all files for configuration ':shared_preferences:lintClassPath'.
> Could not find kot
我从Java切换到Kotlin,我是一个全新的人。我试着做了一个可以精确计算你的年龄的应用程序。age输入是通过Android Studio中的EditText实现的。然后在TextView中设置你的年龄。 当我按下按钮时,应用程序崩溃。下面是Kotlin代码 var edtTxtAge = findViewById<EditText>(R.id.edtTxtAge)
val btnCalc = findViewById<Button>(R.id.btnCalc)
var txtAge = findViewById<
我正在用firebase和kotlin编写一个android应用程序。现在我创建了一个kotlin类,它扩展了Service类。
问题是,在启动服务之后,如果我关闭应用程序,就会崩溃!
如果我用java编写相同的代码,一切都很好!我不明白为什么当我使用kotlin时它会崩溃
看看我的代码。
myService.kt
class myService : Service() {
internal var TAG = "tagForLogD"
override fun onBind(p0: Intent?): IBinder? {
return nu
对于用Kotlin编写的应用程序,我使用带反引号的方法名进行测试,如下所示: fun `API login error - don't save token or user`() { 它工作了,测试编译和工作没有问题,但Android Studio中的Lint用消息Identifier not allowed in Android将这些方法标记为错误。 有没有办法抑制这种情况,让Lint检查没有错误地通过,并且在Android Studio中它不会被标记为红色下划线?
当应用程序的gradle build.gradle.kts文件中没有启用Jetpack Compose标志时,我的LiveData观察器会根据片段中的代码为personsResult返回正确的数据类型kotlin.Result<List<Person>>: private fun observePersons() {
val observer: (kotlin.Result<List<Person>>) -> Unit = { personsResult ->
// Do something