[英]dependencies issue when adding library AAR
I've created an Android library that I want to be able to use in other Android applications. 我创建了一个我想可以在其他Android应用程序中使用的Android库。 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. 为了测试与其他应用程序的集成,我创建了一个新应用程序,并按照本指南通过从库的AAR文件创建新模块将库导入该新应用程序。
build.gradle file: build.gradle文件:
dependencies {
...
compile project(':my-sdk')
...
}
settings.gradle file: settings.gradle文件:
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 编译成功,我可以在测试应用程序内使用该库的API,但是运行该程序时会遇到运行时异常
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/MediaType;
java.lang.NoClassDefFoundError:无法解决以下问题: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. 我认为这是一个依赖项问题,因为该库使用
okhttp
作为依赖项,它可能未打包在AAR文件中。 I just couldn't find anywhere how to compile this dependency so it would work in other projects. 我只是在任何地方都找不到如何编译此依赖项,以便它可以在其他项目中工作。
我修复了添加jar文件而不是在模块中使用maven的问题,然后组装release aar,并在应用程序项目中禁用了“即时运行”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.