Tag: 安卓

Java和Kotlin组合生成错误(重复邮编条目)

我已经将Kotlin库添加到了我现有的项目中。 之后,我得到构建错误。 我评论了最近添加的所有库,并检查了添加kotlin库后的主要问题 Error:Execution failed for task ‘:app:transformClassesWithMultidexlistForDebug’. > java.io.IOException: Can’t write [/home/imedrix-server/StudioProjects/kardioscreen-operatorapp/app/build/intermediates/multi-dex/debug/componentClasses.jar] (Can’t read [/home/imedrix-server/StudioProjects/kardioscreen-operatorapp/app/build/intermediates/transforms/desugar/debug/76.jar(;;;;;;**.class)] (Duplicate zip entry [76.jar:org/intellij/lang/annotations/Flow.class])) 项目gradle buildscript { ext.kotlin_version = ‘1.2.21’ repositories { google() jcenter() } dependencies { classpath ‘com.android.tools.build:gradle:3.0.1’ classpath ‘com.google.gms:google-services:3.0.0’ classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version” classpath (‘com.google.firebase:firebase-plugins:1.0.5’) { exclude group: ‘com.google.guava’, module: ‘guava-jdk5’ } } } allprojects { repositories { google() […]

Kotlin插件崩溃Android Studio

我已经更新了Kotlin插件到版本1.1.61,但Android工作室不启动新的插件。 错误: Plugin ‘org.jetbrains.kotlin’ failed to initialize and will be disabled. Please restart Android Studio. com.intellij.openapi.extensions.impl.PicoPluginExtensionInitializationException: Duplicate registration for EP: org.jetbrains.uast.uastLanguagePlugin: original plugin com.intellij, new plugin org.jetbrains.kotlin

无法将Kotlin Android扩展程序添加到我的项目中

当我尝试通过以下方式添加kotlin-android-extensions: apply plugin: ‘kotlin-android-extensions’ 到我的项目Android Studio告诉我插件’kotlin-android-extensions not found? 出了什么问题? 我正在运行Android Studio 3.0 Canary 8

Kotlin – 混淆的属性名称

我正在开发一个Kotlin Android应用程序,我遇到了集成Google Sign In的问题,当我获取GoogleSignInAccount以提取属性时,属性名称似乎被混淆了(或以其他方式混淆),下面是在AS 2.3调试器上查看属性的方式: 以下是试图访问这些属性的代码片段: private fun googleSignInResult(data : GoogleSignInResult) { if (data.isSuccess) { if (data.signInAccount != null) { val account = data.signInAccount val authData = HashMap() authData[“id_token”] = account?.idToken.let { it } ?: return authData[“id”] = account?.id.let { it } ?: return val task = ParseUser.logInWithInBackground(“google”, authData) task.continueWith { user -> if (task.isCancelled) […]

让我们也来申请,如果在Kotlin拿走了一些未知的东西

我读了许多关于这些项目的Kotlin文件。 但是我不太清楚。 Kotlin的用途是什么, 还有 , 如何 取得细节? 我需要每个项目的例子。 请不要发布Kotlin文档。 我需要一个实时的例子和这些项目的用例。

在Android / Kotlin上加倍的字符串

我必须使用Kotlin将字符串转换为Android上的双精度字符串。 以下是应该在Kotlin工作,但不(没有这样的方法): var dbl = “1.0”.toDouble() 以下爪哇方式也不起作用: var dbl = Double.parseDouble(“1.0”) 显然, Android上的String类既没有Kotlin API,Double也没有常用的Java API? 是否有任何与Kotlin 在Android上的 优雅方式? 现在,我正在使用这个( 这个工作 ,但它是丑陋的): var dbl = java.lang.Double.parseDouble(“1.0”) 该项目刚刚使用Android Studio创建,使用以下版本: ext.kotlin_version = ‘1.1.51’ minSdkVersion 23 targetSdkVersion 26 因为我认为这是Android API和Kotlin API之间的一些不匹配。

Kotlin通用对话框不显示

无法显示通用对话框。我是Kotlin中的新手。有没有人遇到这个问题? 我努力了 class CommonStaticClass { fun showCommonPopUp(activity: Context, msg: String,drawable: Int): Dialog { val metrics = activity.resources.displayMetrics val dev_width = metrics.widthPixels val dev_height = metrics.heightPixels val dialogCommon = Dialog(activity) dialogCommon.window.setBackgroundDrawable(ColorDrawable(android.graphics.Color.TRANSPARENT)) dialogCommon.window.requestFeature(Window.FEATURE_NO_TITLE) dialogCommon.setContentView(R.layout.dialog_alert) dialogCommon.setCancelable(false) dialogCommon.setCanceledOnTouchOutside(false) dialogCommon.window.setLayout((dev_width* 85)/ 100, (dev_height* 25) / 100) val tv_headerObj = dialogCommon.findViewById(R.id.txt_header) as TextView val img_smileOBJ = dialogCommon.findViewById(R.id.img_smile) as ImageView img_smileOBJ.setImageResource(drawable) tv_headerObj.text […]

为什么在类路径中有不同版本的Kotlin JAR?

我决定在AS 3.0中添加一对Kotlin文件到现有的Java Android项目中。 一旦我添加Kotlin文件,我让助手添加适当的行到我的build.gradle文件,特别是: project build.gradle buildscript { ext.kotlin_version = ‘1.2.21’ //… dependencies { classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version” app build.gradle // top of file apply plugin: ‘com.android.application’ apply plugin: ‘kotlin-android’ //…. dependencies { compile “org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version” 不幸的是,所有的构建都会产生这样的警告 Warning:Runtime JAR files in the classpath should have the same version. These files were found in the classpath: /Users/sddsfsd/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.2.21/88bfff5aa470143a83b0bc5ec00c0be8cabd7cad/kotlin-stdlib-jdk7-1.2.21.jar (version 1.2) […]

用Kotlin完成另一个Android的活动

我试图用kotlin完成另一个(android)的活动。 我知道用java做的wat是用下面的代码( https://stackoverflow.com/a/10379275/7280257 ) 第一次活动: BroadcastReceiver broadcast_reciever = new BroadcastReceiver() { @Override public void onReceive(Context arg0, Intent intent) { String action = intent.getAction(); if (action.equals(“finish_activity”)) { finish(); // DO WHATEVER YOU WANT. } } }; registerReceiver(broadcast_reciever, new IntentFilter(“finish_activity”)); 在其他活动上: Intent intent = new Intent(“finish_activity”); sendBroadcast(intent); 出于某种原因,将java活动转换为kotlin不会提供有效的输出,如果有人可以给我正确的语法来正确使用kotlin,我会感激 kotlin输出(第一个活动) [确定] : val broadcast_reciever = object : BroadcastReceiver() […]

带有产品风味和Kotlin的ClassNotFoundException

我有一个主要在Kotlin编写的项目,但有一些Java类。 现在项目进展顺利,我想增加在不同的环境之间切换的可能性,为此我使用了风味: productFlavors { prod { dimension “default” buildConfigField ‘boolean’, ‘FABRIC’, ‘true’ applicationId = “com.myapp” } beta { dimension “default” buildConfigField ‘boolean’, ‘FABRIC’, ‘true’ applicationId = “com.myapp.beta” } dev { dimension “default” buildConfigField ‘boolean’, ‘FABRIC’, ‘false’ applicationId = “com.myapp.dev” } } 然而,当我运行的味道是不生产(这不会改变applicationId),我得到一个Java类的ClassDefNotFoundException: Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.myapp.beta.ui.view.ScrollBehavior” on path: DexPathList[[zip file “/data/app/com.myapp.beta-1/base.apk”],nativeLibraryDirectories=[/data/app/com.myapp.beta-1/lib/arm64, /system/lib64, […]