首页 > 解决方案 > 不允许解析依赖配置“实现”,因为它被定义为“canBeResolved=false”

问题描述

我正在尝试运行一个反应原生项目,但它的 gradle 无法正常工作。这是错误。

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':babylonjs_react-native'.
Caused by: java.lang.IllegalStateException: Resolving dependency configuration 'implementation' is not allowed as it is defined as 'canBeResolved=false'.
Instead, a resolvable ('canBeResolved=true') dependency configuration that extends 'implementation' should be resolved.
    at build_8wyks54mb6cye9xs3jcg9t1xg$_run_closure4$_closure12.doCall(G:\Workspace\New Folder (2)\node_modules\@babylonjs\react-native\android\build.gradle:117)
    at build_8wyks54mb6cye9xs3jcg9t1xg$_run_closure4.doCall(G:\Workspace\New Folder (2)\node_modules\@babylonjs\react-native\android\build.gradle:114)

这是问题发生的地方

afterEvaluate { project ->
    // some Gradle build hooks ref:
    // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
    task androidJavadoc(type: Javadoc) {
        source = android.sourceSets.main.java.srcDirs
        classpath += files(android.bootClasspath)
        classpath += files(project.getConfigurations().getByName('implementation').asList())
        include '**/*.java'
    }

请有人告诉我为什么错误显示我不知道发生了什么。有人请帮助我,我将非常感激。

标签: javaandroidreact-nativegradle

解决方案


您应该使用下面的代码:

classpath += files(configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) })

这可能对你有帮助。


推荐阅读