当我尝试创建一个新的OkHttpClient对象时,会引发异常
我使用的是OkHttp 3.11.0和OkIO 2.0.0-RC1。
线程"main“中的异常: kotlin/TypeCastException at okhttp3.ResponseBody.create(ResponseBody.java:210) at okhttp3.internal.Util.(Util.java:60) at okhttp3. okhttp3.OkHttpClient.(OkHttpClient.java:123) at p12.Main.main(Main.java:8),由: java.
fun handle() : String {
null?.let { return "Ololo"}
}
val result = handle()
result.trim() // kotlin.TypeCastException: null cannot be cast to non-null type kotlin.CharSequence
知道为什么空安全的Kotlin函数返回空吗?
open class Super {
open var name : String = "Name1"
init {
println("INIT block fired with : $name")
name = name.toUpperCase()
println(name)
}
}
class SubClass(newName : String) : Super() {
override var name : String = "Mr. $newName"
我是,有以下代码:
private fun search(g: String, l: GeoPoint): Task<String> {
val data = hashMapOf(
"uid" to user.uid,
"first_name" to user.first_name,
"age" to user.age,
"gender" to user.gender,
"bio" to user.bio,
伙计们!
我在使用DBUnit时遇到了问题:
在我的测试类中,当我调用DatabaseOperation.INSERT.execute(connection,dataSet)时,使用引用包含类型为年份(4)- MySQL的列的表的FlatXmlDataSet得到以下信息:
(...)
Caused by: org.dbunit.dataset.datatype.TypeCastException: Error casting value for table 'Vehicle' and column 'LaunchYear'
at org.dbunit.o
所以,这是我现在的代码,但是当我运行这个程序时,这个应用程序仍然崩溃:
db.collection("historyCal").document(idData.toString()).get()
.addOnSuccessListener { document ->
if (document != null) {
val calin = document.get("calInDay") as List<*>
calin.forEach {
L
我已经找到了一个能广泛帮助我的代码的答案,但是我找到的解决方案对我没有用。
我得到以下错误:
kotlin.TypeCastException: null cannot be cast to non-null
type kotlin.collections.Map<kotlin.String, kotlin.Any>
FATAL EXCEPTION: main
Process: com.meetHitch.HitchApp, PID: 4021
kotlin.TypeCastException: null cannot be cast t
我有一个使用OkHttp进行网络速度测试的安卓应用程序。现在我需要用NetBeans 8.2为桌面创建另一个客户端,但是我不能让OkHttp工作。我包含了库okhttp-3.11.0和okio-2.0.0,但我得到的是java.lang.NoClassDefFoundError。
我的代码是:
public class TestCheckNetwork {
private final JFrame frame;
private final OkHttpClient client;
long startTime;
long endTime;
long fileSize;
TestCheck
我试图从Kotlin代码中调用Java方法org.springframework.data.mongodb.core.query.Update#set。此方法声明为
public Update set(String key, Object value)
没有关于参数可空性的附加注释或注释。实际上,它只是将value放入HashMap中,因此实际上value可能是null。
但是,Kotlin编译器将value类型视为Any (而不是预期的Any!),并在将null传递给
Null can not be a value of a non-null type Any
使用!!传递可空值会明显导致K
我在Kotlin中创建了一个数据类,其中包含了一个ByteArray图像。当我构建时,我有以下错误:
Error:Kotlin: [Internal Error] java.lang.IllegalStateException: Backend Internal error: Exception during code generation
Cause: An operation is not implemented: primitive arrays are not supported yet
File being compiled at position: file:///my/home/
我试图以一种惯用的方式复制kotlin中的一些java代码。特别是,我希望在重写子setter以供将来使用时使用父setter。在java中,我可以做到:
public class Parent() {
public View rootView;
void setRootView(View view) {
this.rootView = view
}
}
public class Child() extends Parent() {
private FrameLayout layout;
public Child(View r
谷歌刚刚发布了AndroidStudio4.2稳定版。我更新了我的从4.1到4.2。现在我得到了这个错误。它显示了数据绑定中的错误。
Caused by: java.util.ServiceConfigurationError: javax.annotation.processing.Processor: android.databinding.annotationprocessor.ProcessDataBinding Unable to get public no-arg constructor
at kotlin.collections.CollectionsKt___C
我正在尝试解码HTML实体,目前我的代码是:
val str = name
val textView = findViewById<View>(R.id.text) as TextView
textView.text = Html.fromHtml(str, Html.FROM_HTML_MODE_COMPACT)
这里的错误信息是:
kotlin.TypeCastException: null cannot be cast to non-null type android.widget.TextView
我试图将代码基从Java转移到Kotlin。但我在String.format中发现了奇怪的行为。
我在Kotlin和Java中都有相同的代码(以及特性)。
fun callScriptMethod(methodName: String, vararg args: Any): String {
var format = methodName
if (!format.contains("javascript:")) {
format = String.format("javascript:%s", format
我正在做一个数据快照,我得到了一个错误
val passwordFromDB = datasnapshot.child(completePhoneNumber).child("password").getValue<String>(String::class.java) as String
if (passwordFromDB.equals(userPassword)) {
et_Password.error = null
//get user data from datasnapshot
val usernameFromDB = datas
在我的Application类的onCreate方法中有以下代码
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getSystemService(Context.MIDI_SERVICE).also {
MidiController.instance.midiManager = it as MidiManager
}
}
当我在我的设备上测试这个代码时,我没有遇到任何问题,但是一些用户的设备报告了以下错误
java.lang.RuntimeException:
at android.app.
我正在尝试从Android开发者站点获得的片段基础源代码。我将代码转换为Kotlin,只需使用Code > tablet to Kotlin特性,并尝试在Nexus10API23仿真器平板上运行它。
我在这行的ArticleFragment中有一个错误:
fun updateArticleView(position: Int) {
//here, there is no view in activity for ID article, so it's null
val article = activity.findViewById<TextView>(
我试着通过heroku run bash运行kotlin spring webapp。然后我就跑了:
java -cp ./build/libs/pss_kotlin-1.0-SNAPSHOT.jar pl.makzyt.pss_kotlin.MainKt
然后我得到了这个错误:
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at pl.makzyt.pss_kotlin.MainKt.main(Main.kt)
Caused b
我在读。
说:
如果类具有与扩展函数具有相同签名的成员函数,则成员函数始终优先于。
同时,本书还演示了 Kotlin的stdlib扩展函数(它比的API更容易混淆)。我不明白的是,这个split扩展函数是如何在以下调用中占据优先地位的:
"12.345-6.A".split(".") // <-- Kotlin's extension function gets invoked here even though there is a member function on String class in Java with matching