android studio: How to set compatible versions in gradle

I have recently updated android studio. and updated other plugins, now everything is missed up even if I return to previous gradle file.

my app is using google maps and directions, still using extends of fragment

project structure looks as following:

project structure

Gradle version: 4.1

Android Plugin version: 3.0.1

Android Plugin repo: jcenter, maven { url '' name 'Google' }

and the gradle file:

    apply plugin: ''

    android {
        compileSdkVersion 27
        buildToolsVersion "27.0.3"
        defaultConfig {
            applicationId "com.***"
            minSdkVersion 16
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), ''
        productFlavors {

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile ''
        compile ''
        testCompile 'junit:junit:4.12'

in one activity I have:


I see the following error on:

   compile '' 

All libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 25.2.0. Examples include and less... (Ctrl+F1) There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

I have also tried running:

    ./gradlew -q dependencies app:dependencies --configuration compile

it failed on JAVA_HOME, after I set it by: set JAVA_HOME="C:.../jdk***"

It did not work complaining on JAVA_HOME again

can anyone help please ? by telling me how to fix such problems or how can I fix this one ?

Thanks a lot!