[英]Android Build: Classes of a JAR file inside a AAR package are not recognized
I have a library project that I want to share as AAR file. 我有一个要共享为AAR文件的图书馆项目。
This library project contains several JAR files, some of them are classes I made and are used in the library project. 该库项目包含几个JAR文件,其中一些是我制作的类,并且已在库项目中使用。 For example I have a class in the lib project that inherits from a class inside the JAR file.
例如,我在lib项目中有一个类,它从JAR文件中的类继承。
I was able to create the AAR file, and now I'm testing the AAR file in a sample app made in Android Studio. 我能够创建AAR文件,现在我正在Android Studio中制作的示例应用程序中测试AAR文件。
I added the AAR file modifying the build.gradle file of the app module like this: 我添加了修改应用程序模块的build.gradle文件的AAR文件,如下所示:
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name: 'mightylibrary', ext:'aar')
compile 'com.android.support:appcompat-v7:20.+'
}
Then when I try to use methods from the parent class I'm not able to see them, only the methods implemented in the child class. 然后,当我尝试使用父类中的方法时,我看不到它们,只能看到在子类中实现的方法。
Is there any known limitation of accessing classes inside JARs packaged within a AAR file? 访问AAR文件中打包的JAR中的类是否存在已知限制?
Any solution? 有什么办法吗?
Thanks 谢谢
So it seems I missed to add this 所以看来我错过了添加
repositories {
jcenter()
mavenLocal() // Missed this
}
In the project (not the module) build.gradle file so it searchees in the local cache repo. 在项目(而非模块)的build.gradle文件中,它在本地缓存存储库中进行搜索。 What seems funny is then why it detected the classes within "classes.jar" but not in the other jars within "libs" folder of my AAR file.
有趣的是,为什么它在AAR文件的“ libs”文件夹中的“ classes.jar”中而不是其他jar中检测到类。 Interesting...
有趣...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.