gpt4 book ai didi

android - targetSdkVersion gradle 奇怪的值

转载 作者:行者123 更新时间:2023-11-29 16:37:22 26 4
gpt4 key购买 nike

因此,我从 Github 克隆了这个项目,并在浏览其 build.gradle 时,发现了这个奇怪的配置,尤其是 targetSdkVersion。现在,在我详细介绍它是什么之前,让我提一下该项目有两个模块 - app(主要模块)和 callrecord(封装通话记录功能)

这是相同的 build.gradle 文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion project.sdk

defaultConfig {
applicationId "com.aykuttasil.callrecorder"
minSdkVersion project.minSdk
targetSdkVersion project.sdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "com.android.support:appcompat-v7:$supportVersion"
testCompile 'junit:junit:4.12'
compile project(':callrecord')
}

你能看到吗?

我不明白 compileSdkVersion project.sdk 这行。这个项目“对象”也在其他几个地方被引用。

首先,为什么有人会使用这个属性?第二,我如何知道它是什么版本?

最佳答案

why would someone use this property?

  • 使用此属性的主要目的是在一个地方为 Android 项目模块配置所有变量
  • 所以在一个地方改变它会影响整个项目

how do I find out what version it is?

  • 它将在 gradle.propertiesbuild.gradle 文件中可用

看看 Build.Gradle file of CallRecorder那个项目的

enter image description here

样本

这是关于它的好文章 Configure variables for all Android project modules in one place

gradle.properties

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX = true
android.enableJetifier = false

#gradle.properties
myTargetSdkVersion=27
myCompileSdkVersion=27
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

enter image description here

than use in your Build.Gradle

android {
compileSdkVersion project.myTargetSdkVersion.toInteger()
defaultConfig {
applicationId "com.example.nilesh.myapplication"
minSdkVersion project.myMinSdkVersion.toInteger()
targetSdkVersion project.myTargetSdkVersion.toInteger()
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}

关于android - targetSdkVersion gradle 奇怪的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52108359/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com