Gradle 지식

2132 단어
여러 버전 공존 문제
우선 응용 프로그램 Id Suffix를 사용하여 응용 프로그램 Id를 수정합니다. 이 수정을 완성하면 개발과 온라인 버전이 공존할 수 있습니다. 그러나 이것은 가장 초보적인 수정입니다. 변형 폴더에 맞추어 서로 다른 환경의 코드와 운행 자원을 만들고 개발과 온라인 버전을 구분하여 많은 목적을 달성할 수 있습니다.
buildTypes {
        release {
            minifyEnabled true
            proguardFiles 'proguard-rules.txt'
            shrinkResources true //    keep
            signingConfig signingConfigs.release
        }
        debug {
            minifyEnabled false
            proguardFiles 'proguard-rules.txt'
            shrinkResources false //    keep
            signingConfig signingConfigs.release
             
              //
            applicationIdSuffix ".debug"
        }

    }
  • 안드로이드 매니페스트에서 응용 프로그램 Id를 사용하는 곳, 특히 fileProvider는 자리 차지 문자${applicationId}로 대체하고 컴파일러는 자동으로 실제 값
  • 으로 대체한다.
  • builde.gradle에 응용 프로그램 Id가 정의되어 있지 않으면 안드로이드 매니페스트의packagename
  • 를 사용합니다
  • 설치 패키지의 이름 수정(AndroidStudio 3)
  • android.applicationVariants.all { variant ->
            variant.outputs.all {
                outputFileName = "app-${variant.baseName}-${variant.versionName}.apk"
            }
        }
    

    Gradle 사용자 정의 플러그인 컴파일 중 설정 오류 읽기
    문제가 발생했습니다. 주로Gradle 스크립트의 실행 과정에 관한 문제입니다. 근원은 설정을 읽을 때의 문제입니다.
    A Gradle build has three distinct phases.
    InitializationGradle
    supports single and multi-project builds. During the initialization phase, Gradle determines which projects are going to take part in the build, and creates a Project instance for each of these projects.
    Configuration
    During this phase the project objects are configured. The build scripts of all projects which are part of the build are executed.
    ExecutionGradle
    determines the subset of the tasks, created and configured during the configuration phase, to be executed. The subset is determined by the task name arguments passed to the gradle command and the current directory. Gradle then executes each of the selected tasks.
    설정 과정에서 관련 설정 정보를 얻는 값은 비어 있습니다. 정확한 획득 시기는 Configuration이 끝난 후 (project.after Evaluate) 실행해서 논리를 얻는 것입니다.

    좋은 웹페이지 즐겨찾기