【问题标题】:Not able to access source code of AAR file build in Kotlin在 Kotlin 中无法访问 AAR 文件构建的源代码
【发布时间】:2019-01-31 13:51:58
【问题描述】:

我在 Kotlin 中构建了一个模块,然后导入到我的项目中。我将minifyEnabled false 放入模块的build.gradle 文件中。但是看不到源代码或者下不了断点。

它适用于 Java,但不适用于 Kotlin。

【问题讨论】:

  • 您找到解决方案了吗?
  • 有什么解决办法吗?

标签: android kotlin


【解决方案1】:

将您的aar 文件复制到src/main/libs 文件夹中。

打开 Project Level build.gradle 并添加 flatDir 及其正文内容,如下例所示:

allprojects {
    repositories {
        flatDir {
            dirs ‘src/main/libs’
        }
        jcenter()
        google()
    }
}

在此之后打开Application Level build.gradle 并将aar 文件添加到依赖项中:

dependencies {
    compile(name:'myFile', ext:'aar')
}

然后在 Android Studio 3.2 中,在 Windows 上按 Ctrl-Shift-A 或按 Cmd-Shift-A 如果您使用的是 Mac,请在键盘上输入 sync 并选择 Sync Project with Gradle Files 命令。

minifyEnabled 标志为 ProGuard 保留,并且它默认关闭。因此,调试和发布版本都没有使用ProGuard,并且proguardFiles 参数被忽略。

另外,请阅读:Adding local .aar files to Gradle build using “flatDirs” is not working

还有这个帖子:How to Include an External .aar File Using Gradle?

还有这个帖子:Why are there two build.gradle files in an Android Studio project?

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2016-06-22
    • 2015-06-12
    • 2022-12-11
    • 2016-05-05
    • 1970-01-01
    • 2020-05-31
    • 2020-04-01
    • 2014-01-22
    • 2020-08-11
    相关资源
    最近更新 更多