无法解析/无法解析 - com.amitshekhar.android:android-networking:1.0.2

问题描述 投票:0回答:3

我正在尝试导入网络库,但 android studio 显示此消息:错误:无法解析 ':app@debug/compileClasspath' 的依赖关系:无法解析 com.amitshekhar.android:android-networking:1.0.2 .

这是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'
}

当我将其导入到 Activity.java 时,如下所示

代码:

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

有一些错误

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'
java android android-studio build.gradle android-library
3个回答
4
投票

该库很旧,没有迁移到 Maven 中央存储库,因为 JCenter 已被弃用。

您需要从 Jitpack 存储库使用它:

  1. 将其添加到存储库末尾的根 build.gradle 中:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. 将依赖项添加到您的应用程序 build.gradle 中:
dependencies {
    implementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking:v1.0.2'
}

享受吧!


1
投票

我想我可能已经找到了与您在 Setting.gradel 文件中写入的相同的解决方案

maven { url ("https://jcenter.bintray.com") }

mavenCentral() 行下方,并确保将上述代码添加到这两个位置,因为您可以在该文件中看到两行 mavenCentral()

并在您的 gradel.properties 中添加以下行

android.enableJetifier=true 


0
投票

只需将此代码添加到 gradle 文件 (settings.gradle.kts) 的两个位置即可:

 maven { url = uri("https://jcenter.bintray.com") }

它应该看起来像这样:

 pluginManagement {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jcenter.bintray.com") }
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jcenter.bintray.com") }
    }
}

rootProject.name = "json data parsing"
include(":app")
© www.soinside.com 2019 - 2024. All rights reserved.