Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find method compileOptions() for arguments

Tags:

java

android

The error appears:

Could not find method compileOptions() for arguments [build_88ddjipq2tquhqjwgj0asxwi4$_run_closure3@5ddee9dd] on project ':app' of type org.gradle.api.Project.

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 28
        buildToolsVersion "29.0.0"
        defaultConfig {
            applicationId "com.example.myapplication"
            minSdkVersion 15
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

        implementation 'com.twitter.sdk.android:twitter-core:3.3.0'
        implementation 'com.twitter.sdk.android:tweet-ui:3.3.0'
        implementation 'com.twitter.sdk.android:tweet-composer:3.3.0'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
like image 348
Gorpe Avatar asked Jul 05 '19 09:07

Gorpe


Video Answer


1 Answers

Put compileOptions inside android tag like this :

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

EDIT: To be exact

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
like image 60
Rajat Mehra Avatar answered Sep 28 '22 23:09

Rajat Mehra