Local AAR file doesn't manage dependencies

蓝咒 提交于 2021-02-07 07:01:07

问题


I have worked on an Android library (an API client) that uses Retrofit and Joda DateTime.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'joda-time:joda-time:2.8.1'
}

Now that the library is completed I compiled it into an AAR file and I want to use it in an application, so I added it to the libs folder of the application and included it in the build.gradle file like so :

dependencies {
    compile(name:'s3papiandroidclient', ext:'aar')
    //Some other things
}

However, when I try to initialize the API client from the library, the application crashes when it comes to calling objects from RetroFit or DateTime (For instance, retrofit.RestAdapter). It looks like Gradle does not read the dependencies from the AAR library, thus doesn't install Retrofit and DateTime in my application. I tried to use the transitive=true parameter on my AAR file, does not help.

Other point that might help, I tried to generate a POM file, and the dependencies don't appear in it either. It looks like there's really something going on with these and I am completely stuck on that.

The only workaround I could find is to add manually the dependencies from the AAR file to the app's build.gradle file but it doesn't make sense, I assume Gradle can import dependencies on its own !

Regards,

Gyoo.


回答1:


It looks like Gradle does not read the dependencies from the AAR library

That is because there are no dependencies in an AAR file.

I tried to generate a POM file, and the dependencies don't appear in it either

Then there is a problem in how you are generating the POM file. Plus, AFAIK, you would need to put the AAR and its POM file in a repository, in order for Gradle to recognize the POM and use the dependency information inside of it.



来源:https://stackoverflow.com/questions/31745072/local-aar-file-doesnt-manage-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!