java.lang.AbstractMethodError abstract method "androidx.camera.core.impl.Identifier androidx.camera.core.CameraFilter.getIdentifier()"

514 views
Skip to first unread message

Ultima Ratio

unread,
Nov 15, 2023, 1:06:11 PM11/15/23
to Android CameraX Discussion Group
Hello!

I get this error on CrashLytics:
java.lang.AbstractMethodError
abstract method "androidx.camera.core.impl.Identifier androidx.camera.core.CameraFilter.getIdentifier()"

But only in release mode, as app-bundle (maybe also a thing as APK).. I added the extensions to pro-guard, but the issue is still present.

I can re-test it, localy with creating an app bundle in release mode, then creating the APKs with the bundletool and then installing it at a Samsung phone (one phone, that has the issue is a  Galaxy A52s 5G or A53s).

IMHO it has something todo with the CameraSelector.Builder and the filtering function there.

I added this to my proguard:
-keep class androidx.camera.extensions.ExtensionsManager$** {*;}
-keep class androidx.camera.extensions.internal.sessionprocessor.AdvancedSessionProcessor$** {*;}
-keep class androidx.camera.extensions.internal.sessionprocessor.StillCaptureProcessor** {*;}
-keep class androidx.camera.extensions.internal.sessionprocessor.PreviewProcessor** {*;}

Am I missing something?

BR




Ultima Ratio

unread,
Nov 15, 2023, 1:17:13 PM11/15/23
to Android CameraX Discussion Group, Ultima Ratio
This here looks similar: https://issuetracker.google.com/issues/222726805

So it could be a pro-guard issue, but why is there no actual page to describe, how to configure it?

Ultima Ratio

unread,
Nov 15, 2023, 1:20:11 PM11/15/23
to Android CameraX Discussion Group, Ultima Ratio
Here more stacktrace:
Non-fatal Exception: java.lang.AbstractMethodError: abstract method "androidx.camera.core.impl.Identifier androidx.camera.core.CameraFilter.getIdentifier()"
       at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:627)
       at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:387)

The code where it happens:

                CaptureState.WIDELENS_BACK -> {
                    CameraSelector.Builder()
                        .addCameraFilter { infos ->
                            infos.filter {
                                it.lensFacing == CameraSelector.LENS_FACING_BACK && it.isWidelens()
                            }
                        }
                        .build()
                }

The line with this abstractMehtodError is the actual comparission.. 

isWideLens is a kotlin extension function:
fun CameraInfo?.isWidelens(): Boolean {
    try {
        if (this == null) {
            return false
        }
        val value = zoomState.value
        return intrinsicZoomRatio < 1 || (value != null && value.minZoomRatio < 1)
    } catch (ex: Exception) {
        ex.printStackTrace(System.err)
    }
    return false
}

Scott Nien

unread,
Nov 15, 2023, 10:27:33 PM11/15/23
to Android CameraX Discussion Group, beh...@gmail.com
Hi , Thanks for letting us know the issue. 

May I know which CameraX version you were using ?   And I assume you are using the same version for camera-core / camera-camera2 / camera-lifecycle / camera-extensions ,  right ?

Ultima Ratio

unread,
Nov 16, 2023, 3:46:40 AM11/16/23
to Android CameraX Discussion Group, scot...@google.com, Ultima Ratio
Hi!

Yes, it should be all the same version. Here from my build.gradle:

val camerax_version = "1.3.0"
api("androidx.camera:camera-core:${camerax_version}")
api("androidx.camera:camera-camera2:${camerax_version}")
api("androidx.camera:camera-lifecycle:${camerax_version}")
api("androidx.camera:camera-video:${camerax_version}")
api("androidx.camera:camera-view:${camerax_version}")
api("androidx.camera:camera-extensions:${camerax_version}")

Also keep in mind: Its not happening, when I switch the app to release mode. I need to create a bundle (aab) and from that APKs and then install them. Then I have this problem.

Scott Nien

unread,
Nov 16, 2023, 8:02:56 AM11/16/23
to Ultima Ratio, Android CameraX Discussion Group
Thanks for the information ! app bundle is something we haven't tested. We will look into this 

Ultima Ratio

unread,
Nov 16, 2023, 8:36:04 AM11/16/23
to Android CameraX Discussion Group, scot...@google.com, Android CameraX Discussion Group, Ultima Ratio
Hi again.

Ok, after some testing: also happens with APK.. it just didnt happen for the testers (Redmi devices).

Also happens with latest 1.4.0 alpha.

But: I tried to implement the interface and give that the CameraSelector filter mechanic..

    private val wideLensFilter: CameraFilter = object : CameraFilter {
        override fun filter(cameraInfos: MutableList<CameraInfo>): MutableList<CameraInfo> {
            val list = mutableListOf<CameraInfo>()
            for (cameraInfo in cameraInfos) {
                if (cameraInfo.isWidelens()) {
                    list.add(cameraInfo)
                }
            }
            return list
        }

        override fun getIdentifier(): Identifier {
            return Identifier.create("TEST")
        }
    }

And applying the filter then:

                    CameraSelector.Builder()
                        .addCameraFilter(wideLensFilter)
                        .build()



Lets see if it will work. Will keep you updated. 


Because the problem is the 2nd line here (taken from ProcessCameraprovider.java):

        for (CameraFilter cameraFilter : cameraSelector.getCameraFilterSet()) {
            if (cameraFilter.getIdentifier() != CameraFilter.DEFAULT_ID) {
                CameraConfig extendedCameraConfig =
                        ExtendedCameraConfigProviderStore.getConfigProvider(
                                cameraFilter.getIdentifier()).getConfig(
                                lifecycleCameraToBind.getCameraInfo(), mContext);
                if (extendedCameraConfig == null) { // ignore IDs unrelated to camera configs.
                    continue;
                }


CameraFilter is an interface and getIdentifier() is a default function.

Ultima Ratio

unread,
Nov 16, 2023, 10:56:40 AM11/16/23
to Android CameraX Discussion Group, Ultima Ratio, scot...@google.com, Android CameraX Discussion Group
Just to keep you updated: If I apply the filter like that and not like I showed in post#3, then it works fine in release mode APK.

Trying as bundle later on and then submitting it to the PlayStore. 

Ultima Ratio

unread,
Nov 17, 2023, 5:19:05 AM11/17/23
to Android CameraX Discussion Group, Ultima Ratio, scot...@google.com, Android CameraX Discussion Group
Yeah. Its also working fine from the PlayStore now.


So either some java8, kotlin or compiler optimizations removed the default function from the interface? Very strange error..

Scott Nien

unread,
Nov 20, 2023, 11:11:14 PM11/20/23
to Ultima Ratio, Android CameraX Discussion Group
Hi ! 
Thanks a lot for the information. 

I can't reproduce the issue (without implementing the getIdentifier() method) on my Pixel and Samsung devices.  
I modify it on top of CameraX Basic ( https://github.com/android/camera-samples/tree/main/CameraXBasic) and use CameraX version 1.3.0 

I wonder if that is fixed in the newer kotlin compiler or maybe the latest bundletool ?  

Can you share how you build the app bundle and install the apk from the aab file ?
and also what android gradle plugin and kotlin gradle plugin were you using?  you can find it in your top level build.gradle 

classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"


Ultima Ratio

unread,
Nov 21, 2023, 9:36:41 AM11/21/23
to Android CameraX Discussion Group, scot...@google.com, Android CameraX Discussion Group, Ultima Ratio
Hi!

Sure I can provide you with every thing you need.

We use the camera as an own library. From the lib:

id("com.android.application") version "7.3.1" apply false
id("org.jetbrains.kotlin.android") version "1.8.0" apply false
id("org.jetbrains.kotlin.kapt") version "1.8.0"
id("com.android.library") version "7.3.1" apply false

extra.set("compileSdkVersion", 34)
extra.set("minSdkVersion", 23)
extra.set("targetSdkVersion", 33)

For the library part of the camera, we have that options:

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}

Gradle version from gradle.properties:

I basically make a library out of it and push it to our own repo, with the goals: 
assemble publish


Our main app, which includes its as library via implementation:

id("com.android.application") version "7.3.1" apply false
id("com.android.library") version "7.3.1" apply false

id("org.jetbrains.kotlin.android") version "1.8.0" apply false
id("org.jetbrains.kotlin.kapt") version "1.8.21"

extra.set("compileSdkVersion", 34)
extra.set("minSdkVersion", 23)
extra.set("targetSdkVersion", 33)

Compile and kotlinOptions are also the same and also the used gradle.


Ultima Ratio

unread,
Nov 22, 2023, 8:34:17 AM11/22/23
to Android CameraX Discussion Group, Ultima Ratio, scot...@google.com, Android CameraX Discussion Group
Hey!

Just for info, we have that abstractmethoderror also somewhere else now..

And from what I read there, it should be closed or not be a thing with our AGP..

BUT: we have minSdk 23.. We get rid of this bug, with minSdk 24.. So maybe thats somehow the issue?

We will raise it to 24 with the end of the year.

Reply all
Reply to author
Forward
0 new messages