gpt4 book ai didi

android - android中的不同口味

转载 作者:行者123 更新时间:2023-12-03 05:15:06 25 4
gpt4 key购买 nike

我想在我的项目中创建这样的东西,但我是 gradle 新手,所以我不知道它可以做的很多事情。

enter image description here

这是资源管理器中的项目结构
enter image description here

来自应用模块的 gradle.build

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
}
}

// Manifest version information!
def versionMajor = 1
def versionMinor = 0
def versionPatch = 0
def versionBuild = 0 // bump for dogfood builds, public betas, etc.

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def date = new Date()
def buildTime = date.format("dd.MM.yy", TimeZone.getTimeZone("UTC"))
def buildTimeInternal = date.format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))

android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion

versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"

buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
buildConfigField "String", "BUILD_TIME", "\"${buildTimeInternal}\""

testApplicationId "ru.ltst.u2020mvp.tests"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

signingConfigs {
debug {
storeFile file("../distribution/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release {
storeFile file("../distribution/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}

buildTypes {
debug {
applicationIdSuffix '.dev'
versionNameSuffix '-dev'
debuggable true
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-project.txt')
signingConfig signingConfigs.release
}
}

productFlavors {
internal {
applicationId 'ru.ltst.u2020mvp.internal'
}
production {
applicationId 'ru.ltst.u2020mvp'
}
}


lintOptions {
textReport true
textOutput 'stdout'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

packagingOptions {
exclude 'LICENSE.txt'
}
}

// TODO remove eventually: http://b.android.com/162285
configurations {
internalDebugCompile
}

dependencies {
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:support-annotations:23.0.1'
compile "com.android.support:appcompat-v7:23.0.1"
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'

compile 'com.google.dagger:dagger:2.0.1'
apt 'com.google.dagger:dagger-compiler:2.0'
provided 'org.glassfish:javax.annotation:10.0-b28'

compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
internalDebugCompile 'com.squareup.retrofit:retrofit-mock:1.9.0'

compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.jakewharton.timber:timber:2.7.1'
internalDebugCompile 'com.jakewharton.madge:madge:1.1.1'
internalDebugCompile 'com.jakewharton.scalpel:scalpel:1.1.1'

compile 'io.reactivex:rxjava:1.0.8'
compile 'io.reactivex:rxandroid:0.24.0'

internalCompile 'com.mattprecious.telescope:telescope:1.4.0@aar'

// Espresso 2 Dependencies
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.0') {
exclude module: 'support-annotations'
}
}

// change apk name
android.applicationVariants.all { variant ->
for (output in variant.outputs) {
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "u2020-mvp-${output.name}-${buildTime}.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}

// print build finish time
gradle.buildFinished { buildResult ->
def buildFinishDate = new Date()
def formattedDate = buildFinishDate.format('yyyy-MM-dd HH:mm:ss')
println "Build finished: ${formattedDate}"
}

有人可以向我解释它是如何工作的吗?

当我更改构建变体时,Java 内容会更改。 (例如,对于 internalDebug 变体,它是 main、internal、internalDebug,然后对于 internalRelease 构建变体,它变成了 main、internal、internalRelease)。

我问的原因是我在 gradle 文件中看不到任何“internalRelease”字样,所以我不明白构建变体是如何创建的逻辑以及它如何定义为不同构建变体显示哪些模块

最佳答案

调试无签名测试,发布有签名发布;点击左上角机器人,将android转为project,你就明白了;

关于android - android中的不同口味,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33348334/

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