Я новичок в Kotlin, я хочу создать мобильное приложение для Android. Я использую Android studio 3.3, уровень API Android 28. Я использовал сваггер, чтобы получить весь свой веб-сервис RESTful, поэтому у меня есть android-client-генерируется файл, который содержит все веб-службы.Для начала я создал интерфейс Android для аутентификации по электронной почте и паролю ». Среди доступных веб-сервисов« apiMobileUsersGetByFireBaseIDGet ». В этом Ws для идентификации используется идентификатор firebase. Я создаю класс kotlin AUthentication следующим образом:
class Authentication : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_authentication)
var email = editTextEmail.text
var password = editTextPassword.text
FirebaseApp.initializeApp(this@Authentication)
val auth = FirebaseAuth.getInstance()
buttonlogin.setOnClickListener {
auth.signInWithEmailAndPassword(email.toString(), password.toString())
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
println("success")
if (verifyAvailableNetwork(this@Authentication)) {
CoroutineScope(Dispatchers.IO).launch {
val user = MobileApi().apiMobileUsersGetByFireBaseIDGet(auth.currentUser!!.uid)
if (user == UsersData()) {
withContext(Dispatchers.Main) {
var intent = Intent(this@Authentication, MainActivity::class.java)
intent.putExtra("id", auth.currentUser?.email)
startActivity(intent)
}
}
}
}
} else {
println("Error: ${task.exception?.message}")
}
}
}
}
fun verifyAvailableNetwork(activity: AppCompatActivity): Boolean {
val connectivityManager = activity.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networkInfo = connectivityManager.activeNetworkInfo
return networkInfo != null && networkInfo.isConnected
}
}
я добавил разрешение на доступ к Интернету в AndroidManifest.xml. Моя проблема в том, что я запускаю свое приложение на своем мобильном телефоне, ошибка
java.lang.ClassNotFoundException: Didn't find class "java.time.LocalDateTime" appear.Could you please tell me how can make my app functional and where's the problem, I'm really stuck. The error description as the following :
E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: com.app.homecraft, PID: 5345
java.lang.ClassNotFoundException: Didn't find class "java.time.LocalDateTime" on path: DexPathList[[zip file "/data/app/com.app.homecraft-1/base.apk", zip file "/data/app/com.app.homecraft-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.app.homecraft-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.app.homecraft-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.app.homecraft-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.app.homecraft-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.app.homecraft-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.app.homecraft-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.app.homecraft-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.app.homecraft-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.app.homecraft-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.app.homecraft-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.app.homecraft-1/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.parseType(KDeclarationContainerImpl.kt:283)
at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.loadParameterTypes(KDeclarationContainerImpl.kt:274)
at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.findConstructorBySignature(KDeclarationContainerImpl.kt:242)
at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:65)
at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:34)
at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke(ReflectProperties.java:92)
at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31)
at kotlin.reflect.jvm.internal.KFunctionImpl.getCaller(KFunctionImpl.kt)
at kotlin.reflect.jvm.ReflectJvmMapping.getJavaMethod(ReflectJvmMapping.kt:62)
at kotlin.reflect.jvm.KCallablesJvm.setAccessible(KCallablesJvm.kt:82)
at com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory.create(KotlinJsonAdapter.kt:206)
at com.squareup.moshi.KotlinJsonAdapterFactory.create(KotlinJsonAdapter.kt)
at com.squareup.moshi.Moshi.adapter(Moshi.java:137)
at com.squareup.moshi.Moshi.adapter(Moshi.java:97)
at com.squareup.moshi.Moshi.adapter(Moshi.java:71)
at io.swagger.client.apis.MobileApi.apiMobileUsersGetByFireBaseIDGet(MobileApi.kt:4126)
at com.app.homecraft.Authentication$onCreate$1$1$1.invokeSuspend(Authentication.kt:43)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)
Suppressed: java.lang.ClassNotFoundException: java.time.LocalDateTime
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 23 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available