Gradle 错误:无法为 ProductFlavor_Decorated 获取未知 属性 'project'
Error with Gradle: Could not get unknown property 'project' for ProductFlavor_Decorated
我到处搜索这个问题,但没有找到解决方案。我将 Gradle 升级到版本 6.7.1。升级后第一次尝试同步 Gradle 时,我收到此错误:
Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'project' for ProductFlavor_Decorated{name=flavor1, dimension=null, minSdkVersion=null, targetSdkVersion=null, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=null, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=[], buildConfigFields={}, resValues={}, proguardFiles=[], consumerProguardFiles=[], manifestPlaceholders={}, wearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.ProductFlavor.
at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
at com.android.build.gradle.internal.dsl.ProductFlavor_Decorated.getProperty(Unknown Source)
at de.triplet.gradle.play.PlayPublisherPlugin$_apply_closure2.doCall(PlayPublisherPlugin.groovy:26)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.util.ClosureBackedAction.execute(ClosureBackedAction.java:71)
at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:154)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:105)
at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:166)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication.execute(DefaultUserCodeApplicationContext.java:100)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.run(DefaultCollectionCallbackActionDecorator.java:95)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run(DefaultBuildOperationExecutor.java:71)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.execute(DefaultCollectionCallbackActionDecorator.java:92)
at org.gradle.internal.ImmutableActionSet$SetWithFewActions.execute(ImmutableActionSet.java:285)
at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:264)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection.doAdd(DefaultNamedDomainObjectCollection.java:113)
at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:253)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.create(AbstractNamedDomainObjectContainer.java:79)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.create(AbstractNamedDomainObjectContainer.java:71)
at org.gradle.api.internal.NamedDomainObjectContainerConfigureDelegate._configure(NamedDomainObjectContainerConfigureDelegate.java:39)
at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:65)
at build_vakvk2514duks3dkwbm106jz$_run_closure2$_closure14.doCall({project-directory}/app/build.gradle:81)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.util.ClosureBackedAction.execute(ClosureBackedAction.java:71)
at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:154)
at org.gradle.util.ConfigureUtil.configureSelf(ConfigureUtil.java:142)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.configure(AbstractNamedDomainObjectContainer.java:91)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.configure(AbstractNamedDomainObjectContainer.java:38)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:103)
at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:166)
at com.android.build.gradle.internal.dsl.CommonExtensionImpl.productFlavors(CommonExtensionImpl.kt:197)
at com.android.build.gradle.internal.dsl.BaseAppModuleExtension.productFlavors(BaseAppModuleExtension.kt)
at com.android.build.gradle.internal.dsl.BaseAppModuleExtension_Decorated.productFlavors(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:484)
at org.gradle.internal.metaobject.BeanDynamicObject.tryInvokeMethod(BeanDynamicObject.java:196)
at org.gradle.internal.metaobject.CompositeDynamicObject.tryInvokeMethod(CompositeDynamicObject.java:98)
at org.gradle.internal.extensibility.MixInClosurePropertiesAsMethodsDynamicObject.tryInvokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:34)
at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:56)
at build_vakvk2514duks3dkwbm106jz$_run_closure2.doCall({project-directory}/app/build.gradle:80)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.util.ClosureBackedAction.execute(ClosureBackedAction.java:71)
at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:154)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:105)
at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:166)
at org.gradle.internal.extensibility.ExtensionsStorage$ExtensionHolder.configure(ExtensionsStorage.java:173)
at org.gradle.internal.extensibility.ExtensionsStorage.configureExtension(ExtensionsStorage.java:64)
at org.gradle.internal.extensibility.DefaultConvention.configureExtension(DefaultConvention.java:364)
at org.gradle.internal.extensibility.DefaultConvention.access0(DefaultConvention.java:45)
at org.gradle.internal.extensibility.DefaultConvention$ExtensionsDynamicObject.tryInvokeMethod(DefaultConvention.java:301)
at org.gradle.internal.metaobject.CompositeDynamicObject.tryInvokeMethod(CompositeDynamicObject.java:98)
at org.gradle.internal.extensibility.MixInClosurePropertiesAsMethodsDynamicObject.tryInvokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:34)
at org.gradle.groovy.scripts.BasicScript$ScriptDynamicObject.tryInvokeMethod(BasicScript.java:134)
at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:163)
at org.gradle.groovy.scripts.BasicScript.invokeMethod(BasicScript.java:83)
at build_vakvk2514duks3dkwbm106jz.run({project-directory}/app/build.gradle:22)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 140 more
这是产品口味:
flavorDimensions "brand", "environment"
productFlavors {
flavor1 {
dimension "brand"
playAccountConfig = playAccountConfigs.defaultAccountConfig
applicationId "com.flavor1.foo"
buildConfigField("String", "productName", "\"Flavor 1\"")
}
flavor2 {
dimension "brand"
playAccountConfig = playAccountConfigs.defaultAccountConfig
applicationId "com.flavor2.foo"
buildConfigField("String", "productName", "\"Flavor 2\"")
}
iat {
dimension "environment"
buildConfigField("boolean", "IAT_ENVIRONMENT", "true")
}
prod {
dimension "environment"
buildConfigField("boolean", "IAT_ENVIRONMENT", "false")
}
}
我不明白是什么导致它突然崩溃,它在 Gradle 版本 5.6.4 上工作正常。
*注意:您可能已经完成了其中的一些,但为了以防万一,我将包括所有这些
在项目的根目录下创建一个名为“gradle.properties”的新文件。
复制并粘贴这些符合您需要的配置:
- ./gradle.properties
- ./app/build.gradle
- Firebase - google-services.json
- 远程配置
- 协议版本
gradle.properties
中的配置
示例配置
ORG="SG_OTC"
STORE_URL="<Play store URL>"
PRIVACY_URL="<Privacy policy URL>"
SERVICE_FOREGROUND_NOTIFICATION_ID=771579
SERVICE_FOREGROUND_CHANNEL_ID="OpenTrace Updates"
SERVICE_FOREGROUND_CHANNEL_NAME="OpenTrace Foreground Service"
PUSH_NOTIFICATION_ID=771578
PUSH_NOTIFICATION_CHANNEL_NAME="OpenTrace Notifications"
#service configurations
SCAN_DURATION=8000
MIN_SCAN_INTERVAL=36000
MAX_SCAN_INTERVAL=43000
ADVERTISING_DURATION=180000
ADVERTISING_INTERVAL=5000
PURGE_INTERVAL=86400000
PURGE_TTL=1814400000
MAX_QUEUE_TIME=7000
BM_CHECK_INTERVAL=540000
HEALTH_CHECK_INTERVAL=900000
CONNECTION_TIMEOUT=6000
BLACKLIST_DURATION=100000
FIREBASE_REGION = "<Your Firebase region>"
STAGING_FIREBASE_UPLOAD_BUCKET = "opentrace-app-staging"
STAGING_SERVICE_UUID = "17E033D3-490E-4BC9-9FE8-2F567643F4D3"
V2_CHARACTERISTIC_ID = "117BDD58-57CE-4E7A-8E87-7CCCDDA2A804"
PRODUCTION_FIREBASE_UPLOAD_BUCKET = "opentrace-app"
PRODUCTION_SERVICE_UUID = "B82AB3FC-1595-4F6A-80F0-FE094CC218F9"
android.useAndroidX=true
android.enableJetifier=true
在 build.gradle
中构建配置
根据buildTypes
中的不同设置,相应地更改包名称和其他配置,例如resValue
例如,
buildTypes {
debug {
buildConfigField "String", "FIREBASE_UPLOAD_BUCKET", STAGING_FIREBASE_UPLOAD_BUCKET
buildConfigField "String", "BLE_SSID", STAGING_SERVICE_UUID
String ssid = STAGING_SERVICE_UUID
versionNameSuffix "-debug-${getGitHash()}-${ssid.substring(ssid.length() - 5,ssid.length() - 1 )}"
resValue "string", "app_name", "OpenTrace Debug"
applicationIdSuffix "stg"
}
Values such as STAGING_FIREBASE_UPLOAD_BUCKET, STAGING_SERVICE_UUID have been defined in gradle.properties as described above.
Firebase 和 google-services.json
为不同的环境设置 Firebase。下载每个环境的 google-services.json 并放在相应的文件夹中。
调试:./app/src/debug/google-services.json
制作:./app/src/release/google-services.json
该应用目前依赖 Firebase Functions 运行。更多信息可参考opentrace-cloud-functions.
获取
远程配置
远程配置用于检索应用程序中使用的“分享”消息。它的关键是“ShareText”。如果无法检索,则回退到 R.string.share_message
协议版本
使用的协议版本应为 2(或以上)协议版本 1 已被弃用
问题与 Gradle Play Publisher 有关。我删除了与 com.github.triplet.play
相关的所有行,现在它正在构建。希望这对和我一样有问题的人有所帮助。
我到处搜索这个问题,但没有找到解决方案。我将 Gradle 升级到版本 6.7.1。升级后第一次尝试同步 Gradle 时,我收到此错误:
Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'project' for ProductFlavor_Decorated{name=flavor1, dimension=null, minSdkVersion=null, targetSdkVersion=null, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=null, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=[], buildConfigFields={}, resValues={}, proguardFiles=[], consumerProguardFiles=[], manifestPlaceholders={}, wearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.ProductFlavor.
at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
at com.android.build.gradle.internal.dsl.ProductFlavor_Decorated.getProperty(Unknown Source)
at de.triplet.gradle.play.PlayPublisherPlugin$_apply_closure2.doCall(PlayPublisherPlugin.groovy:26)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.util.ClosureBackedAction.execute(ClosureBackedAction.java:71)
at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:154)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:105)
at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:166)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication.execute(DefaultUserCodeApplicationContext.java:100)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.run(DefaultCollectionCallbackActionDecorator.java:95)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run(DefaultBuildOperationExecutor.java:71)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.execute(DefaultCollectionCallbackActionDecorator.java:92)
at org.gradle.internal.ImmutableActionSet$SetWithFewActions.execute(ImmutableActionSet.java:285)
at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:264)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection.doAdd(DefaultNamedDomainObjectCollection.java:113)
at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:253)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.create(AbstractNamedDomainObjectContainer.java:79)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.create(AbstractNamedDomainObjectContainer.java:71)
at org.gradle.api.internal.NamedDomainObjectContainerConfigureDelegate._configure(NamedDomainObjectContainerConfigureDelegate.java:39)
at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:65)
at build_vakvk2514duks3dkwbm106jz$_run_closure2$_closure14.doCall({project-directory}/app/build.gradle:81)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.util.ClosureBackedAction.execute(ClosureBackedAction.java:71)
at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:154)
at org.gradle.util.ConfigureUtil.configureSelf(ConfigureUtil.java:142)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.configure(AbstractNamedDomainObjectContainer.java:91)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.configure(AbstractNamedDomainObjectContainer.java:38)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:103)
at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:166)
at com.android.build.gradle.internal.dsl.CommonExtensionImpl.productFlavors(CommonExtensionImpl.kt:197)
at com.android.build.gradle.internal.dsl.BaseAppModuleExtension.productFlavors(BaseAppModuleExtension.kt)
at com.android.build.gradle.internal.dsl.BaseAppModuleExtension_Decorated.productFlavors(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:484)
at org.gradle.internal.metaobject.BeanDynamicObject.tryInvokeMethod(BeanDynamicObject.java:196)
at org.gradle.internal.metaobject.CompositeDynamicObject.tryInvokeMethod(CompositeDynamicObject.java:98)
at org.gradle.internal.extensibility.MixInClosurePropertiesAsMethodsDynamicObject.tryInvokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:34)
at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:56)
at build_vakvk2514duks3dkwbm106jz$_run_closure2.doCall({project-directory}/app/build.gradle:80)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.util.ClosureBackedAction.execute(ClosureBackedAction.java:71)
at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:154)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:105)
at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:166)
at org.gradle.internal.extensibility.ExtensionsStorage$ExtensionHolder.configure(ExtensionsStorage.java:173)
at org.gradle.internal.extensibility.ExtensionsStorage.configureExtension(ExtensionsStorage.java:64)
at org.gradle.internal.extensibility.DefaultConvention.configureExtension(DefaultConvention.java:364)
at org.gradle.internal.extensibility.DefaultConvention.access0(DefaultConvention.java:45)
at org.gradle.internal.extensibility.DefaultConvention$ExtensionsDynamicObject.tryInvokeMethod(DefaultConvention.java:301)
at org.gradle.internal.metaobject.CompositeDynamicObject.tryInvokeMethod(CompositeDynamicObject.java:98)
at org.gradle.internal.extensibility.MixInClosurePropertiesAsMethodsDynamicObject.tryInvokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:34)
at org.gradle.groovy.scripts.BasicScript$ScriptDynamicObject.tryInvokeMethod(BasicScript.java:134)
at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:163)
at org.gradle.groovy.scripts.BasicScript.invokeMethod(BasicScript.java:83)
at build_vakvk2514duks3dkwbm106jz.run({project-directory}/app/build.gradle:22)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 140 more
这是产品口味:
flavorDimensions "brand", "environment"
productFlavors {
flavor1 {
dimension "brand"
playAccountConfig = playAccountConfigs.defaultAccountConfig
applicationId "com.flavor1.foo"
buildConfigField("String", "productName", "\"Flavor 1\"")
}
flavor2 {
dimension "brand"
playAccountConfig = playAccountConfigs.defaultAccountConfig
applicationId "com.flavor2.foo"
buildConfigField("String", "productName", "\"Flavor 2\"")
}
iat {
dimension "environment"
buildConfigField("boolean", "IAT_ENVIRONMENT", "true")
}
prod {
dimension "environment"
buildConfigField("boolean", "IAT_ENVIRONMENT", "false")
}
}
我不明白是什么导致它突然崩溃,它在 Gradle 版本 5.6.4 上工作正常。
*注意:您可能已经完成了其中的一些,但为了以防万一,我将包括所有这些
在项目的根目录下创建一个名为“gradle.properties”的新文件。 复制并粘贴这些符合您需要的配置:
- ./gradle.properties
- ./app/build.gradle
- Firebase - google-services.json
- 远程配置
- 协议版本
gradle.properties
中的配置示例配置
ORG="SG_OTC"
STORE_URL="<Play store URL>"
PRIVACY_URL="<Privacy policy URL>"
SERVICE_FOREGROUND_NOTIFICATION_ID=771579
SERVICE_FOREGROUND_CHANNEL_ID="OpenTrace Updates"
SERVICE_FOREGROUND_CHANNEL_NAME="OpenTrace Foreground Service"
PUSH_NOTIFICATION_ID=771578
PUSH_NOTIFICATION_CHANNEL_NAME="OpenTrace Notifications"
#service configurations
SCAN_DURATION=8000
MIN_SCAN_INTERVAL=36000
MAX_SCAN_INTERVAL=43000
ADVERTISING_DURATION=180000
ADVERTISING_INTERVAL=5000
PURGE_INTERVAL=86400000
PURGE_TTL=1814400000
MAX_QUEUE_TIME=7000
BM_CHECK_INTERVAL=540000
HEALTH_CHECK_INTERVAL=900000
CONNECTION_TIMEOUT=6000
BLACKLIST_DURATION=100000
FIREBASE_REGION = "<Your Firebase region>"
STAGING_FIREBASE_UPLOAD_BUCKET = "opentrace-app-staging"
STAGING_SERVICE_UUID = "17E033D3-490E-4BC9-9FE8-2F567643F4D3"
V2_CHARACTERISTIC_ID = "117BDD58-57CE-4E7A-8E87-7CCCDDA2A804"
PRODUCTION_FIREBASE_UPLOAD_BUCKET = "opentrace-app"
PRODUCTION_SERVICE_UUID = "B82AB3FC-1595-4F6A-80F0-FE094CC218F9"
android.useAndroidX=true
android.enableJetifier=true
在 build.gradle
中构建配置根据buildTypes
中的不同设置,相应地更改包名称和其他配置,例如resValue
例如,
buildTypes {
debug {
buildConfigField "String", "FIREBASE_UPLOAD_BUCKET", STAGING_FIREBASE_UPLOAD_BUCKET
buildConfigField "String", "BLE_SSID", STAGING_SERVICE_UUID
String ssid = STAGING_SERVICE_UUID
versionNameSuffix "-debug-${getGitHash()}-${ssid.substring(ssid.length() - 5,ssid.length() - 1 )}"
resValue "string", "app_name", "OpenTrace Debug"
applicationIdSuffix "stg"
}
Values such as STAGING_FIREBASE_UPLOAD_BUCKET, STAGING_SERVICE_UUID have been defined in gradle.properties as described above.
Firebase 和 google-services.json
为不同的环境设置 Firebase。下载每个环境的 google-services.json 并放在相应的文件夹中。
调试:./app/src/debug/google-services.json
制作:./app/src/release/google-services.json
该应用目前依赖 Firebase Functions 运行。更多信息可参考opentrace-cloud-functions.
获取远程配置
远程配置用于检索应用程序中使用的“分享”消息。它的关键是“ShareText”。如果无法检索,则回退到 R.string.share_message
协议版本
使用的协议版本应为 2(或以上)协议版本 1 已被弃用
问题与 Gradle Play Publisher 有关。我删除了与 com.github.triplet.play
相关的所有行,现在它正在构建。希望这对和我一样有问题的人有所帮助。