Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio refactor revert all lambdas and other Java 8 features

I have an Android library project with

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

It uses a lot of lambdas, try with resources and etc.

How could I downgrade sourceCompatibility & targetCompatibility to Java 1.6 instead?

Is there such functionality built in Android Studio IDE?

like image 291
Olexii Muraviov Avatar asked Dec 13 '17 15:12

Olexii Muraviov


1 Answers

You can replace the lambda by placing the cursor inside the -> and pressing Alt + Enter then select "Replace lambda with..."

enter image description here


You can do it on an entire file by expanding the menu and selecting "Fix all..."

enter image description here


You can do it on the whole project by following the above steps, but instead click "Run inspection on..."

enter image description here

Select "Whole project"

enter image description here

Once the inspection finishes, right click on the "Lambda can be replaced..." section and select "Replace lambda with..."

enter image description here

like image 189
Chris Stillwell Avatar answered Sep 27 '22 19:09

Chris Stillwell