Gorpe
Gorpe

Reputation: 93

Could not find method compileOptions() for arguments

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
    }

Upvotes: 9

Views: 7518

Answers (2)

Bala Chandra
Bala Chandra

Reputation: 11

apply plugin:'com.android.application'

apply plugin: 'kotlin-android' android { compileSdk 32 defaultConfig { applicationId "com.example.app" minSdk 21 targetSdk 32 versionCode 21 versionName 1 testInstrumentationRunner "androidx.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
}

}

dependencies {

implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.android.support:support-annotations:28.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'

}

Upvotes: 0

Rajat Mehra
Rajat Mehra

Reputation: 1482

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
    }
}

Upvotes: 14

Related Questions