ElyashivLavi ElyashivLavi - 3 years ago 347
Android Question

How to skip a specific gradle task

I want to skip one of the tasks of Android gradle build, so I tried something like

project.tasks.getByName("transformNativeLibsWithStripDebugSymbolForDebug").onlyIf {
println("Skipping")
return false
}


However, the task is not found, even though I can see it in the tasks that are executed...
Any idea how can I get this task? I guess it should be dependant of one of the tasks in the project.

Context - I have a shared library that I want to user the unstripped version of it, however gradle strips it anyway...

EDIT

After some digging, it seems that those tasks are added as part of the binary plugin (the
apply plugin: 'com.android.library'
line at the top of the gradle file).

This transform task is added using the transform API, which doesn't seems to have a way to unregister/modify existing transform...

Answer Source

It's dynamically generated task. Try to add next:

android {...}

afterEvaluate { project ->
    project.tasks.transformNativeLibsWithStripDebugSymbolForDebug {
       onlyIf  {
           println 'Skipping...'
           return false
       }
    }
}

dependencies {...}

In Gradle Console you should see:

Skipping...

:app:transformNativeLibsWithStripDebugSymbolForDebug SKIPPED

Do not forget that transformNativeLibsWithStripDebugSymbolForDebug task is only executed, when you use assembleDebug task (or Shift+F10 combination in Android Studio).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download