Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of unified management version number reference configuration in Android Studio

Shulou Source: shulou.com Published: 2022-05-31 22:50:36 10月03日 Update

This article mainly introduces the relevant knowledge of "how to solve the problem of unified management version number reference configuration in Android Studio". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope that this article "how to solve the problem of unified management version number reference configuration in Android Studio" can help you solve the problem.

Method 1:

Write in gradle.properties:

# Test environment ENV_TEST=test# development environment ENV_DEV=dev# production environment ENV_ONLINE=onlineAPPLICATION_ID=com.xxx.xxxxCOMPILE_SDK_VERSION=26TARGET_SDK_VERSION=26MIN_SDK_VERSION=15SUPPORT_V4_SUPPORT=com.android.support:support-v4:26.1.0SUPPORT_ANNOTATIONS=com.android.support:support-annotations:26.1.0SUPPORT_V7_APPCOMPAT=com.android.support:appcompat-v7:26.1.0SUPPORT_V7_RECYCLERVIEW=com.android.support:recyclerview-v7:26.1.0

Use rules, use strings directly, and add as int after plastic surgery.

Android {compileSdkVersion COMPILE_SDK_VERSION as int defaultConfig {applicationId APPLICATION_ID minSdkVersion MIN_SDK_VERSION as int targetSdkVersion TARGET_SDK_VERSION as int versionCode 100 versionName "1.0.0" multiDexEnabled true flavorDimensions "versionCode" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}

Method 2:

Add buildscript {.... under the build.gradle file in the root directory. The contents of}:

Buildscript {ext.kotlin_version = '1.1.51' ext.rxandroid =' 2.0.1' ext.anko_version = '0.8.2' ext.support_version =' 26.1.0' ext.target_sdk_version = 26 ext.min_sdk_version = 15 ext.applicationId = 'com.beiyijinfu.rxbusdemo' repositories {google () jcenter ()} dependencies {classpath' com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin -gradle-plugin:$kotlin_version "classpath" org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version "/ / NOTE: Do not place your application dependencies here They belong / / in the individual module build.gradle files}}

To use the rules, the string needs to be "$", and the plastic surgery is directly used.

Android {compileSdkVersion compile_sdk_version defaultConfig {applicationId "com.xxx.xxxx" minSdkVersion min_sdk_version targetSdkVersion target_sdk_version versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}} dependencies {implementation fileTree (dir: 'libs' Include: ['* .jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation "com.android.support:appcompat-v7:$support_version" implementation "io.reactivex.rxjava2:rxandroid:$rxandroid" implementation "org.jetbrains.anko:anko-common:$anko_version" implementation "com.android.support:recyclerview-v7:$support_version"}

Method 3:

Add ext {.... under the build.gradle file in the root directory. The contents of}:

Ext {kotlin_version = '1.1.51' rxandroid =' 2.0.1' anko_version = '0.8.2' support_version =' 26.1.0' target_sdk_version = 26 compile_sdk_version = 26 min_sdk_version = 15}

To use the rules, the string needs to use "$rootProject." and the shaping directly uses rootProject. Ext can be added or not.

Android {compileSdkVersion rootProject.compile_sdk_version defaultConfig {applicationId "com.xxx.xxxx" minSdkVersion rootProject.ext.min_sdk_version targetSdkVersion rootProject.ext.target_sdk_version versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}} dependencies {implementation fileTree (dir: 'libs' Include: ['* .jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlin_version" implementation "com.android.support:appcompat-v7:$rootProject.support_version" implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxandroid" compile "org.jetbrains.anko:anko-common:$rootProject.anko_version" compile "com.android.support:recyclerview-v7:$rootProject.support_version"}

Method 4:

Create a .gradle file under the root directory of the project. For example, you can define the contents of the file in config.gradle,config.gradle, as shown in the following example:

Ext {kotlin_version = '1.1.51' rxandroid =' 2.0.1' anko_version = '0.8.2' support_version =' 26.1.0' target_sdk_version = 26 compile_sdk_version = 26 min_sdk_version = 15}

Using rules, refer to them in build.gradle first:

Apply from: "config.gradle" dependencies {compile fileTree (include: ['* .jar'], dir: 'libs') compile "com.android.support on" how to solve the problem of unified management version number reference configuration in Android Studio ", thank you for your reading. if you want to learn more about the industry, you can follow the industry information channel, and the editor will update different knowledge points for you every day.

Tags: Problems content files methods rules versions management unification configuration characters strings root directory environment knowledge industry different practical practical practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology Shulou Tech Info Huawei macOS