未找到Android studio aar文件错误类
当我尝试在其他项目中使用导出的android库项目(aar格式)时。我得到以下错误未找到Android studio aar文件错误类,android,android-studio,aar,Android,Android Studio,Aar,当我尝试在其他项目中使用导出的android库项目(aar格式)时。我得到以下错误 > "Could not find class 'com.manish.core.helper.RegistrationHelper$1'" > "Could not find class 'com.manish.core.helper.RegistrationHelper$2'" > "Could not find class 'com.manish.core.helper.Registra
> "Could not find class 'com.manish.core.helper.RegistrationHelper$1'"
> "Could not find class 'com.manish.core.helper.RegistrationHelper$2'"
> "Could not find class 'com.manish.core.helper.RegistrationHelper$3'"
> "Could not find class 'com.manish.core.helper.RegistrationHelper$4'"
在aar文件中有一个文件“classes.jar”,它包含所有的类文件,但我不理解错误的原因
我正在使用android studio在构建目录中生成的aar文件。
我还在gradle文件中添加了apply插件:“com.android.library”
所有这些错误只适用于匿名和静态类
我的gradle文件:
apply plugin: 'com.manish.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.manish.test"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'junit:junit:4.12'
compile(name:'somerandomlibrary-debug', ext:'aar')
}
repositories{
flatDir{
dirs 'libs'
}
}
要使用aar文件,必须在
build.gradle
中使用以下内容:
repositories{
flatDir{
dirs 'libs'
}
}
通过这种方式,您可以在libs文件夹中使用aar文件
然后,您必须使用以下方法添加依赖项:
dependencies {
compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar')
}
问题是,aar文件不包含嵌套的依赖项,也没有描述库使用的依赖项的POM文件 如果要使用flatDir repo导入aar文件,则还必须在项目中指定依赖项。您应该使用maven存储库!例如: 一个更简单的解决方案是,将其添加到“aar”-项目中build.gradle的以下行中:
您可以在基于aar的应用程序中使用生成的POM文件进行依赖项注入。这不是一个好做法,但如果您确实需要它,您可以使用
嵌套依赖项,如下所示
depenencies {
...
compile (name:'somerandomlibrary-debug', ext:'aar') {
dependencies {
compile 'com.some:dependency:9.1.1'
...
}
}
}
谢谢安吉拉抽出时间,我已经把上面的内容写在我的简历里了。我无法访问匿名类和内部类。我可以访问其他类您只能访问公共类。
depenencies {
...
compile (name:'somerandomlibrary-debug', ext:'aar') {
dependencies {
compile 'com.some:dependency:9.1.1'
...
}
}
}