Expand my Community achievements bar.

Retrofit Integration with AEM Cloud

Avatar

Level 1

Hi,

I am facing issue while using retrofit2 in my aem project.

I have added all the dependency and bundles as well.

Getting error in new OkHttpClient.Builder().

Error Message : noclassdeffounderror kotlin/jvm/internal/intrinsics

2 Replies

Avatar

Community Advisor

Hi @samikshas963487 
Please check, if you have retrofit2 osgi bundle installed and active, if not then try below:



Arun Patidar

Avatar

Community Advisor

Hi @samikshas963487 , Please follow the steps suggested by @arunpatidar , Along with that you can also check on below points.

You’re encountering a NoClassDefFoundError related to Kotlin dependencies. This error typically occurs when the Kotlin standard library is not included in your project. 

  • Add Kotlin Standard Library Dependency in pom.xml.
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib</artifactId>
        <version>1.8.0</version>
    </dependency>
  • Embed Kotlin Library in Your OSGi Bundle by configuring maven-bundle-plugin in pom.xml.
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>4.2.1</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Embed-Dependency>kotlin-stdlib</Embed-Dependency>
                        <Embed-Transitive>true</Embed-Transitive>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
  • Ensure All Necessary Dependencies Are Included in pom.xml.
    <dependency>
        <groupId>com.squareup.retrofit2</groupId>
        <artifactId>retrofit</artifactId>
        <version>2.9.0</version>
    </dependency>
    <dependency>
        <groupId>com.squareup.retrofit2</groupId>
        <artifactId>converter-gson</artifactId>
        <version>2.9.0</version>
    </dependency>
    <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>4.9.0</version>
    </dependency>
    <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>logging-interceptor</artifactId>
        <version>4.9.0</version>
    </dependency>

Hope this will help you !

Regards,

Shiv Prakash