gpt4 book ai didi

适用于不同产品风格的 Android Google Maps API key

转载 作者:行者123 更新时间:2023-11-29 00:54:27 25 4
gpt4 key购买 nike

我正在尝试设置我的 Android 项目,以便我可以让它的 3 个不同版本并行工作,指向不同的后端 API 等等:

  • 我仅用于自己开发的调试/开发版本
  • 我在内部向客户发布的 beta/qa 版本,以便他们可以在不影响生产环境的情况下测试应用
  • 发布到 Play 商店供所有人使用的生产版本

正如我所说,这 3 个版本应该可以并行安装在同一台设备上(所以我猜他们应该有不同的应用程序 ID)、不同的图标、指向不同的后端 API 等等。

为此,我认为最好的选择是像这样使用产品口味:

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "env"
productFlavors {
dev {
dimension "env"
applicationId "com.myapp.dev"
resValue 'string', 'backend_url', 'https://dev.example.com'
}
beta {
dimension "env"
applicationId "com.myapp.beta"
resValue 'string', 'backend_url', 'https://beta.example.com'
}
prod {
dimension "env"
applicationId "com.myapp"
resValue 'string', 'backend_url', 'https://www.example.com'
}
}
}

并且我在src下创建了相应的devbetaprod目录,在那里有单独的资源,例如每种口味的启动器图标。

现在我想将 Google map 集成到我的应用程序中。所以我创建了一个 Google Maps Activity,Android 工作室提出了 2 个 google_maps_api.xml,他将它们放在 srcdebugrelease 子目录中。如果我没记错的话,那些配置文件应该是特定于 flavor 的而不是特定于 buildType 的,所以我将一个从 debug 移到了 dev,我将一个从 release 移到了 beta 并且我将 beta 中的那个复制到 prod 中。所以现在我有以下文件结构:

Project file structure

所以现在我需要为每种风格生成 Google Maps API key 并将它们限制为我的应用程序的每种风格。但为此,我需要在每个 Google Cloud 项目的 API key 中指定 SHA-1 指纹。而且我不确定在那里使用哪一个。我可以对所有这些使用相同的 SHA-1 指纹吗?我是否应该为每种构建类型(调试/发布)或每种风格(dev/qa/prod)使用不同的 SHA-1 指纹?如果是这样,我如何找到用于每个键的正确指纹?

请注意,我尝试了 Gradle 签名报告,但没有太大帮助:

13:05:37: Executing task 'signingReport'...

Executing tasks: [signingReport]


> Task :app:signingReport
Variant: prodDebug
Config: debug
Store: /Users/sarbogast/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 93:AA:D5:1B:0D:EA:7B:49:0B:BE:9F:13:FA:46:74:3F
SHA1: 09:FE:D6:BF:19:44:FC:BB:AB:7E:24:19:F7:A9:7D:31:2B:A5:55:17
SHA-256: 62:99:B8:38:07:B1:41:63:62:39:1B:2F:8A:80:F4:F6:E6:A5:97:2C:D0:7B:28:1E:34:2F:90:D1:10:C3:04:C4
Valid until: Monday, November 9, 2043
----------
Variant: devRelease
Config: none
----------
Variant: prodRelease
Config: none
----------
Variant: betaRelease
Config: none
----------
Variant: prodReleaseUnitTest
Config: none
----------
Variant: betaDebugAndroidTest
Config: debug
Store: /Users/sarbogast/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 93:AA:D5:1B:0D:EA:7B:49:0B:BE:9F:13:FA:46:74:3F
SHA1: 09:FE:D6:BF:19:44:FC:BB:AB:7E:24:19:F7:A9:7D:31:2B:A5:55:17
SHA-256: 62:99:B8:38:07:B1:41:63:62:39:1B:2F:8A:80:F4:F6:E6:A5:97:2C:D0:7B:28:1E:34:2F:90:D1:10:C3:04:C4
Valid until: Monday, November 9, 2043
----------
Variant: devReleaseUnitTest
Config: none
----------
Variant: prodDebugUnitTest
Config: debug
Store: /Users/sarbogast/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 93:AA:D5:1B:0D:EA:7B:49:0B:BE:9F:13:FA:46:74:3F
SHA1: 09:FE:D6:BF:19:44:FC:BB:AB:7E:24:19:F7:A9:7D:31:2B:A5:55:17
SHA-256: 62:99:B8:38:07:B1:41:63:62:39:1B:2F:8A:80:F4:F6:E6:A5:97:2C:D0:7B:28:1E:34:2F:90:D1:10:C3:04:C4
Valid until: Monday, November 9, 2043
----------
Variant: devDebugUnitTest
Config: debug
Store: /Users/sarbogast/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 93:AA:D5:1B:0D:EA:7B:49:0B:BE:9F:13:FA:46:74:3F
SHA1: 09:FE:D6:BF:19:44:FC:BB:AB:7E:24:19:F7:A9:7D:31:2B:A5:55:17
SHA-256: 62:99:B8:38:07:B1:41:63:62:39:1B:2F:8A:80:F4:F6:E6:A5:97:2C:D0:7B:28:1E:34:2F:90:D1:10:C3:04:C4
Valid until: Monday, November 9, 2043
----------
Variant: devDebugAndroidTest
Config: debug
Store: /Users/sarbogast/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 93:AA:D5:1B:0D:EA:7B:49:0B:BE:9F:13:FA:46:74:3F
SHA1: 09:FE:D6:BF:19:44:FC:BB:AB:7E:24:19:F7:A9:7D:31:2B:A5:55:17
SHA-256: 62:99:B8:38:07:B1:41:63:62:39:1B:2F:8A:80:F4:F6:E6:A5:97:2C:D0:7B:28:1E:34:2F:90:D1:10:C3:04:C4
Valid until: Monday, November 9, 2043
----------
Variant: betaDebugUnitTest
Config: debug
Store: /Users/sarbogast/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 93:AA:D5:1B:0D:EA:7B:49:0B:BE:9F:13:FA:46:74:3F
SHA1: 09:FE:D6:BF:19:44:FC:BB:AB:7E:24:19:F7:A9:7D:31:2B:A5:55:17
SHA-256: 62:99:B8:38:07:B1:41:63:62:39:1B:2F:8A:80:F4:F6:E6:A5:97:2C:D0:7B:28:1E:34:2F:90:D1:10:C3:04:C4
Valid until: Monday, November 9, 2043
----------
Variant: devDebug
Config: debug
Store: /Users/sarbogast/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 93:AA:D5:1B:0D:EA:7B:49:0B:BE:9F:13:FA:46:74:3F
SHA1: 09:FE:D6:BF:19:44:FC:BB:AB:7E:24:19:F7:A9:7D:31:2B:A5:55:17
SHA-256: 62:99:B8:38:07:B1:41:63:62:39:1B:2F:8A:80:F4:F6:E6:A5:97:2C:D0:7B:28:1E:34:2F:90:D1:10:C3:04:C4
Valid until: Monday, November 9, 2043
----------
Variant: betaReleaseUnitTest
Config: none
----------
Variant: prodDebugAndroidTest
Config: debug
Store: /Users/sarbogast/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 93:AA:D5:1B:0D:EA:7B:49:0B:BE:9F:13:FA:46:74:3F
SHA1: 09:FE:D6:BF:19:44:FC:BB:AB:7E:24:19:F7:A9:7D:31:2B:A5:55:17
SHA-256: 62:99:B8:38:07:B1:41:63:62:39:1B:2F:8A:80:F4:F6:E6:A5:97:2C:D0:7B:28:1E:34:2F:90:D1:10:C3:04:C4
Valid until: Monday, November 9, 2043
----------
Variant: betaDebug
Config: debug
Store: /Users/sarbogast/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 93:AA:D5:1B:0D:EA:7B:49:0B:BE:9F:13:FA:46:74:3F
SHA1: 09:FE:D6:BF:19:44:FC:BB:AB:7E:24:19:F7:A9:7D:31:2B:A5:55:17
SHA-256: 62:99:B8:38:07:B1:41:63:62:39:1B:2F:8A:80:F4:F6:E6:A5:97:2C:D0:7B:28:1E:34:2F:90:D1:10:C3:04:C4
Valid until: Monday, November 9, 2043
----------

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
13:05:38: Task execution finished 'signingReport'.

我对整个 Android 生态系统还是比较陌生,我找不到很多关于这种设置的文档,所以我也不确定我做的是否正确。

最佳答案

可能是你的signingConfig有问题

试试这个,

signingConfigs {
productname{
storeFile file("release.keystore") //or jKs file path
storePassword "myPassword"
keyAlias "myAlias"
keyPassword "Something...."
}
}

buildTypes {

debug {
signingConfig signingConfigs.productname
}
release {
signingConfig signingConfigs.productname
}
}

关于适用于不同产品风格的 Android Google Maps API key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55914316/

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