我正在学习Kotlin作为Euler项目的一个有趣的辅助项目。我刚从5分钟前的IntelliJ创意开始。
我有这样的代码:
fun Number.isMultipleOf(n: Number): Boolean {
return this % n == 0
}
fun main(args: Array<String>){
println(10.isMultipleOf(5))
}
编译错误如下:
Kotlin: Unresolved reference. None of the following candidates is applicable because
大家好,我试图创建和运行一个反应本地应用程序。我运行npx react-native init rn4,但当我运行npm run android时,出现了以下错误:
> Task :react-native-gradle-plugin:compileKotlin
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target compatibility should be set to the same Java ve
是否有一种方法可以禁用JOOQ的码原发出的警告?它创建了很多我想省略的日志。
w: [...]/Routines.kt: (3070, 13): 'Subltree' is deprecated.
w: [...]/Routines.kt: (3082, 1): This annotation is deprecated in Kotlin. Use '@kotlin.Deprecated' instead
w: [...]/Routines.kt: (3088, 13): 'Subltree' is deprecated.
w: [...]/R
对于String.strip(),我得到警告'strip(): String!' is deprecated. This member is not fully supported by Kotlin compiler, so it may be absent or have different signature in next major version"
为什么会这样呢?“条带”来自Java字符串,我应该使用什么?
我已经将Kotlin版本改为1.2.30。更新后,我无法运行项目。我得到了下面的错误信息。
Error:Execution failed for task ':app:compileDevDebugJavaWithJavac'.
> app: Original kapt is deprecated. Please add "apply plugin: 'kotlin-kapt'" to your build.gradle.
我该如何解决这个问题?
最简单的Kotlin
thufir@dur:~/github/gradleScriptKotlin$
thufir@dur:~/github/gradleScriptKotlin$ gradle clean shadowJar;java -jar build/libs/gradleScriptKotlin.jar
> Task :compileKotlin
Using Kotlin incremental compilation
> Task :shadowJar
A problem was found with the configuration of task &
我在Kotlin创建了一个事件系统,在那里可以收听和广播事件,类似于事件在C#中的工作方式。
要广播一个事件,我有一句台词:
playerConnected.broadcast(player)
这里,playerConnected是事件,player是上下文对象。
在IntellIJ中进行调试时,当“逐步进入”广播函数以查看事件侦听器所做的操作时,它将进入broadcast()函数,这是有意义的,它看起来如下所示:
fun broadcast(args: T) {
for (listener in listeners) {
try {
liste
我使用visual studio 2015来构建使用远程构建的移动cordova,但是我发现了错误和错误:
Warning PackageApplication is deprecated, use `xcodebuild -exportArchive` instead.
Error BLD102 Error : BLD00102 : No such file or directory 'xxx.plist'
如何在kotlin中计算Android设备的尺寸?
我试过了:
val displayMetrics = DisplayMetrics()
windowManager.defaultDisplay.getMetrics(displayMetrics)
var width = displayMetrics.widthPixels
var height = displayMetrics.heightPixels
它给出了以下错误:
"getter for defaultDisplay: Display!' is deprecated. Deprecated in Java:
在我正在工作的项目中,我得到了以下错误,我不知道如何在Android Studio上从JRE更改为JDK。
.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jre8\1.2.20\f77d7863695e17041b50ebe5e2f87e5314a2c812\kotlin-stdlib-jre8-1.2.20.jar: kotlin-stdlib-jre8 is deprecated. Please use kotlin-stdlib-jdk8 instead
我试图编写一个FileWriter来输出我的文件。
public class TestWriter{
public static void main(String[] args){
FileWriter fw = new FileWriter("\\User\\Eric\\Desktop\\writer.txt"); //absolute position
fw.write("testing"); //write some content in my text file
我在本地服务器上使用XAMPP和PHP 5.3.1,我的Cake项目使用"1.2.0.6311 beta",一切正常,但现在我得到这个错误消息
Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\htdocs\rh_pura\cake\libs\debugger.php on line 100
Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp
我正在尝试使用@JsonView注解从Spring中的对象反序列化几个字段。但是,我将注释添加到我的方法中,它返回一个空对象,而不是反序列化指定的字段。
这是我的POJO:
@Entity
data class Album(
@JsonView(View.AlbumSummary::class)
val title: String,
@JsonView(View.AlbumSummary::class)
@ManyToMany
val artists: List<Account>,
由于Kotlin1.4不推荐使用String.toBoolean()而不记录替换。我们现在应该使用java.lang.Boolean.parseBoolean代替,还是有一种Kotlin方法来代替它?
/**
* Returns `true` if the content of this string is equal to the word "true", ignoring case, and `false` otherwise.
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warnin
我已经安装了Eclipse Photon和Kotlin plugin for Eclipse 0.8.6和Spring Tools 3.9.5.RELEASE插件。我按照的指示创建了一个带有向导的新项目:
然后,我创建了一个新的Run Configuration,并按照引用中的指示编辑了主类:
在运行项目之后,我得到了以下错误:
Error: Could not find or load main class com.kotlinexample.KotlinExampleApplicationKt
Caused by: java.lang.ClassNotFoundExcept
我在Eclipse中有一个新的Kotlin项目(我安装了kotlin插件)。然而,这一守则:
val a: Int = 10000
println("Your Int Value is "+a);
导致此错误:
ERROR: Cannot access 'java.io.Serializable' which is a supertype of 'kotlin.String'. Check your module classpath for missing or conflicting dependencies.
这个错误的根源是什么
为什么我不能在kotlin中使用反射设置一个UShort?我把我的问题转化为单元测试。
我的测试看起来如下:
class Junk {
var DA: UShort? = null
}
class Tests {
@Test
fun testSetShort() {
var uut = Junk()
val value = 100
val expect = 100
val properties: Collection<KProperty<*>> = Junk::class.mem
我正在尝试用spring boot和kotlin构建一个简单的api。当我请求保存一个新用户时,一切都很顺利,一个新用户被持久化,但是响应体是空的。我不知道为什么,我返回新用户。请帮助我理解为什么Jackson没有序列化我的kotlin类。
我可以保证返回的用户不为空。
实体:
@Entity
data class User(@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private val id: Long = 0L,
priva
使用下面的代码,我在IntelliJ IDEA 13.1.6和Kotlin插件0.11.91.AndroidStudio.3中得到了以下错误:
Platform declaration clash: The following declarations have the same JVM signature (getName()Ljava/lang/String;):
• public open fun getName(): kotlin.String?
• internal final fun <get-name>(): kotlin.String?
Java类,Java
Kotlin Gradle插件在不同的子项目中加载了多次,这是不支持的,可能会破坏构建。
这种情况可能发生在应用带有Gradle 'plugins {. }‘DSL的Kotlin插件的子项目中,如果它们指定显式版本,即使版本是相等的。请将Kotlin插件添加到公共父项目或根项目中,然后删除子项目中的版本。
如果父项目不需要插件,则在插件行中添加“apply false”。参见: Kotlin插件是在以下项目中加载的:‘:expo’,‘:react本地-agora’
任务:世博-权限:编译permissions失败
Deprecated Gradle features were use
我正在使用Kotlin的html库kotlinx.html进行动态html构建。
我想要创建一个按钮,它在单击时触发一个函数。这是我目前的代码:
class TempStackOverflow(): Template<FlowContent> {
var counter: Int = 1
override fun FlowContent.apply() {
div {
button(type = ButtonType.button) {
onClick = "${clicked()}&