skip to Main Content

i am trying to import network library , but android studio shows up with this meessage:ERROR: Unable to resolve dependency for ‘:app@debug/compileClasspath’: Could not resolve com.amitshekhar.android:android-networking:1.0.2.

here is the build.gradle:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.example.myfaild"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.amitshekhar.android:android-networking:1.0.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

when I import it into activity.java like below

Code:

import com.androidnetworking.AndroidNetworking;
import com.androidnetworking.common.Priority;
import com.androidnetworking.error.ANError;
import com.androidnetworking.interfaces.JSONArrayRequestListener;

there are some errors

1) Cannot resolve symbol 'androidnetworking'
2) Cannot resolve symbol 'AndroidNetworking'
3) Cannot resolve symbol 'Priority'
4) Cannot resolve symbol 'JSONObjectRequestListener'
5) Cannot resolve symbol 'ANError'

2

Answers


  1. The library is old and wasn’t migrated to the Maven Central repository, since JCenter was deprecated.

    You need to use it from Jitpack repository:

    1. Add it in your root build.gradle at the end of repositories:
    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
    
    1. Add the dependency to your app build.gradle:
    dependencies {
        implementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking:v1.0.2'
    }
    

    Enjoy!

    Login or Signup to reply.
  2. I think I may have found the solution for the same you have write this in your Setting.gradel file
    maven { url ("https://jcenter.bintray.com") }

    below the mavenCentral()line and make sure to add the above code to both the places as there you can see two mavenCentral() line in that file

    and add the below line in your gradel.properties
    android.enableJetifier=true

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search