AndroidX迁移后,KitKat应用程序崩溃

时间:2019-03-15 05:19:21

标签: android androidx

我已将我的应用迁移到AndroidX,以便能够使用app:drawableLeftCompat。迁移后,在其中一个屏幕上的Android KitKat上运行时,应用程序崩溃。在Android 7上运行时,该应用正常运行。 ADB日志中没有堆栈跟踪。这是日志的一部分

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.

从此日志中,我无法了解崩溃的原因。任何想法。

这是应用模块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'
}

这是主要的build.gradle文件

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

4 个答案:

答案 0 :(得分:3)

崩溃的原因在于这种依赖关系

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

这些库正在使用支持库中的某些渲染机制,该机制在AndroidX中已被破坏。因此,我们决定放弃应用程序中的模糊视图,并删除依赖项。

答案 1 :(得分:1)

此问题应在29.0.2构建工具版本中修复。对我来说,与以下脚本相关的渲染脚本SIGSEGV消失了:

android {
  compileSdkVersion 29
  buildToolsVersion "29.0.2"
  defaultConfig {
    ...
    minSdkVersion 17
    targetSdkVersion 29
    ...
    renderscriptTargetApi 21
    renderscriptSupportModeEnabled true

答案 2 :(得分:0)

我遇到了同样的问题,并通过以下操作解决了该问题:

替换这两行:

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

通过这些:

    implementation group: 'android.arch.persistence.room', name: 'runtime', version: '1.1.0'
    annotationProcessor group: 'android.arch.persistence.room', name: 'compiler', version: '1.1.1'

答案 3 :(得分:0)

我遇到了这个问题,可以使用AppCompatImageView而不是ImageView轻松解决。另外,对于所有设置矢量可绘制的XML视图,我用android:src替换了app:srcCompat

别忘了其他观点!如果您使用TextView或EditText,请将它们更改为AppCompatTextViewAppCompatEditText,然后在需要时使用drawable compat

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

更换后:

<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" />
相关问题