Different resurse for builds


(Gron Bubsky) #1

How can I configure gradle.build to build two different android apk. First one to debug or test with first type of resurse folder (for example, with strings.xml) and second one with other strings.xml for release (for example, with real urls)?


(Luke Daley) #2

This is solved by build flavors.

This is one of many blog posts on the Internet about this: http://tulipemoutarde.be/2013/10/06/gradle-build-variants-for-your-android-project.html


(Gron Bubsky) #3

thanks, that is what i need, i red about it, but i dont understand how it use in past, but how can I build

definite flavors only?


(Luke Daley) #4

Set up some flavors, then run ‘gradle tasks’ you’ll see ‘assemble’ tasks (and others) for each flavor.


(Gron Bubsky) #5

thanx


(Gron Bubsky) #6

oh, one more tiny question, I have two builds, but when I tried to change AndroidManifest.xml for staging version I got an error that gradle can’t merge this file, does it mean that I can’t change AndroidManifest.xml?


(Luke Daley) #7

Some things can be merged and some can’t. I suggest running the build with the ‘-s’ flag to get more information about what is going wrong.


(Gron Bubsky) #8

i have 2 project type: src/main and src/staging; and i have different code in MainActivity.java, when I am trying to build it I got

:generateStagingDebugSources UP-TO-DATE
:compileStagingDebug
/android_projects/GradleApplication/src/staging/java/com/gradleapplication/sample/MainActivity.java:9: error: duplicate class: com.gradleapplication.sample.MainActivity
public class MainActivity extends Activity {
       ^
/android_projects/GradleApplication/src/staging/java/com/gradleapplication/sample/SecondActivity.java:7: error: duplicate class: com.gradleapplication.sample.SecondActivity
public class SecondActivity extends Activity {
       ^
2 errors
:compileStagingDebug FAILED
  FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':compileStagingDebug'.
> Compilation failed; see the compiler error output for details.
  * Try:
Run with --info or --debug option to get more log output.
  * Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileStagingDebug'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)

(Luke Daley) #9

The plugin cannot merge classes. I suspect you have the same class duplicated in different flavor and build type source directories.