随着Android的工作室3.X.X,增加本地.AAR文件摇篮构建不工作[复制]

问题描述 投票:0回答:1

这个问题已经在这里有一个答案:

随着Android的工作室3.X.X,增加本地.AAR文件的Android项目不工作(建设是成功的,但得到的运行时异常)

我尝试下面的方法(摘自参考来源:https://stackoverflow.com/a/23326397/5685911https://stackoverflow.com/a/24894387/5685911等),但没有为我工作:

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模块插入到应用级gradle这个导入的所有库。这似乎从AAR文件导入使用任何上述方法都不会传播。但是,我认为这是不正确的解决方案。任何帮助这里非常感谢理解:)

android gradle android-gradle build.gradle aar
1个回答
1
投票
  1. 打开Android项目要在SDK添加到
  2. 点击文件 - >新建模块 - >导入JAR / ARR包
  3. File name: C://release.aar Subproject name:my_subproject_name
  4. 单击Finish
  5. 添加新的SDK模块作为应用模块的依赖:

应用程序/文件的build.gradle:

 dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation project(':my_subproject_name')
}

在外部库中项目标签结果你会看到你的lib enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.