Error in support lib after room persistence

你。 提交于 2019-12-24 07:51:14

问题


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'

回答1:


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


来源:https://stackoverflow.com/questions/47734482/error-in-support-lib-after-room-persistence

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!