Amit Panchal
Amit Panchal

Reputation: 33

can android project use submodule's dependency?

I have one project named "A" in that I have included one "custom_retrofit" module, now custom_retrofit module contain retrofit library and this module is included in my project A.

Should I need to include retrofit library in project "A".

I have tried to run project A, but project A requires retrofit library when I try to use retrofit, why? It's already in submodule so, it should fetch from that!

Below is my project A's gradle

dependencies {
     api project(path:':custom_retrofit')
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 
}

my custom_retrofit module contain below gradle dependancies

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'

    /** Retrofit NetWorking Library **/
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.okhttp3:okhttp:4.9.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
    implementation('com.github.ihsanbal:LoggingInterceptor:3.1.0') {
        exclude group: 'org.json', module: 'json'
    }
}

Upvotes: 0

Views: 917

Answers (1)

Mohammed Alaa
Mohammed Alaa

Reputation: 3320

I think in your situation you should use api project(path:'custom_retrofit') instead of

implementation project(path:'custom_retrofit') you can check this article to know the difference between the both

Upvotes: 2

Related Questions