Search code examples
androidcordovaandroid-studioandroid-gradle-plugincordova-8.0.0

error: cannot find symbol Build.VERSION_CODES.KITKAT


  
.../platforms/android/app/src/main/java/com/tenforwardconsulting/cordova/BackgroundGeolocationPlugin.java:563: error: cannot find symbol
    @TargetApi(Build.VERSION_CODES.KITKAT)
                                  ^
  symbol:   variable KITKAT
  location: class VERSION_CODES

.../platforms/android/app/src/main/java/com/redskyit/mobile/common/RMCActivity.java:79: error: cannot find symbol
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                                                      ^
  symbol:   variable FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
  location: class LayoutParams

I get these + 100s of other similar errors (all cannot find symbol errors).

I am migrating a project to cordova 8. Cordova 8 has changed the android project around quite a bit and I am working through the various issues this has presented. I am at the stage where it starts to compile, but fails with these errors.

The top level build.gradle looks like this

allprojects {
  repositories {
    jcenter()
    maven {
      url "https://maven.google.com"
    }
  }
  //This replaces project.properties w.r.t. build settings
  project.ext {
    defaultBuildToolsVersion="25.0.2" //String
    defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
    defaultTargetSdkVersion=26 //Integer - We ALWAYS target the latest by default
    defaultCompileSdkVersion=26 //Integer - We ALWAYS compile with the latest by default
  }
}

task clean(type: Delete) {
  delete rootProject.buildDir
}

The app\build.gradle has these in it (along with much more)

buildscript {
  repositories {
    mavenCentral()
    jcenter()
    maven {
        url "https://maven.google.com"
    }
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
  }
}

...

dependencies {
  implementation fileTree(dir: 'libs', include: '*.jar')
  // SUB-PROJECT DEPENDENCIES START
  implementation(project(path: ":CordovaLib"))
  compile "com.google.android.gms:play-services-location:+"
  compile "com.android.support:support-v4:26+"
  compile "com.android.support:support-v4:24.1.1+"
  compile "com.google.gms:google-services:+"
  compile "com.google.android.gms:play-services-tagmanager:+"
  compile "com.google.firebase:firebase-core:+"
  compile "com.google.firebase:firebase-messaging:+"
  compile "com.google.firebase:firebase-crash:+"
  compile "com.google.firebase:firebase-config:+"
  // SUB-PROJECT DEPENDENCIES END
}

I am unfamiliar with android studio projects and gradle so really don't know where to begin looking. Im thinking it's a missing dependancy or something along those lines.


Solution

  • I eventually tracked this down to some dependencies defined by a plugin, one that I had forked. The dependencies were:-

    dependencies {
      compile 'com.github.tony19:logback-android-core:1.1.1-6'       
      compile 'com.github.tony19:logback-android-classic:1.1.1-6'        
      compile 'org.slf4j:slf4j-api:1.7.21'
    }
    

    The fix was to exclude some dependencies of logback-android-classic as follows:

    dependencies {
      compile 'com.github.tony19:logback-android-core:1.1.1-6'       
      compile('com.github.tony19:logback-android-classic:1.1.1-6') {
        exclude group: 'com.google.android', module: 'android'
      }
      compile 'org.slf4j:slf4j-api:1.7.21'
    }