retrorolambda tutorial

when you insert this code into your grad

buildscript { repositories { mavenCentral() } dependencies { classpath 'me.tatarka:gradle-retrolambda:3.2.5' ******************** } } // Required because retrolambda is on maven central repositories { mavenCentral() } apply plugin: 'com.android.application' //or apply plugin: 'java' apply plugin: 'me.tatarka.retrolambda' 

In line with ************ I get

 Error:(53, 0) Cannot change dependencies of configuration ':app:classpath' after it has been resolved. <a href="openFile:C:\Users\JulianDC\Desktop\restaurant\app\build.gradle">Open File</a> 

I believe that new grad as they say, help me figure out why it gives this error?

full hail:

 //noinspection GradleDynamicVersion apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "eatgid.com.restaurant" minSdkVersion 15 targetSdkVersion 19 versionCode 1 versionName "1.0" /* jackOptions { enabled true }*/ } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { targetCompatibility 1.8 sourceCompatibility 1.8 } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:cardview-v7:23.4.0' compile 'com.android.support:recyclerview-v7:23.4.0' compile 'de.hdodenhof:circleimageview:1.2.2' compile 'com.mcxiaoke.volley:library:1.0.15' compile 'com.squareup.retrofit2:retrofit:2.0.1' compile 'com.squareup.retrofit2:converter-gson:2.0.1' compile 'com.squareup.retrofit2:adapter-rxjava:2.0.1' compile 'io.reactivex:rxandroid:1.1.0' compile 'io.reactivex:rxjava:1.1.0' } buildscript { repositories { mavenCentral() } dependencies { classpath 'me.tatarka:gradle-retrolambda:3.2.5' } } apply plugin: 'me.tatarka.retrolambda' apply plugin: 'java' // Required because retrolambda is on maven central repositories { mavenCentral() } } 

    2 answers 2

    In Android Studio, you have 2 files build.gradle:

    The first is the file for the build.gradle project (Project: project-name) and we place the lines here:

     buildscript { repositories { mavenCentral() } dependencies { classpath 'me.tatarka:gradle-retrolambda:3.2.5' } } // Required because retrolambda is on maven central repositories { mavenCentral() } 

    Example:

     // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url "https://plugins.gradle.org/m2/"} } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7' classpath "gradle.plugin.me.tatarka:gradle-retrolambda:3.2.4" classpath 'com.google.gms:google-services:2.0.0-alpha3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } } task clean(type: Delete) { delete rootProject.buildDir } 

    The second is the file for the build.gradle module (Module: module-name). Here we place the lines:

      apply plugin: 'com.android.application' //or apply plugin: 'java' apply plugin: 'me.tatarka.retrolambda' 

    and

     android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } 

    Example:

     apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' apply plugin: 'me.tatarka.retrolambda' android { compileSdkVersion 23 buildToolsVersion "23.0.3" // data binding dataBinding { enabled = true } defaultConfig { applicationId "" minSdkVersion 15 targetSdkVersion 23 versionCode 23 versionName "1" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { // for retrolambda sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { // dependencies ... } 
    • sorry about this in the tutorial - Julian Del Campo

    I just removed the apply plugin: 'me.tatarka.retrolambda' line from the module level gradle and it worked