简体   繁体   English

Android Build:无法识别AAR包中的JAR文件的类

[英]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.

相关问题 替换 jar 中的类,jar 位于 Axis2 aar 文件中 - Replacing classes inside a jar, which is inside an Axis2 aar file 如何从多个java类(单个包)正确创建/使用.aar或.jar文件,以便在android studio中的不同项目中使用它 - How to properly create/use .aar or .jar file from multple java classes ( single package) to use it in different projects in android studio 在 Android aar 中包含带有 Java 源代码的 jar 文件 - Include jar file with Java sources in Android aar 用多个类构建Jar文件 - Build Jar File with multiple classes 在默认包中的JAR文件中导入类 - Importing classes inside JAR files that are in the default package 如何将Android Gradle应用打包到* .jar或* .aar文件 - How to pack Android Gradle app to *.jar or *.aar file 在 Android Studio 中访问 aar 文件的类时出现 classNotFoundException - classNotFoundException while accessing the aar file's classes in Android Studio 在android中,在jar中创建一个jar并访问第一个jar的类 - In android create a jar inside jar and accessing the classes of first jar 使maven在构建jar中复制其他文件(不是资源,而是任何包中的任何文件)? - Making maven copy additional files inside the build jar (not resources but any file inside any package)? Ubuntu 14.04,无法将类打包到“ jar”文件中 - Ubuntu 14.04,unable to package classes into 'jar' file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM