Davood
Davood

Reputation: 5645

How to remove all dependencies on android studio?

I have no internet connection on my machine (because of some reasons) and i want to use Android studio(3) on it with no dependency to the internet.

I Created a very simple (default) App but get lots of errors, I changed the gradle to the local and remove/set offline work option but nothing worked.

Errors:

Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could 
not resolve com.android.support:appcompat-v7:26.+.
<a href="openFile:C:/MyApplication/app/build.gradle">Open File</a><br><a 
href="Unable to resolve dependency for 
&#39;:app@debug/compileClasspath&#39;: Could not resolve 
com.android.support:appcompat-v7:26.+.">Show Details</a>

 Error:Unable to resolve dependency for 
':app@debugUnitTest/compileClasspath': Could not resolve 
com.android.support:appcompat-v7:26.+.
<a href="openFile:C:/MyApplication/app/build.gradle">Open File</a><br><a 
href="Unable to resolve dependency for 
&#39;:app@debugUnitTest/compileClasspath&#39;: Could not resolve 
com.android.support:appcompat-v7:26.+.">Show Details</a>

Error:Unable to resolve dependency for ':app@release/compileClasspath': 
Could not resolve com.android.support:appcompat-v7:26.+.
<a href="openFile:C:/MyApplication/app/build.gradle">Open File</a><br><a 
href="Unable to resolve dependency for 
&#39;:app@release/compileClasspath&#39;: Could not resolve 
 com.android.support:appcompat-v7:26.+.">Show Details</a>

Error:Unable to resolve dependency for 
':app@releaseUnitTest/compileClasspath': Could not resolve 
com.android.support:appcompat-v7:26.+.
<a href="openFile:C:/MyApplication/app/build.gradle">Open File</a><br><a 
href="Unable to resolve dependency for 
&#39;:app@releaseUnitTest/compileClasspath&#39;: Could not resolve 
com.android.support:appcompat-v7:26.+.">Show Details</a>

build.gradle(app):

apply plugin: 'com.android.application'

   android {
    compileSdkVersion 26
    defaultConfig {
    applicationId "com.example.administrator.myapplication"
    minSdkVersion 23
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
       'proguard-rules.pro'
    }
}
 }

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.+'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

 }

build.gradle(project):

buildscript {

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


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

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

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

Upvotes: 0

Views: 1409

Answers (1)

Henry
Henry

Reputation: 17851

For the first time you need to be connected to the internet so that all your dependencies could be fetched. Once that's done, you no longer need the internet.

But if you try building again, Android Studio (gradle) will still try to connect to internet to refresh the dependencies. If you can't be online then you need to tell Android Studio (i.e, gradle) to work offline.

Go to Android Studio's Preferences -> Build, Execution, Deployment -> Offline Work

Turn this option on and gradle will start to work offline.

Note: com.android.support:appcompat-v7:26.+. won't really work here. You need to mention the specific artifact id and not +.

Upvotes: 1

Related Questions