Problem adding "com.github.persian-calendar:calendar" to an empty android project?

Viewed 14

What are the correct steps to add "com.github.persian-calendar:calendar:1.2.1" to an empty android project? I have tried different ways including this guide, but Gradle complains about all of them.

Build.gradle (project):

buildscript {
        ext {   compose_version = '1.2.0'   }
    }
    plugins {
        id 'com.android.application' version '7.4.0-alpha10' apply false
        id 'com.android.library' version '7.4.0-alpha10' apply false
        id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
    }
    allprojects {
        repositories {
            maven("https://jitpack.io")
        }
    }

Build.gradle (module):

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.example.trash2'
    compileSdk 32

    defaultConfig {
        applicationId "com.example.trash2"
        minSdk 24
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.2.0'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {
    implementation("com.github.persian-calendar:calendar:1.2.1")

    ...
}

Error:

org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'trash2'. ...... Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method maven() for arguments [https://jitpack.io] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.

1 Answers

Step 1 :

Use  maven { url 'https://jitpack.io' }  instead of  maven("https://jitpack.io")

Step 2 :

Put  maven { url 'https://jitpack.io' }  in settings.gradle :

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