Back

android

  • 0
  • Android
  • Cloud
Batman
27 May, 2024, 12:38

whenever i'm using the setEndpoint method it gives me java Ambiguous error help me to resolve this issue here is the my code

public class MainActivity extends AppCompatActivity { private final String URL = "https://cloud.appwrite.io/v1"; Account account;

TypeScript
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
            io.appwrite.Client client = new io.appwrite.Client(this)
                    .setEndpoint(URL)
            .setProject("6648a30b00390a48c964")
            .setSelfSigned(true);

    account = new Account(client);


    account.create(
            "unique_user_id",
            "email@google.com",
            "password@12",
            Object.class, new Continuation<User<Object>>() {
                @NonNull
                @Override
                public CoroutineContext getContext() {
                    return null;
                }

                @Override
                public void resumeWith(@NonNull Object o) {

                    if (o instanceof User){

                        Log.d("Appwrite","User Created"+o);
                    }
                    else if (o instanceof AppwriteException){

                        Log.e("Appwrite","Error : "+((AppwriteException) o).getMessage());

                    }
                }
            }
    );

}

}

TL;DR
Developers facing issue setting the endpoint using a function can use the constructor of Client to set the endpoint directly. A specific code example is provided in the messages. Make sure to verify the example matches the documentation provided.
Daniel
27 May, 2024, 12:52

Could you provide the logcat?

Batman
27 May, 2024, 12:59

error: reference to setEndpoint is ambiguous .setEndpoint(URL) ^ both method setEndpoint(String) in Client and method setEndpoint(String) in Client match

Batman
27 May, 2024, 12:59

only this showing..

D5
27 May, 2024, 13:07

I think the appwrite SDK is for kotlin and not for java?

D5
27 May, 2024, 13:08

However you can add kotlin files in your android studio project

D5
27 May, 2024, 13:08

As it can interoperate with java

Batman
27 May, 2024, 13:09

ohh okiee is java sdk available ?

Batman
27 May, 2024, 13:15

then what i do now ??

D5
27 May, 2024, 14:53

I think you can mix java and kotlin on android studio, but not sure

Batman
27 May, 2024, 15:00

but if i'm not wrong appwrite android sdk work for both languages kotlin and java..

D5
27 May, 2024, 15:15

The code to init the SDK should look like this:

TypeScript
Client client = new Client(context)
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("5df5acd0d48c2"); // Your project ID
D5
27 May, 2024, 15:15
Batman
27 May, 2024, 15:18

but i'm facing this issue right now { reference to setEndpoint is ambiguous .setEndpoint(URL) both method setEndpoint(String) in Client and method setEndpoint(String) in Client match }

D5
27 May, 2024, 15:24

Thos doesn't looks like the example I sent you

Batman
27 May, 2024, 15:31

i've done many ways including your example but still facing the same issue

D5
27 May, 2024, 15:32

What's the SDK version you're using?

D5
27 May, 2024, 15:32

Is this cloud or self-hosted?

D5
27 May, 2024, 15:32

Could you try adding the URL directly into the corresponding place?

Batman
27 May, 2024, 17:10

5.1.1

Batman
27 May, 2024, 17:10

yes but still facing the same issue..

metin
6 Jun, 2024, 14:14

Hi @Batman did you find any solution ? I am having exact same problem and i couldnt find a solution.

be4st
15 Jun, 2024, 11:07

Hlo @Batman @metin did you find any solution? I am also having same problem.

D5
16 Jun, 2024, 10:08

@be4st@metin If you're still facing it, it will be better creating a new post

be4st
17 Jun, 2024, 15:00

@Batman instead of setting the endpoint using the function, you can use the constructor of Client to set your endpoint. something like this:

TypeScript
this.client = new Client(context, BuildConfig.ENDPOINT_URL);
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more