在AndroidStudio 3.X.X中,将本地.AAR文件添加到Gradle构建中不起作用

在AndroidStudio 3.X.X中,将本地.AAR文件添加到Gradle构建中不起作用,android,gradle,android-gradle-plugin,build.gradle,aar,Android,Gradle,Android Gradle Plugin,Build.gradle,Aar,在Android Studio 3.X.X中,将本地.AAR文件添加到Android项目不起作用(构建成功,但获得运行时异常) 我尝试了以下方法(参考:,等等),但没有一种对我有效: 1. Import the local aar file: (I) File>New>New Module>Import the .AAR Package [On "Finish" click the .AAR gets included automatically into setting

在Android Studio 3.X.X中,将本地.AAR文件添加到Android项目不起作用(构建成功,但获得运行时异常)

我尝试了以下方法(参考:,等等),但没有一种对我有效:

1. Import the local aar file:
   (I) File>New>New Module>Import the .AAR Package [On "Finish" click the .AAR gets included automatically into settings.gradle file as below:
       include ':app', ':myAAR'
   (II) Add AAR module dependency in app level build.grdle file as below:
       implementation project(":myAAR")

2. Using flatDir method:
   (I) keep aar file in libs folder
   (II) Add flatDir{dirs 'libs'} into the project level build.gradle file as below:
        allprojects {
            repositories {
                jcenter()
                flatDir {
                    dirs 'libs'
                }
            }
        } 
    (III) Add AAR dependency in app level build.gradle file as below:
          dependencies {
              implementation(name:'myAAR', ext: 'aar')
          }
解决方法:需要将AAR模块导入的所有库包含到应用程序级渐变中。似乎没有使用上述任何方法传播从AAR文件导入的内容。 但是,我认为这不是正确的解决办法。在此,我们将非常感谢您的帮助:)

  • 打开要添加SDK的android项目
  • 单击文件->新建模块->导入jar/arr包
  • 文件名:
    C://release.aar

    子项目名称
    :我的子项目名称

  • 单击“完成”
  • 将新SDK模块添加为对应用程序模块的依赖项:
  • app/build.gradle文件:

     dependencies {
            implementation fileTree(include: ['*.jar'], dir: 'libs')
            implementation project(':my_subproject_name')
    }
    
    在外部库的“项目”选项卡的结果中,您将看到您的库