Android studio 用 gradle 编译 Android project 怎么样配置来保持行号

发布于 2022-08-31 09:22:52 字数 1889 浏览 7 评论 0

为了混淆后还能看到crash时报错的行号,需要配置javac参数来保持行号

以前用 ant 是这样

<javac
debug="true" debuglevel="source,lines,vars" get/classes"  
 </javac>

现在Android studio 改用 gradle , 我在网上查找了一些方法
1)方法1:地址:https://github.com/codeborne/selenide/blob/master/build.gradle

 allprojects {
repositories {
    jcenter()
}

compileJava.options.debugOptions.debugLevel = "source,lines,vars"
}

但编译报错:
Error:(16, 0) Could not find property 'compileJava' on root project

加上 apply plugin: 'java'

allprojects {
    repositories {
        jcenter()
    }
    apply plugin: 'java'
    compileJava.options.debugOptions.debugLevel = "source,lines,vars"
    }

报错:Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins.

2)方法2 地址:http://gradle.1045684.n5.nabble.com/Providing-custom-debugLevel-for-compile-task-td1433678.html

allprojects 
{ 
     usePlugin('java') 

     // define global compile options 
     compile.destinationDir = new File("$rootDir/tmp/build/classes") 
     compile.sourceCompatibility = 1.4 
     compile.targetCompatibility = 1.4 
     compile.options.bootClasspath = bootClasspath 
     compile.options.debug = true 
     compile.options.debugOptions.debugLevel = 'lines,source' 
     compile.options.deprecation = true 
} 

也是但编译报错:
Error:(16, 0) Could not find property 'compile' on root project

我的gradle 配置
classpath 'com.android.tools.build:gradle:1.0.0'
distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip

求大牛解答,先谢谢

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文