imagekit-java icon indicating copy to clipboard operation
imagekit-java copied to clipboard

ImageKit instantiation error

Open Hadit1993 opened this issue 2 years ago • 5 comments

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?

Hadit1993 avatar May 23 '23 17:05 Hadit1993

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.

Ox0017 avatar Aug 18 '23 16:08 Ox0017

Still not fixed ?? 7 months

Pradeep7976 avatar Mar 07 '24 20:03 Pradeep7976

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);

NoonieBao avatar Mar 29 '24 15:03 NoonieBao

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

Hadit1993 avatar Mar 31 '24 17:03 Hadit1993

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

NoonieBao avatar Apr 22 '24 14:04 NoonieBao