Code Monkey home page Code Monkey logo

Comments (14)

bharath914 avatar bharath914 commented on June 12, 2024 1

`
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.

bharath914 avatar bharath914 commented on June 12, 2024 1

Nothing had been changed
Same error is happening
image

from supabase-kt.

bharath914 avatar bharath914 commented on June 12, 2024 1

I tried again but same result app is crashing for no reason

from supabase-kt.

jan-tennert avatar jan-tennert commented on June 12, 2024

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.

hieuwu avatar hieuwu commented on June 12, 2024

@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.

jan-tennert avatar jan-tennert commented on June 12, 2024

Closing due to inactivity. Feel free to reopen!

from supabase-kt.

bharath914 avatar bharath914 commented on June 12, 2024

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.

hieuwu avatar hieuwu commented on June 12, 2024

` 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.

hieuwu avatar hieuwu commented on June 12, 2024

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.

bharath914 avatar bharath914 commented on June 12, 2024

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.

hieuwu avatar hieuwu commented on June 12, 2024

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.

hieuwu avatar hieuwu commented on June 12, 2024

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.

hieuwu avatar hieuwu commented on June 12, 2024

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.

bharath914 avatar bharath914 commented on June 12, 2024

I will check and update here

from supabase-kt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.