【问题标题】:yarn android error "You must specify a URL for a Maven repository" but its already set?yarn android 错误“您必须为 Maven 存储库指定 URL”但它已经设置了吗?
【发布时间】:2021-11-08 02:38:28
【问题描述】:

我需要构建并运行一个项目,我克隆了它,安装了依赖项,运行命令 yarn android 后,构建失败,控制台告诉我:

info Installing the app...
Starting a Gradle Daemon, 3 incompatible and 1 stopped Daemons could not be reused, use --status for details
                                Configuration on demand is an incubating feature.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> You must specify a URL for a Maven repository.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 21s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

error Command failed with exit code 1.

我检查了“您必须为 Maven 存储库指定 URL”这一行。并找出 build.gradle 文件应该包含一个 Maven URL,但我的已经有了这个 URL:

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())


buildscript {
    ext {
        firebaseMessagingVersion =  "21.1.0"
        minSdkVersion = 23
        compileSdkVersion = 29
        targetSdkVersion = 29
        buildToolsVersion = "29.0.2"
        googlePlayServicesVersion = "17.0.0"
        multiDexEnabled=true
        supportLibVersion = "23.1.1" 
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")
        classpath 'com.google.gms:google-services:4.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        jcenter()
        maven {
            url 'https://jitpack.io'
            url "https://maven.google.com"
             }
        maven {
            url = properties.getProperty ("bkm_maven_url")
            credentials {
                username = properties.getProperty ("bkm_username")
                password = properties.getProperty ("bkm_password")
            }
        }

        // force dependency versions on all subprojects
        configurations.all {
            resolutionStrategy {
                // use 0.9.0 to fix crash on Android 11
                force "com.facebook.soloader:soloader:0.9.0"
            }
        }
    }
}

我该如何解决这个问题?

【问题讨论】:

    标签: android react-native maven gradle


    【解决方案1】:

    在测试了不同的方法后,我发现我应该只使用npm 来安装依赖项。我的意思是不要与yarn 混合,这解决了我的问题。

    【讨论】:

      猜你喜欢
      • 2021-04-12
      • 1970-01-01
      • 2015-11-04
      • 1970-01-01
      • 2015-06-22
      • 2021-08-21
      • 1970-01-01
      • 2011-06-21
      • 1970-01-01
      相关资源
      最近更新 更多