Monday 15 July 2013

android - Gradle productflavors sourcesets and old project structure -


Today, I started changing our project to use the gradle build system. I can not change the project structure, and I have different tastes, so I was wondering how can I override sources for "Dev" and "Products", because it does not apparently work :

  buildscript {repositories {mavenCentral ()} dependency {classpath 'com.android.tools.build:gradlecs.4.2'}} Apply the plugin: 'Android' Android {compileSdkVersion 17 buildToolsVersion " 17 "Dependency (Compilation Project '(': 'APS) Compile Project (': google-play-services_lib ') Collection Projections (': Mergeadator') file tree (DIR: 'Libs' includes: '* .jar')} Signing Config {Release {storeFile file ("Myapp.keystore") Store password "******* *** "Key aliases" ********** "KeyPassword" ********** "}} SourceSets {Main {Manifest.srcDile = ['src'] Resources. SrcDirs = ['src'] aild.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['Res'] assets.srcDirs = ['assets']} dev {java.srcDirs = ['Src-dev']} prod {java.srcDirs = ['src-prod']} instrumentTest.set root ('test')} productFlavors {dev {packageName "com.myapp.dev"} prod {packageName "com .myapp {}} buildTypes {release {signingConfig signingConfigs.release}}}   

This gives me the following error:

  An AndroidSource Suite named 'Dev 'Can not be added as an AndroidSourceset, with that name already present.   

The thing is, I can not use the new project structure and I'm left with this one, so how do I override the source directory, so that in Dev version, Src-prod (src / main / java and src / dev / java or instead of src / prod / java) for src and prod versions

Thx!

Edit: Src-prod and src-dev directories contain only those static classes that are used to indicate different environments. I will do the same with the property (different icon for dev env)

Announce your taste before you Need to customize and then customize the sources.

What happens when you customize SourceSets, it is Android. SourceSets.dev is created, but then when Android. Productflowers. If you make Dove, then this is an Android resourceset. And fails (because it already exists).

We do not really know that the source Sets already created means the same thing, so we are likely to fail to use SourceSet for that taste when you mean it Can be used for something else.

No comments:

Post a Comment