简体   繁体   中英

dependencies issue when adding library AAR

I've created an Android library that I want to be able to use in other Android applications. I've created a small test app in the same project as the library and everything works.

To test integration with other apps, I created a new application, and followed this guide to import my library to that new application by creating a new module from the library's AAR file.

build.gradle file:

dependencies {
    ...
    compile project(':my-sdk')
    ...
}

settings.gradle file:

include ':app', ':my-sdk'

Compilation succeeded and I can use the library's API inside the test app, but when running it I get a runtime exception

java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/MediaType;

I assume it's a dependencies issue, since the library uses okhttp as a dependency, which is probably not being packed in the AAR file. I just couldn't find anywhere how to compile this dependency so it would work in other projects.

我修复了添加jar文件而不是在模块中使用maven的问题,然后组装release aar,并在应用程序项目中禁用了“即时运行”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM