Aovin Mahmud
Aovin Mahmud

Reputation: 214

Android Studio failed for task ':app:compileDefaultFlavorDebugJavaWithJavac

I am using the android studio version 3.1. I am working with youtube Api project. and had added some dependency in the gradle. After sysc it's shows everything oke and fresh. but when i go to run the application it show the error below. I have changed the compileSdkVersion and tried other ways to fix that. Thanks in advance.

Error

org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:compileDefaultFlavorDebugJavaWithJavac'.

Build.grable

buildscript {
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
    }
}
apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 25
    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            proguardFile getDefaultProguardFile('proguard-android.txt')
        }
    }
    productFlavors {
        defaultFlavor {
            proguardFile 'proguard-rules.txt'
        }
    }
    flavorDimensions "default"
}
allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}
dependencies {
    implementation 'com.android.support:cardview-v7:25.2.0'
    implementation 'com.android.support:recyclerview-v7:25.2.0'
    implementation 'com.android.support:appcompat-v7:25.2.0'

    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.apis:google-api-services-youtube:v3-rev182-1.22.0'
    implementation 'com.google.http-client:google-http-client-android:1.20.0'
    implementation 'com.google.api-client:google-api-client-android:1.20.0'
    implementation 'com.google.api-client:google-api-client-gson:1.20.0'

    implementation 'com.github.PierfrancescoSoffritti:AndroidYouTubePlayer:7.0.0'
}

Upvotes: 1

Views: 120

Answers (3)

Paraskevas Ntsounos
Paraskevas Ntsounos

Reputation: 1777

Try this code (app level grandle):

buildscript {
    repositories {
        maven { url "https://jitpack.io" }
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
        jcenter()
        google()
    }
}

And project level grandle:

buildscript {
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}
apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 27
    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            proguardFile getDefaultProguardFile('proguard-android.txt')
        }
    }
    productFlavors {
        defaultFlavor {
            proguardFile 'proguard-rules.txt'
        }
    }
    flavorDimensions "default"
}
allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}
dependencies {
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'

    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.apis:google-api-services-youtube:v3-rev182-1.22.0'
    implementation 'com.google.http-client:google-http-client-android:1.20.0'
    implementation 'com.google.api-client:google-api-client-android:1.20.0'
    implementation 'com.google.api-client:google-api-client-gson:1.20.0'

    implementation 'com.github.PierfrancescoSoffritti:AndroidYouTubePlayer:7.0.0'
}

Upvotes: 2

Roy Danu
Roy Danu

Reputation: 1

I just found that there are bugs like this in Android Studio 3.1, pls try follow this link

Upvotes: 0

Roy Danu
Roy Danu

Reputation: 1

Have you tried restarting android studio? or have you try cleaning / re-build the project? And pls also try to go to file -> invalidate caches / restart and then press that and press invalidate caches and restart.

Upvotes: 0

Related Questions