2016-03-15 31 views
4

我已經修改了build.gradle升級我的項目,我使用MacOSX上的Android 2.1工作室預覽,這是我的搖籃:升級Android項目使用Java8(compileOptions不能應用於groovy.lang.closure)

build.gradle。

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 'android-N' 
    buildToolsVersion '24.0.0 rc1' 

    defaultConfig { 
     applicationId "com.xxx.xxx" 
     minSdkVersion 21 
     targetSdkVersion 'N' 
     versionCode 1 
     versionName "1.0" 
     jackOptions { 
      enabled true 
     } 

    } 
    compileOptions { 
      sourceCompatibility JavaVersion.VERSION_1_8 
      targetCompatibility JavaVersion.VERSION_1_8 
     } 
    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.0.0-alpha1' 
    compile 'com.android.support:design:24.0.0-alpha1' 
    compile 'com.android.support:support-v4:24.0.0-alpha1' 
    compile 'com.android.support:cardview-v7:24.0.0-alpha1' 
    compile 'com.android.support:recyclerview-v7:24.0.0-alpha1' 
} 

Android Studio中抱怨說,'compileOptions cannot be applied to groovy.lang.closure'

我安裝的工具的SDK的Android N和,跟着Google's instruction正是 Correct JDK pointed to

編輯:它停止了抱怨,但Android的可視化設計使以下錯誤消息:

Android N requires the IDE to be running with Java 1.8 or later 

Install a supported JDK

回答

0

對我來說,應用上述解決方案並沒有解決問題。相反,我不得不去到Android Studio中的設置,並選擇「使用gradle這個包裝」

在Android Studio中進行選擇:

文件\設置\建立,執行,部署\構建工具\搖籃

Mac用戶:過Android Studio \首選項... \建立,執行,部署\構建工具\搖籃)

馬rk:使用默認的Gradle包裝器(默認)

這將在構建文件中刪除所有'不能應用於'(groovy.lang.Closure')警告。

2.Click「文件」,然後選擇「的Invalidate緩存/重新啓動。

+0

沒有工作,請找到另一種解決辦法 – ahitt6345

+0

@Abhijit讓我知道你有哪些機器人工作室版本上 –

+0

的Android 2.1.2工作室工作版本 – ahitt6345