Migrating from IDEA to Android Studio with Gradle

I migrated my project from IDEA to Android Studio to use Gradle. I have successfully created the application (I have not yet reviewed the tests), and now I want to include the tastes of the products in it (my reason for moving).

Now I can choose one of four build options in the "Build Options" menu, and creating with the new settings displays a new application on my phone, so that everything looks fine.

However, where can I make changes to the sources (with the original directory structure) or do I need to change it? What is the best way? (I don't have the structure / src / xxx / res, just src / org / bla / bla)

Major changes relate to resources such as string files and graphics. Thank!

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.android.gms:play-services:4.1.+'
    compile 'org.apache.commons:commons-lang3:3.2.+'
    compile 'org.apache.httpcomponents:httpmime:4.1.+'
    compile 'com.android.support:appcompat-v7:+'
}

android {

    compileSdkVersion 19
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        //versionName "0.5"
    }

    productFlavors {
        iDomsPortalDev {
            packageName 'org.idoms.iDomsAndroid.iDomsPortalDev'
        }
        iDomsPortal {
            packageName 'org.idoms.iDomsAndroid.iDomsPortal'
        }
    }

    buildTypes {
        debug {
            packageNameSuffix ".debug"
            //versionNameSuffix "-debug"
        }
        release {
            packageNameSuffix ".release"
            //versionNameSuffix "-release"
        }
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.

        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
        iDomsPortal.setRoot('product-flavors/iDomsPortal')
        iDomsPortalDev.setRoot('product-flavors/iDomsPortalDev')

}
println "main: " + android.sourceSets.main.res.srcDirs

    android.applicationVariants.all { variant ->
        println variant.name + ": " + android.sourceSets[variant.name].res.srcDirs
    }

    android.productFlavors.all { flavor ->
        println flavor.name + ": " + android.sourceSets[flavor.name].res.srcDirs
    }

    android.buildTypes.all { buildType ->
        println buildType.name + ": " + android.sourceSets[buildType.name].res.srcDirs
    }

[EDIT: !]

+3
1

, , , ; , , sourceSets.main.

script build.gradle (, android), , :

println "main: " + android.sourceSets.main.res.srcDirs

android.applicationVariants.all { variant ->
    println variant.name + ": " + android.sourceSets[variant.name].res.srcDirs
}

android.productFlavors.all { flavor ->
    println flavor.name + ": " + android.sourceSets[flavor.name].res.srcDirs
}

android.buildTypes.all { buildType ->
    println buildType.name + ": " + android.sourceSets[buildType.name].res.srcDirs
}

, , ( " + " ).

, :

main: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/res]
app1: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/src/app1/res]
app2: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/src/app2/res]
debug: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/build-types/debug/res]
release: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/build-types/release/res]
app1Debug: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/src/app1Debug/res]
app1Release: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/src/app1Release/res]
app2Debug: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/src/app2Debug/res]
app2Release: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/src/app2Release/res]

main - , sourceSets.main. debug release build-types sourceSets. app1 app2 src/app1 src/app2, , , . , . :

// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
app1.setRoot('product-flavors/app1')
app2.setRoot('product-flavors/app2')

, app1Debug ., , , , - , . , , , :

main: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/res]
app1: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/product-flavors/app1/res]
app2: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/product-flavors/app2/res]
debug: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/build-types/debug/res]
release: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/build-types/release/res]
app1Debug: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/src/app1Debug/res]
app1Release: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/src/app1Release/res]
app2Debug: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/src/app2Debug/res]
app2Release: [/Users/sbarta/AndroidStudioProjects/AS_Eclipse/app/src/app2Release/res]
+1

All Articles