Reputation: 2220
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 .
Upvotes: 0
Views: 2994
Reputation: 2954
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'
Upvotes: 1
Reputation: 4249
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
Upvotes: 0