Android Studio

Gradle > buildTypes 설정

오마로 2024. 2. 13. 16:27
반응형

Android Studio에서 BuidlType별로 앱을 install 하고 싶을 때 설정입니다.

1.Android Studio > Gradle에 전체 tasks를 나오게 하려면 아래와 같이 설정을 하면 나옵니다. 

https://stackoverflow.com/questions/67405791/gradle-tasks-are-not-showing-in-the-gradle-tool-window-in-android-studio-4-2

 

Gradle tasks are not showing in the gradle tool window in Android Studio 4.2

I just updated Android Studio to version 4.2. I was surprised to not see the Gradle tasks in my project. In the previous version, 4.1.3, I could see the tasks as shown here: But now I only see the

stackoverflow.com

2.Tasks > install에 원하는 task를 나오게 하기 
 1)DebugDev 라는 install 추가는 아래와 같이 추가

signingConfigs{
        releaseWithSignedKey {
            storeFile file("SampleKeyStore.jks")
            storePassword "password1"
            keyAlias "sample"
            keyPassword "password2"
        }
    }

    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField "boolean","IS_DEBUG","true"
            buildConfigField "boolean","IS_FREE","true"
            debuggable true
            signingConfig signingConfigs.debug
        }

        debugDev {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField "boolean","IS_DEBUG","true"
            buildConfigField "boolean","IS_FREE","true"
            debuggable true
            signingConfig signingConfigs.debug
        }

        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

            buildConfigField "boolean","IS_DEBUG","false"
            buildConfigField "boolean","IS_FREE","true"
            debuggable false
            signingConfig signingConfigs.releaseWithSignedKey
        }

        releaseProduct {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField "boolean","IS_DEBUG","false"
            buildConfigField "boolean","IS_FREE","false"    //admob
            debuggable false
            signingConfig signingConfigs.releaseWithSignedKey
        }
    }

그럼, 원하는 DebugDev task가 생깁니다. 

3)release task 추가 

signingConfigs{
    releaseWithSignedKey {
        storeFile file("SampleKeyStore.jks")
        storePassword "password1"
        keyAlias "sample"
        keyPassword "password2"
    }
}

 signingConfigs 추가 후 release에 해당 releaseWithSignedKey를 추가하면 됩니다.

release {
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

    buildConfigField "boolean","IS_DEBUG","false"
    buildConfigField "boolean","IS_FREE","true"
    debuggable false
    signingConfig signingConfigs.releaseWithSignedKey
}

감사합니다.

반응형

'Android Studio' 카테고리의 다른 글

GitHub First Commit 하기  (0) 2023.07.20
Firebase 연동  (0) 2017.03.20
난독화 처리 및 매핑 파일  (0) 2017.03.11