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

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

为了混淆后还能看到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

求大牛解答,先谢谢

【热门文章】
【热门文章】