Home > Software design >  Parameter specified as non-null is null: method com.android.build.gradle.internal.dsl.BaseAppModuleE
Parameter specified as non-null is null: method com.android.build.gradle.internal.dsl.BaseAppModuleE

Time:04-14

I have taken over an ex-employees project and I have been trying to make it run since past two days. However, the error I got today took a complete day but is still unsolvable. I have been getting parameter specified as non null is null for compileSdkVersion in build.gradle of one of the sub projects. The main build.gradle has the required Sdk versions specified but this is still throwing error.

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
        jcenter()

    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.25.1'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))


android {
    signingConfigs {
        config {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    packagingOptions {
        exclude 'META-INF/rxjava.properties'
    }
    dataBinding {
        enabled = true
    }
    compileSdkVersion compileSdk
    defaultConfig {
        applicationId "com.cleanaway.driversapp"
        minSdkVersion minSdk
        targetSdkVersion targetSdk
        multiDexEnabled true
        
        versionCode 108400
        versionName "1.84.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        signingConfig signingConfigs.config
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }
    buildTypes {
        debug {
            // Disable fabric build ID generation for debug builds
            ext.enableCrashlytics = false
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    flavorDimensions "product", "mode"
    productFlavors {
        mock {
            applicationIdSuffix = ".mock"
            dimension "mode"
        }
        dev {
            applicationIdSuffix = ".dev"
            dimension "mode"
        }
        prod {
            dimension "mode"
        }
        demo {
            applicationIdSuffix = ".demo"
            dimension "product"
        }
        cleanaway {
            dimension "product"
        }
    }
}

repositories {
    maven { url 'https://maven.fabric.io/public' }
    jcenter()
    //google()
}

kapt {
    correctErrorTypes = true
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation files('libs/evercam-stepglobal-1.0.jar')
    implementation project(':ipcameracontrol')
    implementation project(':cleanawaymodel')
    implementation project(':vehicleapi')
    implementation project(':networkutilities')
    implementation project(':telogisapi')

    //Crashlytics
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
    implementation('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true;
    }

    // Android/Google
    implementation "com.android.support:appcompat-v7:$rootProject.libAndroidSupportVersion"
    implementation "com.android.support:design:$rootProject.libAndroidSupportVersion"
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation "com.android.support:recyclerview-v7:$rootProject.libAndroidSupportVersion"
    implementation "com.android.support:cardview-v7:$rootProject.libAndroidSupportVersion"
    implementation "androidx.appcompat:appcompat:1. "

    //Firebase
    implementation "com.google.firebase:firebase-core:$rootProject.firebaseVersion"
    implementation "com.google.firebase:firebase-storage:$rootProject.firebaseVersion"
    implementation "com.google.firebase:firebase-auth:$rootProject.firebaseVersion"

    // Android architecture components
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    kapt "android.arch.lifecycle:compiler:1.1.1"
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    kapt "android.arch.persistence.room:compiler:1.1.1"
    implementation "android.arch.persistence.room:rxjava2:1.1.1"
    androidTestImplementation "android.arch.core:core-testing:1.1.1"
    implementation 'android.arch.lifecycle:reactivestreams:1.1.1'

    // Kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$rootProject.kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$rootProject.kotlin_version"

    // Data binding
    kapt 'com.android.databinding:compiler:3.1.4'

    // Crash reporting
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }

    // Injection
    implementation "com.google.dagger:dagger:$rootProject.daggerVersion"
    implementation "com.google.dagger:dagger-android:$rootProject.daggerVersion"
    implementation "com.google.dagger:dagger-android-support:$rootProject.daggerVersion"
    kapt "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
    kapt "com.google.dagger:dagger-android-processor:$rootProject.daggerVersion"
    kapt  "com.google.dagger:dagger-android-support:$rootProject.daggerVersion"

    // Data
    implementation "com.google.code.gson:gson:$rootProject.libGsonVersion"
    implementation "com.squareup.retrofit2:converter-gson:$rootProject.gsonConverterVersion"
    implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
    implementation "com.squareup.okhttp3:okhttp:$rootProject.libOkHttp3Version"
    implementation "com.squareup.picasso:picasso:$rootProject.libPicassoVersion"
    implementation('org.simpleframework:simple-xml:2.7.1') {
        exclude module: 'stax-api'
        exclude module: 'stax'
        exclude module: 'xpp3'
    }

    // Reactive library version 1
    implementation "io.reactivex:rxjava:$rootProject.libRxJavaVersion"
    implementation "io.reactivex:rxandroid:$rootProject.libRxAndroidVersion"

    // Reactive library version 2
    implementation 'io.reactivex.rxjava2:rxjava:2.1.1'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation "io.reactivex.rxjava2:rxkotlin:2.0.0"
    implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'

    // Memory leak testing
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'

    // Unit tests
    testImplementation 'junit:junit:4.12'
    testImplementation "org.robolectric:robolectric:$rootProject.libRobolectricVersion"

    // Instrumentation tests
    androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support.test.espresso:espresso-idling-resource:3.0.2'
    androidTestImplementation 'com.android.support.test.espresso.idling:idling-concurrent:3.0.2'

    // Mocking
    testImplementation 'org.mockito:mockito-core:2.9.0'

    // Logging
    implementation 'com.jakewharton.timber:timber:4.6.0'

    // Time and Date
    implementation 'joda-time:joda-time:2.9.9'
    implementation files('libs/commons-lang-2.6.jar')
}

gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xmaxerrs" << "500" // or whatever number you want
    }
}

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

This is the code of sub build.gradle.

This is the error message I am getting.

  • Where: Build file 'D:\xxx\cleanaway-myview-app\driversapp\build.gradle' line: 39
  • What went wrong: A problem occurred evaluating project ':driversapp'.

Parameter specified as non-null is null: method com.android.build.gradle.internal.dsl.BaseAppModuleExtension.compileSdkVersion, parameter version

CodePudding user response:

The following fields don't make sense:

compileSdkVersion compileSdk
minSdkVersion minSdk
targetSdkVersion targetSdk

I think someone misunderstood the instruction that compileSdkVersion can be replaced with compileSdk. Because you need to put actual numbers there, for example

compileSdkVersion 31
minSdkVersion 28
targetSdkVersion 31

which would be the old way. The new way

compileSdk 31
minSdk 28
targetSdk 31

not sure if the old way still works. In any case you need to put actual numbers there. Which ones you want for your project is up to you. compileSdk and targetSdk it's usually best to use the highest possible and minSdk the minimum android version you want to support.

See also What is difference between compileSdk and compileSdkVersion in android studio gradle script when using jetpack compose

  • Related