Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 建筑项目失败并导致连接重置_Android_Gradle_Android Gradle Plugin_Build.gradle - Fatal编程技术网

Android 建筑项目失败并导致连接重置

Android 建筑项目失败并导致连接重置,android,gradle,android-gradle-plugin,build.gradle,Android,Gradle,Android Gradle Plugin,Build.gradle,我正在从事的项目是很久以前开发的,并且正在成功运行。现在,我想再次访问它并运行它以查看一些结果 当我尝试构建项目时,我收到以下错误和“连接重置”消息 更新的gradle:app: plugins{ id 'com.android.application' } android { compileSdkVersion 30 defaultConfig { applicationId "example.com.thninxnet_00"

我正在从事的项目是很久以前开发的,并且正在成功运行。现在,我想再次访问它并运行它以查看一些结果

当我尝试构建项目时,我收到以下错误和“连接重置”消息

更新的gradle:app

plugins{
    id 'com.android.application'
}
android {
    compileSdkVersion 30

    defaultConfig {
        applicationId "example.com.thninxnet_00"
        minSdkVersion 14
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    buildToolsVersion "30.0.2"

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:23.4.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation files('libs/universal-image-loader-1.9.5.jar')
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

        // 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
}
connection reset
更新的gradle:project

plugins{
    id 'com.android.application'
}
android {
    compileSdkVersion 30

    defaultConfig {
        applicationId "example.com.thninxnet_00"
        minSdkVersion 14
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    buildToolsVersion "30.0.2"

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:23.4.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation files('libs/universal-image-loader-1.9.5.jar')
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

        // 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
}
connection reset
更新错误

plugins{
    id 'com.android.application'
}
android {
    compileSdkVersion 30

    defaultConfig {
        applicationId "example.com.thninxnet_00"
        minSdkVersion 14
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    buildToolsVersion "30.0.2"

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:23.4.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation files('libs/universal-image-loader-1.9.5.jar')
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

        // 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
}
connection reset

无法说明后面的错误,但生成过程中的连接重置错误有时是由于不稳定的internet连接造成的。并且,这种不稳定的internet连接可能是同步失败和后面错误的原因。

您使用的是
30
compileSdkVersion
targetSdkVersion
ur
buuldToolsVersion
25
,因此为了兼容性,请更换:

buildToolsVersion "25.0.1"
与:

并替换:

apply plugin: 'com.android.application'
与:

并向我们通报结果

编辑: 另外,
使缓存无效

文件->无效缓存->无效并重新启动

编辑2:

gradle
无法连接到
服务器
以检索所需的
时,可能会发生连接重置,因此您可以执行以下操作:

  • 检查您的
    internet
    连接是否稳定,可能是因为internet连接不稳定
  • 如果您有一个稳定的internet连接,那么问题可能是到
    gradle服务器的连接可能被阻塞,所以请使用VPN(它会更改您的IP),然后再次尝试重建您的项目
  • 另一个问题可能是您的
    防病毒
    软件或
    防火墙
    可能阻止
    Android Studio
    ,因此请确保禁用防火墙和防病毒软件并重建项目
  • google()
    已添加到Gradle v4中,因此请确保您使用的是正确的Gradle插件版本

    请尝试使用更新您的项目级Gradle文件

    classpath 'com.android.tools.build:gradle:3.5.3'
    
    并在您的
    gradle wrapper.properties
    中添加这一行

    distributionUrl=\
      https\://services.gradle.org/distributions/gradle-4.1-x-all.zip
    
    同样,在旧版本的Android Studio中,您可以使用
    maven
    结构使用
    google()
    的等价物,但请尝试将其放在
    jcenter()之后


    您可能还需要在
    所有项目.存储库
    下添加
    google()
    。我想您已经从
    github
    中提取了它。Git不会保存您的安全文件。这意味着当您将项目推送到github时,一些源代码会自动删除。根据您给出的图片,问题在于您的依赖关系(对实施有争议)。按照@maurice所说的去做。我想有些库丢失了,请重新尝试同步。@maurice实际上现在我收到了上面提到的错误。你明白了吗?@LetsamrIt你在版本控制方面遇到了问题。因为,那个项目是旧版本的,现在你正在使用更新版本的
    jar
    和一些internet库。我不知道如何解决这个问题。那么,对不起!您将google()放在jcenter()之上,
    buildscript
    allprojects
    我更新了问题。我按照您建议的步骤进行了操作,但在更新的问题中收到了错误帖子。请阅读it@LetsamrIt我编辑了我的答案,看看吧。