Dependencies Gradle with error

Asked

Viewed 358 times

2

Every time I try to introduce any API in my project and put Compile there in the dependencies of Gradle it gives error and does not come out of it.

I’ve tried synchronizing too.

The Gradle only works if I take out the API I just put in. In case I’m trying to put an API that leaves the images with circle frame.

inserir a descrição da imagem aqui

Follows code:

Build.Radle (Module)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "E**DITADO**"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:cardview-v7:23.3.0'
    compile 'com.android.support:recyclerview-v7:23.3.0'


}

Build.Radle (Application)

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

buildscript {
    repositories {
        jcenter()
    }
    repositories {
        maven {
            url "https://jitpack.io"
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0'
        }



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


allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
  • If Voce has this Voce API it has to be in its folder ".. /app/libs", for this if you are using android studio, go in "project estructure/app" and in the dependencies tab add it by clicking on more and choose the option "file dependecies", if no funfar warns me that jenta tries to solve

  • @Armandomarquessobrinho, I put the API folder where you told me. I put the line there in the dependencies of Gradle, synchronized and the application ran right. But still, there in Gradle is the 3 lines in red, as in the image above. I can ignore ?

  • In case it does not need to have the library, since it is using the dependency by Maven. You put the mouse on top to see the error?

  • @Vitorhenrique I tried to run now and the same error appeared in Gradle. As in the image above.

  • Did you check if Gradle is not offline? I had a similar problem (with another lib) because of this. Check in SETTINGS -> BUILD -> GRADLE if you have marked offline, uncheck and restart AS

  • @Marcelamelo I checked now and Global Gradle Settings > Offline work is unchecked. =\

  • Make sure it’s added: repositories {
 mavenCentral()
} in his build.gradle

  • Check also on your other build.gradle (what is related to your project) if you have allprojects {
 repositories {
 jcenter()
 }
}

  • @Vitorhenrique put the image in the question. It’s all right.

  • Put your two build.gradlecomplete, but copy and paste here and insert them into the code tag for us to analyze better.

  • @Vitorhenrique I can’t put the code here. Exceed the limit. Prefer I put there in my question ?

  • Yes, edit and ask the question.

  • I put it, but it was very discombobulated. I used the code tag and it still looked like this.

  • 1

    tries to do so ó: creates a new project with a blank Activity and v if it runs, if it runs, Voce erases the build.Radle of that your project and copies the content of the build.Radle of that new project in it, dai vc will add the dependencies step by step, if a problem occurs, try to update your SDK

  • If your build.Radle code is the same as the one you posted there, remove the line appearance: Compile fileTree(dir: 'libs', include: ['*.jar']), as it is duplicated, leave only the first.

  • I think I found the error I’ll post as answer.

  • @Brunoromualdo I removed, and gives the same error. I will try to create a new project, as Armando commented

Show 12 more comments

1 answer

4


In his Build.gradle (Aplicação) pick up the line maven:

buildscript {
   repositories {
       jcenter()
   }
   repositories {
       maven { // Essa linha
          url "https://jitpack.io" // Essa linha
       } // Essa linha
   }
}

And move right down to:

allprojects {
    repositories {
        jcenter()

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

    }
}

  • before performing this procedure, I backed up my project, went back to try to do what you said. And it really worked. Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.