i hope you can find my text cause i really confused with my project because the app can't installed in emulator. I wish your advice and guidance.
this the Logcat when running the app
我希望你能找到我的文字,因为我真的对我的项目感到困惑,因为应用程序不能安装在模拟器中。我希望你的建议和指导。这是运行应用程序时的日志记录
FATAL EXCEPTION: main
Process: com.kirani.submee, PID: 20134
java.lang.IllegalArgumentException: CreationExtras must have a value by `SAVED_STATE_REGISTRY_OWNER_KEY`
at androidx.lifecycle.SavedStateHandleSupport.createSavedStateHandle(SavedStateHandleSupport.kt:91)
at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:89)
at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:114)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:187)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:153)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:53)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:35)
at com.kirani.submee.fragments.loginRegister.RegisterFragment.getViewModel(RegisterFragment.kt:22)
at com.kirani.submee.fragments.loginRegister.RegisterFragment.access$getViewModel(RegisterFragment.kt:18)
at com.kirani.submee.fragments.loginRegister.RegisterFragment$onViewCreated$2.invokeSuspend(RegisterFragment.kt:48)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at androidx.lifecycle.DispatchQueue.drainQueue(DispatchQueue.kt:75)
at androidx.lifecycle.DispatchQueue.resume(DispatchQueue.kt:54)
at androidx.lifecycle.LifecycleController.observer$lambda-0(LifecycleController.kt:40)
at androidx.lifecycle.LifecycleController.$r8$lambda$7XqClT_TFDHmqX3ARP07WvbP2Qg(Unknown Source:0)
at androidx.lifecycle.LifecycleController$$ExternalSyntheticLambda0.onStateChanged(Unknown Source:4)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:360)
at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:271)
at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:313)
at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:151)
at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:134)
at androidx.fragment.app.Fragment.performStart(Fragment.java:3167)
at androidx.fragment.app.FragmentStateManager.start(FragmentStateManager.java:588)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:279)
at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:113)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1424)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2968)
at androidx.fragment.app.FragmentManager.dispatchStart(FragmentManager.java:2893)
at androidx.fragment.app.Fragment.performStart(Fragment.java:3171)
at androidx.fragment.app.FragmentStateManager.start(FragmentStateManager.java:588)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:279)
at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:113)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1424)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2968)
at androidx.fragment.app.FragmentManager.dispatchStart(FragmentManager.java:2893)
at androidx.fragment.app.FragmentController.dispatchStart(FragmentController.java:274)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:359)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1543)
at android.app.Activity.performStart(Activity.java:8330)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3670)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
2023-09-09 21:14:38.845 20134-20134 AndroidRuntime com.kirani.submee E at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@b7e6f51, Dispatchers.Main.immediate]
RegisterViewModel.kt
RegisterViewModel.kt
package com.kirani.submee.viewmodel
import androidx.lifecycle.ViewModel
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import com.kirani.submee.data.User
import com.kirani.submee.util.Resource
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.runBlocking
import javax.inject.Inject
@HiltViewModel
class RegisterViewModel @Inject constructor(
private val firebaseAuth: FirebaseAuth
): ViewModel() {
private val _register = MutableStateFlow<Resource<FirebaseUser>>(Resource.Unspecified())
val register: Flow<Resource<FirebaseUser>> = _register
fun createAccountWithEmailAndPassword(user: User, password: String){
runBlocking {
_register.emit(Resource.Loading())
}
firebaseAuth.createUserWithEmailAndPassword(user.email, password)
.addOnSuccessListener {
it.user?.let {
_register.value = Resource.Success(it)
}
}.addOnFailureListener{
_register.value = Resource.Error(it.message.toString())
}
}
}
Sealed class Resource.kt
密封的类资源.kt
package com.kirani.submee.util
sealed class Resource<T> (
val data: T?=null,
val message: String?=null
) {
class Success<T>(data: T): Resource<T>(data)
class Error<T>(message: String): Resource<T>(message = message)
class Loading<T>: Resource<T>()
class Unspecified<T> : Resource<T>()
}
SubmeeApplication.kt
SubmeeApplication.kt
package com.kirani.submee
import android.app.Application
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class SubmeApplication: Application() {
}
AppModule.kt
AppModule.kt
package com.kirani.submee.di
import com.google.firebase.auth.FirebaseAuth
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object AppModule {
@Provides
@Singleton
fun provideFirebaseAuth() = FirebaseAuth.getInstance()
}
data class User.kt
数据类User.kt
package com.kirani.submee.data
data class User(
val firstName: String,
val lastName: String,
val email: String,
var imagePath: String = ""
){
constructor(): this("","","","")
}
build.gradle(Module:app)
Build.gradle(模块:APP)
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-parcelize")
id("androidx.navigation.safeargs.kotlin")
id("com.google.gms.google-services")
id("kotlin-kapt")
id("com.google.dagger.hilt.android")
}
android {
namespace = "com.kirani.submee"
compileSdk = 33
defaultConfig {
applicationId = "com.kirani.submee"
minSdk = 28
targetSdk = 33
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures{
viewBinding = true
}
}
dependencies {
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.9.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("com.google.firebase:firebase-auth-ktx:22.1.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
implementation("br.com.simplepass:loading-button-android:2.2.0")
implementation("com.github.bumptech.glide:glide:4.13.0")
implementation("de.hdodenhof:circleimageview:3.1.0")
implementation("io.github.vejei.viewpagerindicator:viewpagerindicator:1.0.0-alpha.1")
implementation("com.shuhart.stepview:stepview:1.5.1")
implementation("androidx.navigation:navigation-fragment-ktx:2.4.2")
implementation("com.google.dagger:hilt-android:2.45")
kapt("com.google.dagger:hilt-android-compiler:2.45")
kapt("androidx.hilt:hilt-compiler:1.0.0")
}
kapt {
correctErrorTypes = true
}
build gradle.kst (Project:Structure)
构建gradle.kst(项目:结构)
buildscript {
dependencies{
classpath("androidx.navigation.safeargs:androidx.navigation.safeargs.gradle.plugin:2.5.0")
classpath("com.google.gms:google-services:4.3.15")
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.1.1" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
id("com.google.dagger.hilt.android") version "2.45" apply false
}
i've try anything till I forgot it
我什么都试过了,直到忘了为止
更多回答
我是一名优秀的程序员,十分优秀!