1

I'm trying to use the library room persistence, with SDK min 16. After I add room persistence in gradle I get the error below: if I take the last 2 lines of depency (from the lib room) compile normal. Help!

 error: cannot access ActivityCompatApi23
public class MainActivity extends AppCompatActivity
       ^
  class file for android.support.v4.app.ActivityCompatApi23 not found
An exception has occurred in the compiler (1.8.0_05). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
    at com.sun.tools.javac.comp.Check$Validator.visitSelect(Check.java:1301)
    at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1891)
    at com.sun.tools.javac.comp.Check$Validator.validateTree(Check.java:1350)
    at com.sun.tools.javac.comp.Check.validate(Check.java:1221)
    at com.sun.tools.javac.comp.Check.validate(Check.java:1218)
....

my gradle is basic:

    compileSdkVersion 25

    defaultConfig {
        applicationId "com.br.xxxx"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 45
        versionName "3.0.2"


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.google.firebase:firebase-core:10.2.6'
    compile 'com.google.firebase:firebase-database:10.2.6'
    compile 'com.google.firebase:firebase-auth:10.2.6'
    compile 'com.google.firebase:firebase-appindexing:10.2.6'
    compile 'com.google.firebase:firebase-config:10.2.6'

    compile 'com.firebaseui:firebase-ui:1.2.0'
    compile 'com.firebase:geofire-java:2.1.1'

    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.github.PhilJay:MPAndroidChart:v2.2.0'
    compile 'com.github.amlcurran.showcaseview:library:5.4.3'
    compile 'com.andkulikov:transitionseverywhere:1.7.4'

    compile 'com.google.android.gms:play-services-maps:10.2.6'
    compile 'com.google.android.gms:play-services-location:10.2.6'


    compile 'com.google.maps.android:android-maps-utils:0.5'

    compile 'com.google.firebase:firebase-storage:10.2.6'

    compile 'com.firebaseui:firebase-ui-storage:0.6.0'
    compile 'com.jsibbold:zoomage:1.1.0'

    compile "android.arch.persistence.room:runtime:1.0.0"
    annotationProcessor "android.arch.persistence.room:compiler:1.0.0"

}
apply plugin: 'com.google.gms.google-services'
Jonas Rotilli
  • 176
  • 1
  • 3
  • 12
  • where is `compile 'com.android.support:appcompat-v7:25.0.2'` in your gradle? you have to add support repo in gradle. – KuLdip PaTel Dec 11 '17 at 12:43
  • and please add `google()` in your project level repository. – KuLdip PaTel Dec 11 '17 at 12:44
  • Even adding compile 'com.android.support:appcompat-v7:25.0.2' and maven {url 'https://maven.google.com'} the problem persists. I created a project from scratch, with no dependency and also with minSdk16Version. I was able to compile with minSdkVersion 20 only. But in the Room documentation there is no such sdk 20 requirement. – Jonas Rotilli Dec 11 '17 at 13:10

1 Answers1

3

I added the issue in Google's Issue Tracker and they replied:

Room depends on 26.1 of support library, which is probably why it is broken because SupportLibrary does not promise interop between versions.

and added:

You cannot fix and match support library versions. Please match whatever highest version you end up needing by your dependencies.

Then the problem is resolved, Room + lib is only supported with version 26.1 + of the library.

My final gradle:

compileSdkVersion 26

    defaultConfig {
        applicationId "com.br.xxxx"

        minSdkVersion 16
        targetSdkVersion 26
        versionCode 45
        versionName "3.0.2"
    }

...

     repositories {
         maven { url 'https://maven.fabric.io/public' }
         maven { url 'https://maven.google.com' } }

     dependencies {
            compile fileTree(include: ['*.jar'], dir: 'libs')
            implementation 'com.android.support:appcompat-v7:26.1.0'

            compile 'com.google.firebase:firebase-core:10.2.6'
            compile 'com.google.firebase:firebase-database:10.2.6'
            compile 'com.google.firebase:firebase-auth:10.2.6'
            compile 'com.google.firebase:firebase-appindexing:10.2.6'
            compile 'com.google.firebase:firebase-config:10.2.6'

            compile 'com.firebaseui:firebase-ui:1.2.0'
            compile 'com.firebase:geofire-java:2.1.1'

            compile 'com.github.bumptech.glide:glide:3.7.0'
            compile 'com.github.PhilJay:MPAndroidChart:v2.2.0'
            compile 'com.github.amlcurran.showcaseview:library:5.4.3'
            compile 'com.andkulikov:transitionseverywhere:1.7.4'

            compile 'com.google.android.gms:play-services-maps:10.2.6'
            compile 'com.google.android.gms:play-services-location:10.2.6'

            compile 'com.google.maps.android:android-maps-utils:0.5'

            compile 'com.google.firebase:firebase-storage:10.2.6'

            compile 'com.firebaseui:firebase-ui-storage:0.6.0'
            compile 'com.jsibbold:zoomage:1.1.0'


            compile "android.arch.persistence.room:runtime:1.0.0"
            annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
}
Jonas Rotilli
  • 176
  • 1
  • 3
  • 12