Android Studio: зависимости от github

Я пытаюсь включить джойстик в свое приложение, взятое отсюда: https://github.com/controlwear/виртуальный-джойстик-андроид

Настройки Грейдла:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
plugins {
    id 'com.android.application'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.tau.betterhovercraft"
        minSdk 16
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'io.github.controlwear:virtualjoystick:1.10.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

И ошибка, которую я получаю: Ошибка

Я понимаю, что он пытается найти эту библиотеку, но не ищет на github, и я не знаю, как ему сказать.

Я уже пытался поставить эту строку:

        maven { url "https://jitpack.io" }

а потом :

    implementation 'com.github.controlwear:virtualjoystick:1.10.1'

Но я получаю ту же ошибку

РЕДАКТИРОВАТЬ :

Итак, я очень тупой, извините за неудобства, вам просто нужно поместить это в настройки.gradle:

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

Большое спасибо за помощь мне!

0
0
48
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

Ответ принят как подходящий

Вы добавили репозитории maven в раздел allprojects?

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
}

Обновлено: согласно https://mvnrepository.com/artifact/io.github.controlwear/virtualjoystick?repo=jcenter библиотека доступна на jcenter()

Пробовали скачать одну из версий? Я думаю, что все это потерпит неудачу, потому что, если я правильно помню, репозиторий JCenter был закрыт 1 февраля 2022 года testfairy.com/блог/…

Robert 15.03.2022 16:27

Он не закрыт, он просто не принимает новые пакеты. В настоящее время они не планируют закрывать его в ближайшем будущем, но да, не помешает сохранить зависимости в другом месте.

Thommy 15.03.2022 16:51

Добавьте 'jcenter ()' внутри вашего settings.gradle

repositories {
    google()
    mavenCentral()
    jcenter()
}

Я надеюсь, что это может решить вашу проблему. Спасибо.

Это работает, я просто тупой.... Большое спасибо!

Téo TRENY 15.03.2022 10:37

Я рад, что могу помочь. ?

Lalrem Lian B Tlung 15.03.2022 11:48

Если я правильно помню, репозиторий JCenter был закрыт в прошлом году...

Robert 15.03.2022 16:28

Другие вопросы по теме