ReActiveAndroid icon indicating copy to clipboard operation
ReActiveAndroid copied to clipboard

Using with AndroidX

Open bhapps opened this issue 6 years ago • 3 comments

ReActiveAndroid Version: Latest

Bug or Feature Request: Bug

Description: Issue with ReActiveAndroid compatibility with AndroidX or SDK Version

AndroidX compileSdkVersion 28 minSdkVersion 21 targetSdkVersion 28

implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.vectordrawable:vectordrawable:1.0.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.0.0'

error when save() error when select()

Attempt to invoke interface method 'java.lang.Object java.util.Map.get(java.lang.Object)' on a null object reference

at com.reactiveandroid.ReActiveAndroid.getDatabaseForTable(ReActiveAndroid.java:118)
        at com.reactiveandroid.ReActiveAndroid.getTableName(ReActiveAndroid.java:186)
        at com.reactiveandroid.query.Select$From.getPartSql(Select.java:181)
        at com.reactiveandroid.query.QueryBase.getSql(QueryBase.java:19)
        at com.reactiveandroid.query.AggregateQueryBase.getAggregateFunctionSql(AggregateQueryBase.java:112)
        at com.reactiveandroid.query.AggregateQueryBase.count(AggregateQueryBase.java:21)

bhapps avatar Jul 07 '19 06:07 bhapps

Tested with the below;

compileSdkVersion 28
    defaultConfig {
        applicationId "com.myapp.myapplication"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

classpath 'com.android.tools.build:gradle:3.4.1'

get the below error ...

Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.Map.get(java.lang.Object)' on a null object reference
        at com.reactiveandroid.ReActiveAndroid.getDatabaseForTable(ReActiveAndroid.java:118)
        at com.reactiveandroid.ReActiveAndroid.getModelAdapter(ReActiveAndroid.java:149)
        at com.reactiveandroid.Model.getModelAdapter(Model.java:187)
        at com.reactiveandroid.Model.getModelAdapter(Model.java:71)
        at com.reactiveandroid.Model.save(Model.java:39)
        at com.myapp.myapplication.ORMModel.save(ORMModel.java:273)

bhapps avatar Jul 10 '19 08:07 bhapps

I think the issue is related to the android.support Library:

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

As this Library has not been Migrated to AndroidX which uses:

implementation 'androidx.annotation:annotation:1.1.0'

as apposed to the Library using currently

compile 'com.android.support:support-annotations:25.3.1"

bhapps avatar Jul 10 '19 09:07 bhapps

@ImangazalievM

I have pushed commit to Forked version to be compatible with AndroidX and tested. Please see https://github.com/bendothall/ReActiveAndroid/commit/dba30228991c5de7d173b2563b31a463b44edce6

bhapps avatar Jul 10 '19 09:07 bhapps