我在 Typescript 上有 React Native 项目,并尝试添加应用程序链接功能。
我遵循了这里的官方指示:
登录AppGallery Connect,下载
agconnect-services.json
文件并添加到root\android\app
文件夹中。
配置HMS Core SDK的Maven仓库地址:
检查了我的gradle版本(
npm gradle -v
),是10.8.3;
在
build.gradle
目录中的 root\android\
文件中进入 buildscript > 依赖项,我添加了:
classpath("com.android.tools.build:gradle:10.8.3")
classpath ("com.huawei.agconnect:agcp:1.9.1.300")
root\android\
在文件中settings.gradle
我像这样改变了:pluginManagement { repositories {
gradlePluginPortal()
google()
mavenCentral()
// Configure the Maven repository address for the HMS Core SDK.
maven { url 'https://developer.huawei.com/repo/' }
}
includeBuild("../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'Awesome'
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
// Configure the Maven repository address for the HMS Core SDK.
maven { url 'https://developer.huawei.com/repo/' }
}
}
root\android\app
文件夹中build.gradle
我添加了:apply plugin: 'com.huawei.agconnect'
npm start
,选择Andriod并得到这个错误:> Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:10.8.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/10.8.3/gradle-10.8.3.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/10.8.3/gradle-10.8.3.pom
Required by:
project :
> Could not find com.huawei.agconnect:agcp:1.9.1.300.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/huawei/agconnect/agcp/1.9.1.300/agcp-1.9.1.300.pom
- https://repo.maven.apache.org/maven2/com/huawei/agconnect/agcp/1.9.1.300/agcp-1.9.1.300.pom
Required by:
project :
> Could not find com.android.tools.build:gradle:10.8.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/10.8.3/gradle-10.8.3.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/10.8.3/gradle-10.8.3.pom
Required by:
project : > project :gradle-plugin:react-native-gradle-plugin
可能出现什么问题以及我需要更改什么?
classpath
应该使用现有版本...
classpath("com.android.tools.build:gradle:8.7.1")
classpath ("com.huawei.agconnect:agcp:1.9.1.303")