0

I am using a project where Dagger2 dependency is added . My build.gradle is as follows :

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
}

apply plugin: 'com.android.library'

def android_support_version = '25.1.1'

configurations {
    javadocDeps
}

dependencies {
    compile 'com.android.support:support-annotations:' + android_support_version
    compile 'com.android.support:support-v4:' + android_support_version

    javadocDeps 'com.android.support:support-annotations:' + android_support_version
    javadocDeps 'com.android.support:support-v4:' + android_support_version
    provided 'javax.annotation:jsr250-api:1.0'
}

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 25
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
        test {

        }
    }
    productFlavors {
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '3.1'
}

But when I want to sync gradle , then I am getting this error :

Error:(19, 13) Failed to resolve: javax.annotation:jsr250-api:1.0
<a href="disable.gradle.offline.mode">Disable offline mode and sync project</a><br><a href="openFile:F:/Android Project/stripe/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

I have seen this tutorial but could not get the solution . Dagger2 dependency - Gradle

How can I solve this error ? Please help me .

Edited Question :

I have offline work checkbox unchecked . Here is the screenshot .

enter image description here

Community
  • 1
  • 1
Christopher Marlowe
  • 2,098
  • 6
  • 38
  • 68

2 Answers2

1

Your gradle is offline, cannot sync your project.

Go to File -> Settings.

And open the 'Build,Execution,Deployment',Then open the 'Build Tools' -> 'Gradle'.

Then uncheck "Offline work" on the right.

Click the 'OK' button.

Then Sync the Project.

Edit

You change to:

compile 'javax.annotation:jsr250-api:1.0'
RoShan Shan
  • 2,924
  • 1
  • 18
  • 38
0

Your Gradle is in offline mode. Toggle that off and you will be able to download the required components.

Assuming android studio open up the Gradle menu on the right and it is the second icon from the right in the toolbar

Stephen
  • 4,041
  • 22
  • 39
  • It is already unchecked . But I am getting the same error . please see the edited question . – Christopher Marlowe Mar 13 '17 at 06:15
  • Hmmm. Not sure then. It seems Android Studio is out of sync with Gradle. Assuming there is an active internet connection on your machine maybe just try restarting Android studio? It that does not work try cleaning and rebuilding your project? Build > Clean Project. If not that then maybe File > Invalidate Caches and Restart (This may take some time.) – Stephen Mar 13 '17 at 06:19