0

My app works fine on every Android 8 device, but crashes on devices running Android 9.

I'm trying to upgrade it, but I'm getting this:

java.lang.UnsupportedOperationException: removeView(View) is not supported in AdapterView
        at android.widget.AdapterView.removeView(AdapterView.java:947)
        at android.view.ViewOverlay$OverlayViewGroup.add(ViewOverlay.java:195)
        at android.view.ViewGroupOverlay.add(ViewGroupOverlay.java:72)
        at android.transition.TransitionUtils.createViewBitmap(TransitionUtils.java:171)
        at android.transition.TransitionUtils.copyViewImage(TransitionUtils.java:103)
        at android.transition.Visibility.onDisappear(Visibility.java:383)
        at android.transition.Visibility.createAnimator(Visibility.java:252)
        at android.transition.Transition.createAnimators(Transition.java:732)
        at android.transition.TransitionSet.createAnimators(TransitionSet.java:396)
        at android.transition.Transition.playTransition(Transition.java:1779)
        at android.transition.TransitionManager$MultiListener.onPreDraw(TransitionManager.java:315)
        at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:991)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3024)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1897)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8514)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
        at android.view.Choreographer.doCallbacks(Choreographer.java:761)
        at android.view.Choreographer.doFrame(Choreographer.java:696)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7063)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)

I DON'T USE ANY "removeView" FUNCTION in my code, it's in the library only. My gradle file looks like this:

apply plugin: 'com.android.application'

android {
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "fooooo"
        minSdkVersion 25
        targetSdkVersion 28
        compileSdkVersion 28
        versionCode 14
        versionName "1.0.5"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    ......
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation project(':FOOLibrary')
    implementation files('libs/ormlite-core-5.0.jar')
    implementation files('libs/ormlite-android-5.0.jar')
    implementation files('libs/ormlite-android-5.0-javadoc.jar')
    implementation 'com.google.android.gms:play-services-vision:11.0.4'
    implementation 'com.google.android.gms:play-services-location:11.0.4'
    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
    implementation 'com.android.support:recyclerview-v7:28.0.0-alpha3'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.google.code.gson:gson:2.7'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    testImplementation 'junit:junit:4.12'
}

I'm trying changing libraries versions, but anything seems to work. I found in Android documentation that it's normal for removeView function to get that Exception, but i can't override it.

I can show you the code from fragment and the adapter I'm using, but there's no removeView inside them.

Anyone can help?

1 Answers1

0

Finally I got my answer. The problem was in the Fragment managment. I was using this:

fragmentManager.beginTransaction().replace(R.id.main_container,fragment).commit();

instead of:

fragmentManager.beginTransaction().add(R.id.main_fl_container,fragment).commit();

I'm not sure what change of behaviour makes this not working from Android 8 to Android 9, but now it's working. Sorry if I didn't show these lines before, but the exception wasn't specifying any line of code and I had to figured it out myself.