Новый buildType в build.gradle проекта Android

Я пытаюсь добавить новый buildType "обфусцированный", который направлен на активацию proguard для моего apk.

apply plugin: 'com.android.application'

configurations {
obfuscatedCompile
}

dependencies {
compile fileTree(include: '*.jar', dir: 'libs')

debugCompile project(path: ':module1', configuration: 'debug')
debugCompile project(path: ':module2', configuration: 'debug')
debugCompile project(path: ':module3', configuration: 'debug')

releaseCompile project(path: ':module1', configuration: 'release')
releaseCompile project(path: ':module2', configuration: 'release')
releaseCompile project(path: ':module3', configuration: 'release')

obfuscatedCompile project(path: ':module1', configuration: 'release')
obfuscatedCompile project(path: ':module2', configuration: 'release')
obfuscatedCompile project(path: ':module3', configuration: 'release')

compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.squareup.assertj:assertj-android:1.1.1'
androidTestCompile 'org.easymock:easymock:3.4'
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.android.support:support-annotations:24.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
}

android {
compileSdkVersion 23
buildToolsVersion '25'

dexOptions {
    javaMaxHeapSize "4g"
}

String appName = ""

defaultConfig {
    applicationId "com.example.MyApp"
    minSdkVersion 19
    targetSdkVersion 21

    multiDexEnabled true

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

signingConfigs {
    release {
        storeFile file("../../my.keystore")
        storePassword "xxxxx"
        keyAlias "a.b.c.d"
        keyPassword "xxxxx"
    }
}

buildTypes {

    release {
        minifyEnabled false
        signingConfig signingConfigs.release
        debuggable true
    }
    obfuscated {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
    }

    debug {
    }
}

productFlavors {
    flavor1 {
    }
    flavor2 {
        applicationIdSuffix ".flavor2"
        versionCode 123
        versionName "01.02.03"
        resValue "string", "app_name", "App flavor2"
    }
}

sourceSets {
    main {
        resources.srcDirs = ['src/main/java']
        java.srcDirs = ['src/main/java']
    }

    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
}

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
    exclude 'NOTICE'
    exclude 'LICENSE.txt'
    exclude 'LICENSE'
    exclude 'asm-license.txt'
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
}

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-annotations:23.0.1'
    }
}

lintOptions {
    abortOnError false
}

apply from: "task.gradle"
}

Моя проблема: как я могу указать build.gradle, что "запутанный" тип сборки должен получать код из тех же папок "release"? Пример: если я выберу варианты сборки flav1Obfuscated или flavour1Release, папка для рассмотрения должна быть такой же: flav1Release, затем flav1, затем main.

В текущей конфигурации у меня ошибка "Активность по умолчанию не найдена".

0 ответов

Другие вопросы по тегам