代码之家  ›  专栏  ›  技术社区  ›  Elis Hazelton

解析失败:com.halfhp.fig:figlib:1.0.7(mavenCentral/jcenter?)

  •  1
  • Elis Hazelton  · 技术社区  · 1 年前

    我正在用Kotlin构建一个Android应用程序。我希望它有图表,我正在使用

    implementation(libs.androidplot.core)
    

    在我的build.gradle文件中。但在重新加载Gradle项目时,我遇到了以下错误:

    Failed to resolve: com.halfhp.fig:figlib:1.0.7
    Show in Project Structure dialog
    Affected Modules: app
    

    互联网上的建议大致如下: What is the correct way of changing jcenter to mavenCentral? 将jcenter()更改为mavenCentral()。然而,我的build.gradle看起来如下,我不知道如何正确更改依赖项的来源——没有“buildscripts”部分:

    plugins {
        alias(libs.plugins.android.application)
        alias(libs.plugins.kotlin.android)
    }
    
    android {
        namespace = "com.example.myapp"
        compileSdk = 34
    
        defaultConfig {
            applicationId = "com.example.myapp"
            minSdk = 32
            targetSdk = 34
            versionCode = 1
            versionName = "1.0"
    
            testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            release {
                isMinifyEnabled = false
                proguardFiles(
                    getDefaultProguardFile("proguard-android-optimize.txt"),
                    "proguard-rules.pro"
                )
            }
        }
        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_11
            targetCompatibility = JavaVersion.VERSION_11
        }
        kotlinOptions {
            jvmTarget = "11"
        }
        buildFeatures {
            viewBinding = true
        }
    }
    
    
    dependencies {
    
        implementation(libs.androidx.core.ktx)
        implementation(libs.androidx.appcompat)
        implementation(libs.material)
        implementation(libs.androidx.constraintlayout)
        implementation(libs.androidx.lifecycle.livedata.ktx)
        implementation(libs.androidx.lifecycle.viewmodel.ktx)
        implementation(libs.androidx.navigation.fragment.ktx)
        implementation(libs.androidx.navigation.ui.ktx)
        implementation(libs.androidx.legacy.support.v4)
        implementation(libs.androidx.fragment.ktx)
        implementation(libs.androidx.activity)
        implementation(libs.androidplot.core)
        implementation ("com.halfhp.fig:figlib:1.0.7")
        testImplementation(libs.junit)
        androidTestImplementation(libs.androidx.junit)
        androidTestImplementation(libs.androidx.espresso.core)
    }
    
    1 回复  |  直到 1 年前
        1
  •  1
  •   CommonsWare    1 年前

    然而,我的build.gradle看起来如下,我不知道如何正确更改依赖项的来源——没有“buildscripts”部分:

    你可能已经有了 mavenCentral() 已配置。在较新的项目中,默认情况是在 settings.gradle settings.gradle.kts 在一个 dependencyResolutionManagement() lambda:

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
        }
    }
    

    你的问题在于你的版本。替换:

        implementation ("com.halfhp.fig:figlib:1.0.7")
    

    与:

        implementation ("com.halfhp.fig:figlib:1.0.11")
    

    1.0.11 the only version reported to be in Maven Central .

    另外,请注意 this project has not been updated in 3 years .