不允许解析依赖配置“实现”,因为它被定义为“canBeResolved = false”

Ish*_*ran 13 java android gradle react-native

我正在尝试运行一个 React Native 项目,但它的 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)
Run Code Online (Sandbox Code Playgroud)

这是问题发生的地方

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'
    }
Run Code Online (Sandbox Code Playgroud)

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

小智 2

您应该使用下面的代码:

classpath += files(configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) })
Run Code Online (Sandbox Code Playgroud)

这可能对你有帮助。