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

我只是一个虾纸丫 提交于 2019-12-13 07:46:16

问题


I have Android Studio version 2.2 and when I open a new project, it says in the Messages tab:

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

At the top of the screen it says:

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

Build 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' } }

Please help, the activity_main.xml won't work.


回答1:


Go to the directory \Users\user\.gradle\caches\2.x.

You will find the directories scripts & scripts-remapped. Keep a backup of them and then delete them from the directory.

Retry gradle sync. It should work as it will generated new cache files.

Hope this helps. Thanks.




回答2:


add in your build.gradle

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

Sync gradle then clean and rebuild project.it will work



来源:https://stackoverflow.com/questions/41499863/gradle-project-sync-failed-basic-functionality-failed-on-android-studio-2-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!