Gradle 项目同步失败。基本功能 - 在 Android Studio 2.2 上失败

Gradle project sync failed. Basic functionality - failed on Android Studio 2.2

我有 Android Studio 2.2 版,当我打开一个新项目时,它在“消息”选项卡中显示:

Error:C:\Users\Rooprai.gradle\caches.14.1\scripts-remapped\settings_4a7gjv1r4bbxs9f9pza41diyjejwtyixtds2dlx9q4hqm4iap\cp_settings57408229\cache.properties (The system cannot find the file specified).

屏幕顶部显示:

Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.

构建 Gradle:

  // Top-level build file where you can add configuration options common to all sub-projects/modules.

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

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

allprojects { repositories { jcenter() } }

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

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

请帮忙,activity_main.xml 不工作。

进入目录\Users\user\.gradle\caches.x.

您会发现目录脚本和脚本重新映射。保留它们的备份,然后从目录中删除它们。

重试 gradle 同步。它应该可以工作,因为它将生成新的缓存文件。

希望这对您有所帮助。谢谢。

加入你的build.gradle

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

同步 gradle 然后清理并重建 project.it 将起作用