Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 华为通道 V5 接入.md #15885

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@

## SDK 集成(二选一)
### Android Studio Gradle 自动集成
Gradle 7.0 及以下版本
1. 在 Android 项目级目录 build.gradle 文件,**buildscript** > **repositories & dependencies** 下分别添加华为仓库地址和 HMS gradle 插件依赖:
```java
buildscript {
repositories {
google()
mavenCentral()
maven {url 'https://developer.huawei.com/repo/'} // 华为 maven 仓库地址
}
dependencies {
Expand All @@ -46,12 +47,65 @@ buildscript {
2. 在 Android 项目级目录 build.gradle 文件,**allprojects**>**repositories**下添加华为依赖仓库地址:
```java
allprojects {
repositories {
mavenCentral()
maven {url 'https://developer.huawei.com/repo/'} // 华为 maven 仓库地址
}
}
```
Gradle 7.0 版本
1. 在 Android 项目级目录 build.gradle 文件,**buildscript** > **repositories & dependencies** 下分别添加华为仓库地址和 HMS gradle 插件依赖:
```java
buildscript {
repositories {
mavenCentral()
maven {url 'https://developer.huawei.com/repo/'} // 华为 maven 仓库地址
}
dependencies {
// 其他classpath配置
classpath 'com.huawei.agconnect:agcp:1.6.0.300' // 华为推送 gradle 插件依赖
}
}
```
2. 在 Android 项目级目录 settings.gradle 文件,**dependencyResolutionManagement **>**repositories**下添加华为依赖仓库地址:
```java
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {url 'https://developer.huawei.com/repo/'} // 华为 maven 仓库地址
}
}
```
Gradle 7.0 及以上版本
1. 在 Android 项目级目录 build.gradle 文件,**buildscript** > **dependencies ** 下添加 HMS gradle 插件依赖:
```java
buildscript {
dependencies {
// 其他classpath配置
classpath 'com.huawei.agconnect:agcp:1.6.0.300' // 华为推送 gradle 插件依赖
}
}
```
2. 在 Android 项目级目录 settings.gradle 文件,**pluginManagement & dependencyResolutionManagement **>**repositories**下分别添加华为依赖仓库地址:
```java
pluginManagement {
repositories {
mavenCentral() // 此处请调整 mavenCentral() 在仓库配置列表最前置位置
google()
gradlePluginPortal()
maven {url 'https://developer.huawei.com/repo/'} // 华为仓,如果不集成华为可以不加
}
}
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {url 'https://developer.huawei.com/repo/'} // 华为 maven 仓库地址
}
}
```

3. 将从华为推送平台获取的应用配置文件 agconnect-services.json 拷贝到 app 模块目录下(请勿放在子模块下)。
![](https://main.qcloudimg.com/raw/338c87faaeb388f648835f17aeddc490.png)
4. 在 app 模块下 build.gradle 文件头部添加以下配置(请勿放在子模块 build.gradle 下):
Expand Down