Невозможно разрешить зависимость для дооснащения2 - PullRequest
0 голосов
/ 07 сентября 2018

Я пытаюсь импортировать модифицированную библиотеку в мой файл Gradle, но, к сожалению, у меня слишком много ошибок.

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.

EDIT Это мое приложение build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.example.practice"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.dinuscxj:recyclerrefreshlayout:2.0.5'
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.firebaseui:firebase-ui-database:4.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.squareup.picasso:picasso:2.71828'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.vanniktech:emoji-one:0.5.1'
implementation 'net.danlew:android.joda:2.9.9.3'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
}

apply plugin: 'com.google.gms.google-services'

Это мой проект build.gradle

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:4.0.1'
  }
}

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

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

Я добавил последнюю версию retrofit2, но все еще получаю эти ошибки. У меня есть поиск возможных решений, но я ничего не могу найти. Может кто-нибудь помочь мне с этой проблемой?

Ответы [ 5 ]

0 голосов
/ 07 сентября 2018

Я нашел решение. Я забыл снять отметку автономная работа в Настройки -> Построение, выполнение, развертывание -> Gradle -> Автономная работа

0 голосов
/ 07 сентября 2018

Можете ли вы добавить этот плагин в файл build.gradle вашего приложения

implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'

И можете ли вы изменить файл build.gradle проекта, как показано ниже в кодах всех проектов

 allprojects {
repositories {
    google()
    maven { url "https://jitpack.io" }
    jcenter()
} }
0 голосов
/ 07 сентября 2018

Попробуйте добавить это к gradle уровня модуля (т.е. приложения):

repositories {
    maven {
        mavenCentral()
    }
}

Также вы можете попробовать:

Перейти к файлу / аннулировать перезапуск кэша

0 голосов
/ 07 сентября 2018

Попробуйте это

  implementation('com.squareup.retrofit2:retrofit:2.1.0') {
    // exclude Retrofit’s OkHttp dependency module and define your own module import
    exclude module: 'okhttp'
}
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.okhttp3:okhttp:3.4.1'

и проект build.gradle

allprojects {
repositories {
    jcenter()
    google()
    mavenCentral()
    maven { url 'https://jitpack.io' }
}
}
0 голосов
/ 07 сентября 2018

Добавьте файл сборки Gradle

'com.squareup.retrofit2:retrofit:2.4.0'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...