Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了没有找到Android studio aar文件错误类大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

当我尝试在其他项目中使用导出的@L_618_0@库项目(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.RegistrationHelper$3'"
> "Could not find class 'com.manish.core.Helper.RegistrationHelper$4'"

在aar文件中有一个文件“classes.jar”,它包含所有类文件,但我不明白错误的原因.

我正在使用android studio在build目录中生成的aar文件.
我还在gradle文件添加了apply plugin:’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文件不包含嵌套依赖项,并且没有描述库使用的依赖项的POM文件.

如果要使用flatDir repo导入aar文件,则还必须在项目中指定依赖项.你应该使用maven存储库!例如:maven-publish

一个更简单的解决方案是,将以下行添加到“aar”项目中的build.gradle:

task createPom {
    apply plugin: 'maven'
    description "Generates pom.xml"
    pom {
        project {
            groupId 'com.example'
            artifactId 'example'
            version '0.0.1-SNAPSHOT'
            packaging 'aar'
        }
    }.withXml {
        def dependenciesnode = asnode().appendNode('dependencies')

        configurations.compile.allDependencies.each { dependency ->
            def dependencyNode = dependenciesnode.appendNode('dependency')
            dependencyNode.appendNode('groupId',dependency.group)
            dependencyNode.appendNode('artifactId',dependency.Name)
            dependencyNode.appendNode('version',dependency.version)
        }
    }.writeTo("$buildDir/pom.xml")
}

您可以在基于aar的应用程序中使用生成的POM文件进行依赖项注入.

大佬总结

以上是大佬教程为你收集整理的没有找到Android studio aar文件错误类全部内容,希望文章能够帮你解决没有找到Android studio aar文件错误类所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。