You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native集成Android SDK时无法找到com.cuelinks.sdk:link-kit依赖

错误信息

执行./gradlew build时抛出以下错误:

Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not find com.cuelinks.sdk:link-kit:1.0.3.
  Required by:
      project :app

应用级build.gradle配置

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"

react {
    
}

/**
 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
 */
def enableProguardInReleaseBuilds = false

def jscFlavor = 'org.webkit:android-jsc:+'

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    namespace "com.cuelinkssdkintegration"
    defaultConfig {
        applicationId "com.cuelinkssdkintegration"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
}

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android:0.71.3")
    implementation("androidx.appcompat:appcompat:1.5.1")
    implementation("com.cuelinks.sdk:link-kit:1.0.3")

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

已尝试的方案

  • 执行./gradlew clean后运行npx react-native run-android
  • 清除缓存并重启
  • 删除node_modules后重新安装

注:该依赖在原生Android项目中可正常使用。

解决方案

1. 检查项目根目录build.gradle的仓库配置

问题核心是React Native项目的Gradle仓库未包含com.cuelinks.sdk:link-kit所在的仓库源。打开项目根目录下的build.gradle文件,确保allprojects.repositories中添加了对应仓库:

allprojects {
    repositories {
        google()
        mavenCentral()
        // 若为Cuelinks私有仓库,添加对应地址:
        // maven { url 'https://maven.cuelinks.com/repository' }
        maven { url "$rootDir/../node_modules/react-native/android" }
        maven { url "$rootDir/../node_modules/jsc-android/dist" }
    }
}

2. 若为本地AAR依赖

如果原生项目中是通过本地AAR文件引入的依赖,需在应用级build.gradle中添加本地仓库路径:

android {
    // 保留原有配置
    repositories {
        flatDir {
            dirs 'libs'
        }
    }
}

将link-kit-1.0.3.aar文件复制到app/libs目录下,修改依赖声明为:

implementation(name: 'link-kit', ext: 'aar')

3. 同步并重新构建

执行以下命令同步Gradle并重新构建:

./gradlew clean build

内容的提问来源于stack exchange,提问作者Sam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 06:24:54