Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Initialise supposeClient realtime #17

Closed
2 tasks done
bhavinmac opened this issue Oct 18, 2022 · 8 comments
Closed
2 tasks done

[Bug]: Initialise supposeClient realtime #17

bhavinmac opened this issue Oct 18, 2022 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@bhavinmac
Copy link

General Info

  • I installed the latest version of Supabase-Kt
  • I checked for similar bug report

What happened? (include your code)

class SplashKotlinActivity : AppCompatActivity() {

val supabaseClient = createSupabaseClient {
    supabaseUrl = "https://MY_KEY.supabase.co/realtime/v1"
    supabaseKey = "SUPABASE_KEY"

    install(Realtime)
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_splash)
    initializeAndroid(supabaseClient)

}

Run app and it crases and trows errro: java.lang.ExceptionInInitializerError

Platform(s)

Android

Relevant log output

java.lang.ExceptionInInitializerError
        at io.ktor.client.HttpClientJvmKt.HttpClient(Unknown Source:0)
        at io.github.jan.supacompose.SupabaseClientImpl.<init>(SupabaseClient.kt:94)
        at io.github.jan.supacompose.SupabaseClientBuilder.build(SupabaseClientBuilder.kt:30)
        at com.wweevv.SplashKotlinActivity.<init>(SplashKotlinActivity.kt:65)
        at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1272)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3389)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3620)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2183)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:241)
        at android.app.ActivityThread.main(ActivityThread.java:7617)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
     Caused by: java.lang.IllegalStateException: Failed to find HTTP client engine implementation in the classpath: consider adding client engine dependency.
@bhavinmac bhavinmac added the bug Something isn't working label Oct 18, 2022
@brezinajn
Copy link
Contributor

add this dependency

implementation("io.ktor:ktor-client-cio:2.1.1")

@jan-tennert
Copy link
Collaborator

jan-tennert commented Oct 18, 2022

Yes you need a Ktor Client Engine, might include this in the readme

@bhavinmac
Copy link
Author

add this dependency

implementation("io.ktor:ktor-client-cio:2.1.1")

Now getting error "java.lang.IllegalStateException: The schema must be specified"

@jan-tennert
Copy link
Collaborator

jan-tennert commented Oct 18, 2022

Also the supabase url should just be https://MY_KEY.supabase.co
If you want to have a different URL just for realtime, you can change it in the realtime config but supabase-kt handles the urls for the different modules automatically

General Info

* [x]  I installed the latest version of Supabase-Kt

* [x]  I checked for similar bug report

What happened? (include your code)

class SplashKotlinActivity : AppCompatActivity() {

val supabaseClient = createSupabaseClient {
    supabaseUrl = "https://MY_KEY.supabase.co/realtime/v1"
    supabaseKey = "SUPABASE_KEY"

    install(Realtime)
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_splash)
    initializeAndroid(supabaseClient)

}

Run app and it crases and trows errro: java.lang.ExceptionInInitializerError

Platform(s)

Android

Relevant log output

java.lang.ExceptionInInitializerError
        at io.ktor.client.HttpClientJvmKt.HttpClient(Unknown Source:0)
        at io.github.jan.supacompose.SupabaseClientImpl.<init>(SupabaseClient.kt:94)
        at io.github.jan.supacompose.SupabaseClientBuilder.build(SupabaseClientBuilder.kt:30)
        at com.wweevv.SplashKotlinActivity.<init>(SplashKotlinActivity.kt:65)
        at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1272)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3389)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3620)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2183)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:241)
        at android.app.ActivityThread.main(ActivityThread.java:7617)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
     Caused by: java.lang.IllegalStateException: Failed to find HTTP client engine implementation in the classpath: consider adding client engine dependency.

@jan-tennert
Copy link
Collaborator

add this dependency

implementation("io.ktor:ktor-client-cio:2.1.1")

Now getting error "java.lang.IllegalStateException: The schema must be specified"

This exception is thrown if you try to listen for db changes without actually specifying a schema.
See https://github.com/supabase-community/supabase-kt/tree/master/Realtime under Listening for Postgres changes for more informations

@brezinajn
Copy link
Contributor

brezinajn commented Oct 18, 2022

This actually bugs me. Even though I like the DSL style for settings, it doesn't force the consumer to provide required arguments and results in crash at runtime and it increases difficulty for new users. So maybe we should force required args as function arguments.
e. g.

createSupabaseClient(
    supabaseUrl = "https://MY_KEY.supabase.co/realtime/v1"
    supabaseKey = "SUPABASE_KEY"
) {
    install(Realtime)
    ...
}

Even more so now when this library is part of supabase community (congrats btw :) great job). So there is actually a danger of people using it :D

@jan-tennert
Copy link
Collaborator

This actually bugs me. Even though I like the DSL style for settings, it doesn't force the consumer to provide required arguments and results in crash at runtime and it increases difficulty for new users. So maybe we should force required args as function arguments. e. g.

createSupabaseClient(
    supabaseUrl = "https://MY_KEY.supabase.co/realtime/v1"
    supabaseKey = "SUPABASE_KEY"
) {
    install(Realtime)
    ...
}

Even more so now when this library is part of supabase community (congrats btw :) great job). So there is actually a danger of people using it :D

Thanks, yea you are right, maybe I should change that!

@jan-tennert
Copy link
Collaborator

jan-tennert commented Oct 18, 2022

I'd close this issue to keep things clean. Feel free to open another issue when you have any issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants