在android中集成 jitpack.io 时出错

Getting error while integrating jitpack.io in android

提问人:Mohamad Vahid Soudagar 提问时间:11/17/2023 最后编辑:RobertMohamad Vahid Soudagar 更新时间:11/17/2023 访问量:21

问:

嗨,我在同步项目时收到此错误 e:D:\Projects\Android Projects\Learning\Android\Task\settings.gradle.kts:13:21:意外的标记(使用“;”分隔同一行上的表达式)

这是我的settings.gradle

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

rootProject.name = "Gweiland_Task"
include(":app")

这是我的模块和项目级构建文件

项目

// Top-level build file where you can add configuration options common to all sub-projects/modules.

plugins {
    id("com.android.application") version "8.1.2" apply false
}

模块

plugins {
    id("com.android.application")
}

android {
    namespace = "com.example.gweiland_task"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.example.gweiland_task"
        minSdk = 25
        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_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    viewBinding {
        enable = true
    }
}

dependencies {

    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.10.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

//    mp chart
    implementation("com.github.PhilJay:MPAndroidChart:v3.1.0")
    implementation("com.github.jitpack:android-example:1.0.1")
}

我正在尝试导入我的一个库的 jitpack.io

Android Gradle Jitpack

评论


答:

0赞 Sergei Kozelko 11/21/2023 #1

您正在尝试在 Kotlin 构建脚本中使用 Groovy 代码。正确的语法是

maven { url = uri("https://jitpack.io") }