1

I have 2 jar files that one of them is for release and the other one is for debug.

I dont want to play them to export a apk each time in Android Studio. How can i automate it? I am all open for examples snippets and more.

BTW I also need different assets files too.

Thanks

Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30

1 Answers1

3

You can achieve it in many ways.

You can use 2 different folders, one for each buildType (or flavor).

libA
   debug.jar
libB
   release.jar

Then:

dubugCompile fileTree(dir: 'libA', include: ['*.jar'])
releaseCompile fileTree(dir: 'libB', include: ['*.jar'])

Or you can use somenthing like:

debugCompile files('libs/first.jar')
releaseCompile files('libs/second.jar')

For the assets resources (or resources/java file), just use the buildType folder. This is the structure:

module
   src
     debug
       assets
       java
       res
     release
       assets
       java
       res
     main
       assets
       java
       res
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • Does compiler cut the unused jars? For example i build apk using release build type then is debug jar going to put into apk? Btw, i dont have proguard yet. – Emre Aktürk Oct 13 '15 at 07:39
  • Using different folders with dubugCompile and releaseCompile the jar is not included in the apk. – Gabriele Mariotti Oct 13 '15 at 09:18
  • @GabrieleMariotti what if we have a few custom build types, for example ```staging``` and ```beta```. Their custom configurations don't seem to be working, ```stagingCompile``` and ```betaCompile``` – Vishist Varugeese Mar 21 '22 at 14:25