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
}

------------------------------------------------------------------------------------------
C:\Users\사용자\.android 폴더에 debug.keystore 파일을 프로젝트에 추가

app에 debug.keystore 추가

    signingConfigs {
        debugKey {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
		/*        
		releaseKey {
            storeFile file(RELEASE_KEY_STORE)
            storePassword RELEASE_KEY_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_ALIAS_PASSWORD
        }*/
    }

signingConfigs를 debug 및 release에 추가를 한다.

기본 경로

  • Windows: C:\Users\<사용자 이름>\.android\debug.keystore
  • macOS/Linux: /Users/<사용자 이름>/.android/debug.keystore

사용자 정의 경로 설정

build.gradle 파일에서 debug.keystore의 경로를 변경할 수 있습니다. 예를 들어, 프로젝트의 특정 폴더에 keystore를 저장하고 싶다면 다음과 같이 설정할 수 있습니다.

android {
    signingConfigs {
        debug {
            storeFile file("path/to/your/custom/debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
    }
...
}

감사합니다.

반응형

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

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