Tuesday, 14 July 2015

Android have duplicate classes in different variants




This is the suggested structure:

http://stackoverflow.com/questions/16737006/using-build-flavors-structuring-source-folders-and-build-gradle-correctly





However you will copy B.java to all folders(build variants)

So, below structure is the idea one:



Main folder has a basic B.java and is any folder (build variant) want to change it, they can have a different copy!

However, with above structure, when you compile "stag" you will get "duplicate class" error. Which  means you have to use the suggested structure which showed at the beginning.

 However, androidTest folder for (instrument testing) is totally different,  you can have duplicate class in it and it will override the default one (from main folder).

But that only supports Non Activities related classes.

So my suggestions are:




if B.java is a activity, and you use (1) with (3) you will get this error:

junit.framework.AssertionFailedError: Exception in constructor





https://developer.android.com/tools/building/configuring-gradle.html
https://developer.android.com/sdk/installing/studio-build.html
http://www.techotopia.com/index.php/An_Android_Studio_Gradle_Build_Variants_Example
http://tools.android.com/tech-docs/new-build-system/build-system-concepts







No comments:

Post a comment