Включить зависимости в aar - PullRequest
0 голосов
/ 15 февраля 2019

Я пытаюсь сгенерировать aar, чтобы использовать его без maven.

У меня есть следующие зависимости:

api fileTree(include: ['*.jar'], dir: 'libs')
api 'com.squareup.retrofit2:retrofit:2.5.0'
api 'com.squareup.retrofit2:converter-gson:2.5.0'
api 'com.squareup.okhttp3:logging-interceptor:3.12.0'
implementation 'com.android.support:appcompat-v7:28.0.0'

Но когда я импортирую сгенерированный aar в свое приложение, я получаю эту ошибку:

 Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.OkHttpClient$Builder"

Есть идеи?

1 Ответ

0 голосов
/ 15 февраля 2019

Это мое решение, я не знаю, является ли оно лучшим, но сейчас работает:

android {
    ...

    configurations {
        retrofit
    }
}

dependencies {
    api fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.12.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    retrofit 'com.squareup.retrofit2:retrofit:2.5.0'
    retrofit 'com.squareup.retrofit2:converter-gson:2.5.0'
    retrofit 'com.squareup.okhttp3:logging-interceptor:3.12.0'

}
task copyLibs(type: Copy) {
    from configurations.retrofit
    into "libs"
}
build.dependsOn copyLibs
...