I'm working on an online shopping application
i used dagger-hilt, coroutine, retrofit,databinding, mvvm, livedata and etc in this project
i was testing my application but suddenly xampp stopped and it never connected
i had a backup of my database so i uninstalled xampp and reinstalled it again then i import database in new database
before the error in xampp my application works but now when i start my app i see this error " " "com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $"
but the output of my php file is like this:
[
{...},
{...},
{...}
]
when add setlenient to my retrofit i see this error:
"Expected BeingArray but was String"
but as you can see the out put is not String its a list
this is my apiServise:
@GET("wristmetadata.php")
suspend fun getWristWatchMetaData(
@Query(
"wrist_id"
) wrist_id: Int
): Response<List<WristWatch>>
repository:
fun getWristMetaData(wrist_id: Int): LiveData<List<WristWatch>> {
val data = MutableLiveData<List<WristWatch>>()
val job = Job()
applicationScope.launch(IO + job) {
val response = api.getWristWatchMetaData(wrist_id = wrist_id)
withContext(Main + SupervisorJob(job)) {
data.value = response.body()
}
job.complete()
job.cancel()
}
return data
}
viewModel class:
fun getWristmetaData(wrist_id: Int) = repository.getWristMetaData(wrist_id = wrist_id)
this is for di:
@Module
@InstallIn(SingletonComponent::class)
object AppModule {
@Provides
@Singleton
fun provideRetrofit(): Retrofit =
Retrofit.Builder().baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
@Provides
@Singleton
fun provideResourceApi(retrofit: Retrofit): ResourceApi =
retrofit.create(ResourceApi::class.java)
@ApplicationScope
@Provides
@Singleton
fun provideApplicationScope() = CoroutineScope(SupervisorJob())
}
@Retention(AnnotationRetention.RUNTIME)
@Qualifier
annotation class ApplicationScope
i also cleaned my project or invalid cash and restart but didnt work
I will appreciate any help