在Android Studio中构建Gradle时出现问题

b5buobof  于 2023-08-06  发布在  Android
关注(0)|答案(1)|浏览(165)

我几乎在大多数项目中都遇到了这个问题,当我想将现有的项目带到Android时,我总是遇到这样的问题,我应该怎么做才能永久解决这个问题?
谷歌已经为伊朗人禁用了这一部分,如果我想事先在Android Studio中导入任何项目,我必须连接到可以导入使用的库的VPN,有没有一种方法可以在不连接VPN的情况下做到这一点,下载库?我可以手动下载一个文件夹中的所有库,然后把所有的网址在项目中,因为它很难连接到VPN,如果它这样做的速度是超级慢。或者是否有其他可以在Android Studio设置中更改的地址,例如Visual Studio中的Nuget,您可以在其中更改接收库的地址并从该地址下载库?

错误文本:

Could not resolve all artifacts for configuration ':classpath'.
    Could not find gradle-4.2.2.jar (com.android.tools.build:gradle:4.2.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.2.2/gradle-4.2.2.jar
    Could not find builder-4.2.2.jar (com.android.tools.build:builder:4.2.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/4.2.2/builder-4.2.2.jar
    Could not find aaptcompiler-4.2.2.jar (com.android.tools.build:aaptcompiler:4.2.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/aaptcompiler/4.2.2/aaptcompiler-4.2.2.jar
    Could not find bundletool-1.1.0.jar (com.android.tools.build:bundletool:1.1.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/1.1.0/bundletool-1.1.0.jar
    Could not find sdk-common-27.2.2.jar (com.android.tools:sdk-common:27.2.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/sdk-common/27.2.2/sdk-common-27.2.2.jar
    Could not find sdklib-27.2.2.jar (com.android.tools:sdklib:27.2.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/sdklib/27.2.2/sdklib-27.2.2.jar
    Could not find common-27.2.2.jar (com.android.tools:common:27.2.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/common/27.2.2/common-27.2.2.jar
    Could not find protos-27.2.2.jar (com.android.tools.analytics-library:protos:27.2.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/27.2.2/protos-27.2.2.jar
    Could not find core-proto-0.0.8-alpha01.jar (com.google.testing.platform:core-proto:0.0.8-alpha01).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/google/testing/platform/core-proto/0.0.8-alpha01/core-proto-0.0.8-alpha01.jar
    Could not find zipflinger-4.2.2.jar (com.android:zipflinger:4.2.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/zipflinger/4.2.2/zipflinger-4.2.2.jar
    Could not find apksig-4.2.2.jar (com.android.tools.build:apksig:4.2.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/apksig/4.2.2/apksig-4.2.2.jar

字符串

build.Gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.2"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url "https://jitpack.io" }
    }
}

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


的数据

7ajki6be

7ajki6be1#

这是由禁止的HTTP错误(403)引起的。你需要一个VPN或代理来绕过它。
我建议使用HTTP代理,因为Gradle和Android Studio都支持它,并且它不需要复杂的配置就可以工作。
有一个为Android Studio设置HTTP代理的指南。
通常,在配置代理设置后,Gradle会询问您是否也要为Gradle使用相同的代理配置。
否则,如果Gradle不提示,您应该手动执行此操作。在全局 gradle.properties 文件中添加以下行:
第一个月
systemProp.http.proxyPort=[proxy port]

相关问题