Comments (14)
`
import com.bharath.kiet_student_app.BuildConfig
import com.bharath.kiet_student_app.data.repository.SupabaseRepositoryImpl
import com.bharath.kiet_student_app.domain.repository.SupabaseRepository
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.createSupabaseClient
import io.github.jan.supabase.postgrest.Postgrest
import io.github.jan.supabase.postgrest.postgrest
import io.github.jan.supabase.storage.Storage
import javax.inject.Singleton
/**
- @Property SupaModule Module for creating instances of supabase class components
- @sample SupaModule.provideSupabaseRepository
- @see AppModule for better documentation as methods are very similar
*/
@Installin(SingletonComponent::class)
@module
object SupaModule {
@Provides
@Singleton
fun provideSupabaseClient(): SupabaseClient {
return createSupabaseClient(
BuildConfig.SUPABASE_PROJECT_URL,
BuildConfig.SUPABASE_API_ANON_KEY,
) {
install(Storage)
install(Postgrest)
}
}
@Provides
@Singleton
fun providePostgrestClient(supabaseClient: SupabaseClient): Postgrest {
return supabaseClient.postgrest
}
@Provides
@Singleton
fun provideSupabaseRepository(supabaseClient: SupabaseClient): SupabaseRepository {
return SupabaseRepositoryImpl(supabaseClient.postgrest)
}
}`
Check this . Same error is happening every time.
Other components such as Postgrest is working fine .
Storage also working fine before 2.x.x supabase version. But after migrating to 2.x.x then this thing is happening
from supabase-kt.
Nothing had been changed
Same error is happening
from supabase-kt.
I tried again but same result app is crashing for no reason
from supabase-kt.
For some reason it fails to create a default settings instance, but if you don't use resumable uploads anyway you can just do this:
createSupabaseClient(
BuildConfig.SUPABASE_PROJECT_URL,
BuildConfig.SUPABASE_API_ANON_KEY,
) {
install(Storage) {
resumable {
cache = MemoryResumableCache()
}
}
install(Postgrest)
}
from supabase-kt.
@bharath914 Could you please also share code of the repository? Perhaps there's missing @Inject
annotation in the constructor of the SupabaseRepositoryImpl
. Also double check @HiltApplication
in your Application class and @AndroidEntry
point of the Fragment/Activity
from supabase-kt.
Closing due to inactivity. Feel free to reopen!
from supabase-kt.
Currently Im Using Compose but still the app is crashing
App Module.
`
@Installin(SingletonComponent::class)
@module
object SupaModule {
@Provides
@Singleton
fun provideSupabaseClient(): SupabaseClient {
return createSupabaseClient(
BuildConfig.SUPABASE_PROJECT_URL,
BuildConfig.SUPABASE_API_ANON_KEY,
) {
install(Postgrest)
install(Storage) {
resumable {
cache = MemoryResumableCache()
}
}
}
}
@Provides
@Singleton
fun providePostgrestClient(supabaseClient: SupabaseClient): Postgrest {
return supabaseClient.postgrest
}
@Provides
@Singleton
fun provideSupabaseRepository(supabaseClient: SupabaseClient): SupabaseRepository {
return SupabaseRepositoryImpl(supabaseClient.postgrest)
}
}`
Error Logs
FATAL EXCEPTION: main
Process: com.bharath.kiet_student_app, PID: 3323
java.lang.RuntimeException: Unable to create application com.bharath.kiet_student_app.KietApp: java.lang.NullPointerException
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6764)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
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)
Caused by: java.lang.NullPointerException
at com.russhwolf.settings.NoArgKt.Settings(NoArg.kt:32)
at io.github.jan.supabase.storage.resumable.SettingsResumableCache.(SettingsResumableCache.kt:15)
at io.github.jan.supabase.storage.resumable.SettingsResumableCacheKt.createDefaultResumableCache(SettingsResumableCache.kt:55)
at io.github.jan.supabase.storage.Storage$Config$Resumable.(Storage.kt:129)
at io.github.jan.supabase.storage.Storage$Config.(Storage.kt:120)
at io.github.jan.supabase.storage.Storage$Companion.createConfig(Storage.kt:170)
at io.github.jan.supabase.storage.Storage$Companion.createConfig(Storage.kt:156)
at io.github.jan.supabase.SupabaseClientBuilder.install(SupabaseClientBuilder.kt:100)
at com.bharath.kiet_student_app.di.SupaModule.provideSupabaseClient(SupaModule.kt:37)
at com.bharath.kiet_student_app.di.SupaModule_ProvideSupabaseClientFactory.provideSupabaseClient(SupaModule_ProvideSupabaseClientFactory.java:35)
at com.bharath.kiet_student_app.DaggerKietApp_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get(DaggerKietApp_HiltComponents_SingletonC.java:1102)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.bharath.kiet_student_app.DaggerKietApp_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get(DaggerKietApp_HiltComponents_SingletonC.java:1099)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.bharath.kiet_student_app.DaggerKietApp_HiltComponents_SingletonC$SingletonCImpl.supabaseProfileUseCase(DaggerKietApp_HiltComponents_SingletonC.java:1013)
at com.bharath.kiet_student_app.DaggerKietApp_HiltComponents_SingletonC$SingletonCImpl.customWorkerFactory(DaggerKietApp_HiltComponents_SingletonC.java:1029)
at com.bharath.kiet_student_app.DaggerKietApp_HiltComponents_SingletonC$SingletonCImpl.injectKietApp2(DaggerKietApp_HiltComponents_SingletonC.java:1077)
at com.bharath.kiet_student_app.DaggerKietApp_HiltComponents_SingletonC$SingletonCImpl.injectKietApp(DaggerKietApp_HiltComponents_SingletonC.java:1056)
at com.bharath.kiet_student_app.Hilt_KietApp.hiltInternalInject(Hilt_KietApp.java:51)
at com.bharath.kiet_student_app.Hilt_KietApp.onCreate(Hilt_KietApp.java:42)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1277)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6759)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
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)
from supabase-kt.
` import com.bharath.kiet_student_app.BuildConfig import com.bharath.kiet_student_app.data.repository.SupabaseRepositoryImpl import com.bharath.kiet_student_app.domain.repository.SupabaseRepository import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import io.github.jan.supabase.SupabaseClient import io.github.jan.supabase.createSupabaseClient import io.github.jan.supabase.postgrest.Postgrest import io.github.jan.supabase.postgrest.postgrest import io.github.jan.supabase.storage.Storage import javax.inject.Singleton
/**
- @Property SupaModule Module for creating instances of supabase class components
- @sample SupaModule.provideSupabaseRepository
- @see AppModule for better documentation as methods are very similar
*/@Installin(SingletonComponent::class) @module object SupaModule {
@Provides @Singleton fun provideSupabaseClient(): SupabaseClient { return createSupabaseClient( BuildConfig.SUPABASE_PROJECT_URL, BuildConfig.SUPABASE_API_ANON_KEY, ) { install(Storage) install(Postgrest) } } @Provides @Singleton fun providePostgrestClient(supabaseClient: SupabaseClient): Postgrest { return supabaseClient.postgrest } @Provides @Singleton fun provideSupabaseRepository(supabaseClient: SupabaseClient): SupabaseRepository { return SupabaseRepositoryImpl(supabaseClient.postgrest) }
}`
Check this . Same error is happening every time. Other components such as Postgrest is working fine . Storage also working fine before 2.x.x supabase version. But after migrating to 2.x.x then this thing is happening
It looks like you forgot to provide Storage
instance. Please add this block into your SupabaseModule
@Provides
@Singleton
fun provideSupabaseStorage(supabaseClient: SupabaseClient): Storage {
return supabaseClient.storage
}
from supabase-kt.
This is the exact what I provided in my sample. Check out the file here https://github.com/hieuwu/product-sample-supabase-kt/blob/main/app/src/main/java/com/example/manageproducts/di/SupabaseModule.kt
Can you also check the Fragment
or Activity
if it is marked with @AndroidEntryPoint
?
from supabase-kt.
I had checked your code it is same as mine. I also added @AndroidEntryPoint
and @HiltAndroidApp
.
There is no problem with Dagger Hilt . Also The supabase storage worked fine before the newest dependency upgrades.
I think there is a problem with the sdk itself .
Today I had updated to latest version 2.2.3 as well but the problem still exists.
Solve this problem Asap as my app heavily relies on storage feature.
Currently I Set my buckets to Public and accessing them by urls.
from supabase-kt.
Let me try to add MemoryResumableCache
. When I upgraded Supabase from 1.0.0 to 2.0.0, all the breaking change is mostly in GoTrue
and Postgrest
from supabase-kt.
I had checked your code it is same as mine. I also added
@AndroidEntryPoint
and@HiltAndroidApp
. There is no problem with Dagger Hilt . Also The supabase storage worked fine before the newest dependency upgrades. I think there is a problem with the sdk itself . Today I had updated to latest version 2.2.3 as well but the problem still exists. Solve this problem Asap as my app heavily relies on storage feature. Currently I Set my buckets to Public and accessing them by urls.
Can you try example from this https://supabase.com/docs/reference/kotlin/storage-from-upload?example=create-resumable-upload ?
from supabase-kt.
I tried with version 2.2.3 in my sample and it works well. Please double check again @bharath914 . It would be great if you provide the minimum code that cause the crash
from supabase-kt.
I will check and update here
from supabase-kt.
Related Issues (20)
- [Bug]: Column.Raw not removing line breaks
- [Feature request]: Update to Kotlin 2.0.0
- [Bug]: PostgREST filter logical operator unexpected behaviour HOT 1
- [Question]: Is it really necessary that if the authentication with the keys is incorrect it will exit the application with a FATAL ERROR? HOT 2
- [Question]: Is there a possibility to log in anonymously and make it persistent? HOT 6
- [Feature request]: Add support for new private channels
- [Bug]: supabase-runtime fails to connect on iOS devices HOT 3
- [Bug]: Extension functions in RealtimeExt.kt don't have to be suspend HOT 7
- [Question]: Trouble Implementing Password Reset on Android with Supabase HOT 3
- [Bug]: Auth refresh sessions is not working correctly HOT 9
- [Feature request]: App To App OAuth for Discord HOT 1
- [Feature request]: Simplify realtime flows for postgres changes
- [Question]: I think it's better to move the samples to root project? HOT 2
- [Feature request]: Improve Exception on Cancellation HOT 2
- [Bug]: [Storage] Empty file is created on Dashboard when pass empty `ByteArray` to upload function
- [Bug]: All object keys must match HOT 13
- [Bug]: Error: Missing one of these types: signup, email_change, sms, phone_change HOT 2
- [Feature request]: remove session, emit `SIGNED_OUT` when JWT `session_id` is invalid
- [Question]: How cancel supabase request? HOT 3
- [Feature request]: Export `SupabaseExperimental` annotation in `compose-auth-ui` plugin HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from supabase-kt.