【已解决】 retrofit初学遇到无法执行onclick,已抓log,跪求解答
2020-02-18 15:45:07.203 24631-24631/com.chenjiahua.retrofitdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.chenjiahua.retrofitdemo, PID: 24631
java.lang.IllegalStateException: Could not execute method for android:onClick
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.BootstrapMethodError: Exception from call site #4 bootstrap method
Caused by: java.lang.ClassCastException: Bootstrap method returned null
2020-02-18 15:45:07.215 24631-24631/com.chenjiahua.retrofitdemo I/Process: Sending signal. PID: 24631 SIG: 9
在学习retrofit中,发现点击button的时候程序立马跑死。layout部分是使用可视化编辑设计的,onclick是在text部分手动敲入,ctrl + enter 根据IDE提示设置在activity中。
以往都是一样的操作,这次就不知道为啥不能执行,我看了一下我build.gradle 跟up是一样的。
代码部分反反复复对比了up的。只有UI布局不同,其他都已经跟着敲了一遍。还是一样的问题。

点击跳转那个MainActivity.java:48 部分,指的部分是baseUrl
有点懵逼,希望老师能给出相关资料可以让我学习解决一下。


布局文件
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="getRequest"
android:text="@string/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="409dp"
android:layout_height="681dp"
android:layout_marginTop="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button"
app:layout_constraintVertical_bias="1.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
请问你这个问题是怎么解决的。。我也是同样的问题