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

ImageKit instantiation error #29

Open
Hadit1993 opened this issue May 23, 2023 · 5 comments
Open

ImageKit instantiation error #29

Hadit1993 opened this issue May 23, 2023 · 5 comments

Comments

@Hadit1993
Copy link

Hadit1993 commented May 23, 2023

Hi.
I went along with documentaion and added config.properties in my resource folder and added public and private keys and url endpont there.
and here is my imagekit instantiation:

@SpringBootApplication
class EShopBackApplication

fun main(args: Array<String>) {
    
    runApplication<EShopBackApplication>(*args)
	val imageKit = ImageKit.getInstance()
	val config = Utils.getSystemConfig(EShopBackApplication::class.java)
	imageKit.config = config
}

When I run the app I got this error:

Exception in thread "main" java.lang.NoSuchFieldError: Companion
	at okhttp3.internal.Util.<clinit>(Util.kt:70)
	at okhttp3.OkHttpClient.<clinit>(OkHttpClient.kt:1073)
	at io.imagekit.sdk.tasks.RestClient.<init>(RestClient.java:60)
	at io.imagekit.sdk.ImageKit.getInstance(ImageKit.java:40)
	at com.hadit1993.eshopback.EShopBackApplicationKt.main(EShopBackApplication.kt:16)

What is the problem?

@Ox0017
Copy link

Ox0017 commented Aug 18, 2023

Problem is the required dependency com.squareup.okhttp3:okhttp:3.10.0 (from 2018)
You are probably using a newer okhttp version in your project through spring.

@Pradeep7976
Copy link

Still not fixed ??
7 months

@NoonieBao
Copy link

problem still......however, as 0x00117 say, i add the okhttp dependency, now it work well.

        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>3.10.0</version>
        </dependency>
            ImageKit imageKit = ImageKit.getInstance();

            Configuration config = new Configuration(your_public_key, your_private_key, your_url_endpoint);
            imageKit.setConfig(config);

            
            byte[] bytes1 = file.getBytes();
            FileCreateRequest fileCreateRequest = new FileCreateRequest(
                    bytes1,           //  required, "binary", "base64" or "file url"
                    "sample-image11.jpg"    //  required
            );
            Result resultt = imageKit.upload(fileCreateRequest);
            System.out.println(resultt);

@Hadit1993
Copy link
Author

Hadit1993 commented Mar 31, 2024

@NoonieBao I recommend you not using this library in real projects. it's obvious that this repository is not maintained properly and in the future you may get dependency version conflict errors.

@NoonieBao
Copy link

@NoonieBao I recommend you not using this library in real projects. it's obvious that this repository is not maintained properly and in the future you may get dependency version conflict errors.

Good tips, thanks! It is only being used for my personal project, and I have made a backup for unexpected conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants