fix(mobile): 让华为 AGConnect 在 AGP 9 下能识别真实配置
放入 agconnect-services.json 后原插件坐标无法解析,且 1.9.1 不兼容 AGP 9。 映射到 agcp 1.9.5.301,Gradle 可按包名校验;该文件继续忽略不入库。 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Cursor
multica-agent
parent
a71f6a0ce1
commit
1d393f4f1e
@@ -1,6 +1,6 @@
|
||||
# 华为厂商通道配置文件(缺口)
|
||||
# 华为厂商通道配置文件
|
||||
|
||||
华为通道客户端其余依赖已接入。**唯一还缺的文件**是:
|
||||
华为通道客户端依赖已接入。构建机需要一份本地文件:
|
||||
|
||||
`mobile/android/app/agconnect-services.json`
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
|
||||
没有这份文件时:
|
||||
|
||||
- 安卓包仍可构建(AGConnect 插件按文件是否存在条件启用)
|
||||
- 极光自己的通道仍可初始化
|
||||
- AGConnect 插件不会启用,安卓包仍可走极光自有通道构建
|
||||
- **华为真机的厂商通道无法接通**,杀进程后的到达率会明显下降
|
||||
|
||||
本阶段不伪造、不提交该文件。
|
||||
放入真实配置后,`:app` 会启用 AGConnect(agcp `1.9.5.301`,适配 AGP 9)。Gradle 会按包名 `cn.solsum.jinxunda` 校验该文件;校验失败则构建失败。
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
maven("https://maven.aliyun.com/repository/google")
|
||||
maven("https://maven.aliyun.com/repository/central")
|
||||
maven("https://developer.huawei.com/repo/")
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
// agcp 1.9.x 用 apply() 时会检查 buildscript classpath 里有没有 AGP;
|
||||
// 仅靠 plugins DSL 会报「com.android.tools.build:gradle is no set」。
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:9.0.1")
|
||||
classpath("com.huawei.agconnect:agcp:1.9.5.301")
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
||||
@@ -6,8 +22,9 @@ plugins {
|
||||
|
||||
// 华为 agconnect-services.json 到位后才启用 AGConnect 插件,避免缺文件时整包编不过。
|
||||
// 文件从华为 AppGallery Connect 下载,放到本目录,不要提交进 Git。
|
||||
val agconnectServices = file("agconnect-services.json")
|
||||
if (agconnectServices.exists()) {
|
||||
// jpush_flutter_android 只在自己的 library 模块 apply 该插件,不会处理本 app 的配置文件,
|
||||
// 所以这里仍要在 :app 上 apply,并不是重复。
|
||||
if (file("agconnect-services.json").exists()) {
|
||||
apply(plugin = "com.huawei.agconnect")
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[versions]
|
||||
agp = "9.0.1"
|
||||
agcp = "1.9.5.301"
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
huawei-agconnect = { id = "com.huawei.agconnect", version.ref = "agcp" }
|
||||
@@ -20,13 +20,24 @@ pluginManagement {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
// 华为插件发布在 Maven 的 agcp 构件上,没有 Plugin Portal 的
|
||||
// com.huawei.agconnect.gradle.plugin 坐标。plugins DSL 必须映射过去,
|
||||
// 否则放入 agconnect-services.json 后启用插件会解析失败。
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.id == "com.huawei.agconnect") {
|
||||
useModule("com.huawei.agconnect:agcp:1.9.5.301")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||
id("com.android.application") version "9.0.1" apply false
|
||||
id("org.jetbrains.kotlin.android") version "2.3.20" apply false
|
||||
id("com.huawei.agconnect") version "1.9.1.301" apply false
|
||||
id("com.huawei.agconnect") version "1.9.5.301" apply false
|
||||
}
|
||||
|
||||
include(":app")
|
||||
|
||||
Reference in New Issue
Block a user