android – "Gradle files have changed since last project sync." message always shows up-ThrowExceptions

Exception or error:

I’m working on an Android Studio project of which I write while constantly move back and forth from laptop to desktop using usb stick. There has been no problem for couple of months I tried this since Android Studio went stable, until today this message keeps showing up no matter how many times I sync the gradle:

Gradle files have changed since last project sync. A project sync may be necessary for the IDE to work properly.

Gradle Console indicates that the build is successful. I also tried cleaning and rebuilding the project, even reinstalling Android Studio, still the message pops out.

What seems to be the problem? Is it not recommended to write a project on multiple Android Studios?

Here’s a look of my build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.simplifyinc.prodigy"
    minSdkVersion 16
    targetSdkVersion 21
    versionCode 1
    versionName "0.3.2"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'de.hdodenhof:circleimageview:1.2.1'
    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
    compile 'net.the4thdimension:audio-wife:1.0.3'
    compile project('libraries:android-crop')
}
How to solve:

each IDE(even if it is the same build number) uses its own metadata. an example would be the location of the Android sdk.when shuffling files between different systems, you would have to make sure that none of the system generated files are copied.
the safest way would be to delete the all the files and folders mentioned in the . gitignore file.
and as in this particular case, the .idea folder.

###

in build.gradle(module:app)
change
build tool,( in my case its 23.0.1)
targetSdkVersion (23) and
in dependency
compile version
(“com.android.support:appcompat-v7:23.1.0”)
to latest
This happens due to gradle updates

*****Check your PC date*****

###

You must check your PC or laptop date and time. Correct your date and time will resolve your issue.

###

The modified date for some of my files were set to a future date/time (still havent figured out the cause). Updating the modified time of each file in the project using touch -mt YYYYMMDDhhmm ./* and then the same for those with a . prefix touch -mt YYYYMMDDhhmm ./.* fixed this for me.

###

this error had happened to me when I changed my computer time carelessly
configer my computer time,and reset the time,this error solved

###

this error happen when android studio 2.3.3 available and i ignore it, upgrade your android studio to 2.3.3

###

For Me Below Steps Worked:

1) Delete .idea folder

2) Delete build folder

3) opened each file mentioned in .ignore with notepad and add a space , remove a space and saved file again. this will not effects the file but the trick is notepad changes the Date modified attribute of file.

enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *