Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'androidx.compose.runtime.PrimitiveSnapshotStateKt while implementing Coil3 #2036

Closed
coveroid opened this issue Jan 10, 2024 · 2 comments
Closed

Comments

@coveroid
Copy link

coveroid commented Jan 10, 2024

I'm experiencing a NoClassDefFoundError related to androidx.compose.runtime.PrimitiveSnapshotStateKt while implementing Coil's multiplatform library in my project. This error arises during runtime and results in the application crashing. The problem appears to be associated with the integration of Coil in a Jetpack Compose multiplatform environment. Previously, I managed image loading using a custom setup with Compose Coil for Android and Java libraries for desktop.

Implementation Details
The following Coil dependencies are included in the project:

on commonMain:

implementation("io.coil-kt.coil3:coil:3.0.0-alpha01")
implementation("io.coil-kt.coil3:coil-core:3.0.0-alpha01")
implementation("io.coil-kt.coil3:coil-compose:3.0.0-alpha01")
implementation("io.coil-kt.coil3:coil-compose-core:3.0.0-alpha01")
implementation("io.coil-kt.coil3:coil-network:3.0.0-alpha01")

and on androidMain
implementation("io.ktor:ktor-client-okhttp:2.3.7")

Sample fucntion (on commonMain)

@Composable
fun  myImageDownloader (url: String){
    AsyncImage(
        model = ImageRequest.Builder(LocalPlatformContext.current)
            .data(url)
            .build(),
        contentDescription = null,
        modifier = Modifier.fillMaxSize(),
    )
}

I've not set R8 or proguard but i added rules like in documentation in case ... I also invalided cache, files etc ..

                                                                                                    Process: com.myapplication.MyApplication, PID: 24685
                                                                                                    java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/runtime/PrimitiveSnapshotStateKt;
                                                                                                    	at coil3.compose.AsyncImagePainter.<init>(AsyncImagePainter.common.kt:184)
                                                                                                    	at coil3.compose.AsyncImagePainter_commonKt.rememberAsyncImagePainter-GSdzBsE(AsyncImagePainter.common.kt:159)
                                                                                                    	at coil3.compose.AsyncImagePainter_commonKt.rememberAsyncImagePainter-0YpotYA(AsyncImagePainter.common.kt:140)
                                                                                                    	at coil3.compose.AsyncImageKt.AsyncImage-YIYSHzI(AsyncImage.kt:151)
                                                                                                    	at coil3.compose.AsyncImageKt.AsyncImage-sKDTAoQ(AsyncImage.kt:120)
                                                                                                    	at coil3.compose.SingletonAsyncImageKt.AsyncImage-10Xjiaw(SingletonAsyncImage.kt:120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.compose.runtime.PrimitiveSnapshotStateKt" on path: DexPathList[[zip file "/data/app/.../base.apk"],nativeLibraryDirectories=[/data/app/.../lib/arm64, /system/lib64, /system_ext/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)

I have spent several hours trying to diagnose and resolve this issue without success. Any guidance or suggestions from the community would be greatly appreciated. Thank You

@colinrtwhite
Copy link
Member

Sorry I can't provide help for local build issues, though it looks like importing the deprecated accompanist/systemuicontroller could be related.

@colinrtwhite colinrtwhite closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
@coveroid
Copy link
Author

coveroid commented Jan 10, 2024

@colinrtwhite Ok thank you anyway. Could have been this but i disable all accompanist/systemuicontroller on my code and unfortunately the problem persist. Previously I had no problem wioth coil2 with actual expect mechanism and the crash error seems indicate the problem is related to coil3

edit: solved by updating androidx.tv:tv package to last version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants