Android/gradle how to exclude subproject from final apk


I have got multiproject contains independent android apps. In one of them I’m using another one as library and problem is when I’m creating new apk I want exclude this ‘lib’ from final apk unfortunate gradle always include it into apk and it’s throws problems during installation. Anyway my question is if (and how) is possible add dependency just for development and compilation phase not for build apk. Change compile to provided doesn’t solve that problem and gradle add it to apk.