2016-10-16 35 views
1

在幾周/幾個月後(非常忙於工作)第一次打開較舊的項目後,Android Studio要求我升級到最新的gradle插件。Android Studio:在Gradle更新後恢復項目備份

Gradle Upgrade promt

我真的沒有想到它是什麼,然後點擊「更新」。 Gradle完成更新和同步後,我發現我的大部分佈局和java類文件都消失了。他們只是走了。

但是,在我的項目目錄中出現了一個名爲「projectFilesBackup」的文件夾。我認爲恢復此文件夾中包含的備份可能會丟失我丟失的文件。

projectFilesBackup Folder

所以我的問題是:有誰知道我怎麼居然告訴過Android Studio恢復到備份?它只包含一個包含「workspace.xml」的「.idea」文件夾。任何幫助將不勝感激。

我已經嘗試使用「本地歷史記錄」撤消Gradle Update當天所做的任何更改,詳見this SO post

編輯: 根據要求我的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.1' 
 
     classpath "io.realm:realm-gradle-plugin:1.2.0" 
 

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

apply plugin: 'com.android.application' 
 
apply plugin: 'realm-android' 
 

 
android { 
 
    compileSdkVersion 24 
 
    buildToolsVersion "24.0.1" 
 

 
    defaultConfig { 
 
     applicationId "com.tools.awesome.cs.grademanager" 
 
     minSdkVersion 23 
 
     targetSdkVersion 24 
 
     versionCode 1 
 
     versionName "1.0" 
 
    } 
 
    buildTypes { 
 
     release { 
 
      minifyEnabled false 
 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
 
     } 
 
    } 
 
} 
 

 
dependencies { 
 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
 
    testCompile 'junit:junit:4.12' 
 
    compile 'com.android.support:appcompat-v7:24.2.0' 
 
    compile 'com.android.support:design:24.2.0' 
 
    compile 'io.realm:android-adapters:1.3.0' 
 
}

+0

發佈你的兩個build.gradle文件。 – fluffyBatman

+0

感謝您的評論。我已將這些文件編輯到我原來​​的文章中。 – user4370243

+0

你的build.gradle文件配置對我來說看起來不錯。如果你啓動一個gradle sync,它說什麼? – fluffyBatman

回答

0

更改領域,gradle這個-插件最日一個,看看是否再次提出文件。

classpath "io.realm:realm-gradle-plugin:2.0.2" 
+0

不幸的是,它沒有。不過謝謝你的努力! – user4370243

+0

我有一個項目gradle插件更新幾分鐘前,它很好。根據我的經驗,這個更新只會在依賴不符時遇到麻煩。嘗試修補一下你現有的依賴關係。它可能解決你的問題。 – fluffyBatman