Symoon98
Symoon98

Reputation: 41

Android build.gradle Error: "Cannot invoke method android() on null object"

I tried to change the app's version in build.gradle and when I tried to sync the console shows "Cannot invoke method android() on null object" error (At line 1) and "com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle". If I try to revert to the old changes the error appears the same.

apply plugin: 'com.android.application'android {
compileSdkVersion 29
buildToolsVersion "30.0.1"

defaultConfig {
    applicationId "com.x.y"
    minSdkVersion 16
    targetSdkVersion 29
    versionCode 2
    versionName "1.1"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}}

Upvotes: 2

Views: 4978

Answers (2)

Muhammad Usman
Muhammad Usman

Reputation: 71

not working

Build file 'D:\AndroidData\AnasolProjects\NewFreeDataApp\app\build.gradle' line: 12

A problem occurred evaluating project ':app'.

Cannot invoke method testInstrumentationRunner() on null object

  • Try:

Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is: org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'

Upvotes: 0

laalto
laalto

Reputation: 152817

You're missing a newline.

apply plugin: 'com.android.application'android {

should be

apply plugin: 'com.android.application'
android {

Upvotes: 1

Related Questions