App crashes on KitKat after AndroidX migration

4

I've migrated my app to AndroidX to be able to use app:drawableLeftCompat. After migration the app is crashing while running on Android KitKat on one of the screens. When running on Android 7 the app is working fine. There is no stacktraces in ADB log. This is part of the log

E/dalvikvm: Could not find class 'android.view.textclassifier.TextClassificationManager', referenced from method androidx.appcompat.widget.AppCompatTextClassifierHelper.getTextClassifier
W/dalvikvm: VFY: unable to resolve const-class 759 (Landroid/view/textclassifier/TextClassificationManager;) in Landroidx/appcompat/widget/AppCompatTextClassifierHelper;
D/dalvikvm: VFY: replacing opcode 0x1c at 0x000a
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/textclassifier/TextClassifier;)
    VFY: unable to find class referenced in signature (Landroid/view/textclassifier/TextClassifier;)
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/ViewStructure;)
I/dalvikvm: Could not find method android.widget.LinearLayout.dispatchProvideAutofillStructure, referenced from method com.google.android.material.textfield.TextInputLayout.dispatchProvideAutofillStructure
W/dalvikvm: VFY: unable to resolve virtual method 5194: Landroid/widget/LinearLayout;.dispatchProvideAutofillStructure (Landroid/view/ViewStructure;I)V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x002e
W/dalvikvm: VFY: unable to resolve virtual method 4274: Landroid/view

/ViewConfiguration;.shouldShowMenuShortcutsWhenKeyboardPresent ()Z
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
D/EGL_emulation: eglMakeCurrent: 0xb7961980: ver 2 0
E/EGL_emulation: tid 3996: eglSurfaceAttrib(1199): error 0x3009 (EGL_BAD_MATCH)
W/HardwareRenderer: Backbuffer cannot be preserved
D/dalvikvm: Trying to load lib /data/app-lib/ru.septagon.android.cashregister-2/librsjni_androidx.so 0xa4ffabd0
    Added shared lib /data/app-lib/ru.septagon.android.cashregister-2/librsjni_androidx.so 0xa4ffabd0
A/libc: Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 3996 (id.cashregister)
Application terminated.

From this log I can't understand the reason of crash. Any ideas.

This is app module build.gradle

apply plugin: 'com.android.application'
apply plugin: 'io.sentry.android.gradle'

def versionMajor = 1
def versionMinor = 3
def versionPatch = 0

repositories {
    jcenter()
    flatDir {
        dirs 'libs'
    }
}

android {
    if (project.hasProperty('debBuild')) {
        splits.abi.enabled = false
        splits.density.enable = false
    }
    compileSdkVersion rootProject.compileSdkVersion
    buildToolsVersion rootProject.buildToolsVersion

    compileOptions.encoding = 'UTF-8'

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
        disable 'MissingTranslation'
    }
    dataBinding {
        enabled = true
    }

    dexOptions {
        preDexLibraries true
        javaMaxHeapSize "4g"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    splits {
        abi {
            enable true
            reset()
            universalApk true
        }
    }

    defaultConfig {
        applicationId "ru.septagon.android.cashregister"
        minSdkVersion rootProject.minSdkVersion
        targetSdkVersion rootProject.targetSdkVersion
        versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
        versionName generateVersionName("${versionMajor}.${versionMinor}.${versionPatch}")
        setProperty("archivesBaseName", "cashregister-$versionName")

        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField 'int', 'SYNC_PERIOD_SEC', '360'
            signingConfig signingConfigs.release
        }

        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField 'int', 'SYNC_PERIOD_SEC', '60'
        }

    }

    packagingOptions {
        exclude 'lib/mips/libRSSupport.so'
        exclude 'lib/mips/librsjni.so'
    }
}


private String generateVersionName(String version) {
    String versionName = version
    if (project.hasProperty("buildVersion")) {
        versionName += "." + project.getProperties().get("buildVersion").toString()
    }
    return versionName;
}

dependencies {

    implementation project(':log')
    implementation project(':esptouch')
    implementation project(':pinpad')

    implementation(name: 'android_util_fr_drv_ng-release', ext: 'aar')

    // Google support
    implementation "androidx.core:core:$rootProject.supportVersion"
    implementation "androidx.legacy:legacy-support-core-ui:$rootProject.supportVersion"
    implementation "androidx.legacy:legacy-support-v13:1.0.0"
    implementation "androidx.legacy:legacy-support-v4:1.0.0"
    implementation "androidx.appcompat:appcompat:1.1.0-alpha02"
    implementation "androidx.cardview:cardview:$rootProject.supportVersion"
    implementation "androidx.recyclerview:recyclerview:$rootProject.supportVersion"
    implementation "com.google.android.material:material:$rootProject.supportVersion"
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.multidex:multidex:2.0.0'

    implementation 'com.annimon:stream:1.2.0'

    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    implementation 'com.github.mmin18:realtimeblurview:1.1.2'
    implementation 'com.ms-square:etsyblur:0.2.1'

    // Google common
    implementation 'com.firebase:firebase-jobdispatcher:0.8.5'

    // google arch
    implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archVersion"
    implementation "androidx.lifecycle:lifecycle-runtime:$rootProject.archVersion"

    // Rx
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
    implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'

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

    // recycler view
    implementation 'me.tatarka.bindingcollectionadapter2:bindingcollectionadapter:2.3.0-beta1'
    implementation 'me.tatarka.bindingcollectionadapter2:bindingcollectionadapter-recyclerview:2.3.0-beta1'

    // Network
    implementation "com.squareup.okhttp3:okhttp:$rootProject.okhttpVersion"
    implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$rootProject.retrofitVersion"
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'

    // DB
    implementation 'com.j256.ormlite:ormlite-android:5.0'
    annotationProcessor "org.projectlombok:lombok:1.16.12"

    // Glide
    implementation "com.github.bumptech.glide:glide:$rootProject.glideVersion"
    annotationProcessor "com.github.bumptech.glide:compiler:$rootProject.glideVersion"
    implementation 'jp.wasabeef:glide-transformations:3.0.1'

    implementation 'joda-time:joda-time:2.10'
    implementation 'me.jessyan:autosize:0.9.5'
    implementation 'jp.wasabeef:recyclerview-animators:2.3.0'
    implementation 'io.sentry:sentry-android:1.7.10'
    implementation 'com.github.Kyash:rx-keyboard-detector:0.1.2'

    // Test
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.10.19'
}

This is main build.gradle file

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'io.sentry:sentry-android-gradle-plugin:1.7.10'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url 'http://srv-recs-dev01:8081/nexus/content/repositories/releases/' }
        maven { url 'http://srv-recs-dev01:8081/nexus/content/repositories/snapshots/' }
        mavenLocal()
        flatDir {
            dirs 'libs'
            dirs project(':pinpad').file('libs')
        }
    }
//    buildScan { licenseAgreementUrl = 'https://gradle.com/terms-of-service'; licenseAgree = 'yes' }
}

task printVersion{
    doLast {
        print rootProject.childProjects.get("app").android.defaultConfig.versionName
    }
}

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

ext {
    compileSdkVersion = 28
    buildToolsVersion = '28.0.3'

    minSdkVersion = 19
    targetSdkVersion = 26

    supportVersion = '1.0.0-beta01'
    servicesVersion = '11.8.0'
    androidAnnotationVersion = '4.3.1'
    archVersion = '2.0.0-beta01'

    daggerVersion = '2.16'
    okhttpVersion = '3.10.0'
    retrofitVersion = '2.4.0'
    glideVersion = '4.7.1'
    crashlyticsVersion = '2.6.8'
    commonsVersion = "1.3.0.3"
}
android
androidx
asked on Stack Overflow Mar 15, 2019 by Fyodor Sherstobitov • edited Mar 15, 2019 by Fyodor Sherstobitov

4 Answers

3

The reason of the crash was in this dependencies

implementation 'com.github.mmin18:realtimeblurview:1.1.2'
implementation 'com.ms-square:etsyblur:0.2.1'

Those libraries are using some rendering mechanism from Support Library that is broken in AndroidX. So we decided to abandon blurred views in applications and deleted dependencies.

answered on Stack Overflow Jul 31, 2019 by Fyodor Sherstobitov
1

This should be fixed in 29.0.2 build tools release. For me renderscript related SIGSEGV was gone with following config:

android {
  compileSdkVersion 29
  buildToolsVersion "29.0.2"
  defaultConfig {
    ...
    minSdkVersion 17
    targetSdkVersion 29
    ...
    renderscriptTargetApi 21
    renderscriptSupportModeEnabled true
answered on Stack Overflow Aug 9, 2019 by iyegoroff
0

I faced this issue and fix it easily using AppCompatImageView instead of ImageView. In addition, I replaced android:src with app:srcCompat for all XML views which set a vector drawable.

Do not forget about other views! If you use TextView or EditText, change them to AppCompatTextView and AppCompatEditText, then use drawable compat where needed.

<TextView
    android:id="@+id/search_text_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:drawableStart="@drawable/ic_search_24px_vector"
    android:drawablePadding="8dp" />

After replacing:

<androidx.appcompat.widget.AppCompatTextView
    android:id="@+id/search_text_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:drawableStartCompat="@drawable/ic_search_24px_vector"
    android:drawablePadding="8dp" />
answered on Stack Overflow Jun 30, 2020 by Zahra.HY
-1

I was facing the same problem and got it solved by doing the following:

Replace these two lines:

  // google arch
    implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archVersion"
    implementation "androidx.lifecycle:lifecycle-runtime:$rootProject.archVersion"

By these:

    implementation group: 'android.arch.persistence.room', name: 'runtime', version: '1.1.0'
    annotationProcessor group: 'android.arch.persistence.room', name: 'compiler', version: '1.1.1'
answered on Stack Overflow Mar 15, 2019 by Alan Deep

User contributions licensed under CC BY-SA 3.0