dokar3 / ChipTextField

Editable chip layout for Compose Multiplatform
Apache License 2.0
81 stars 3 forks source link

Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.compose.ui.platform.LocalSoftwareKeyboardController" #103

Closed IuliuCristianDumitrache closed 8 months ago

IuliuCristianDumitrache commented 8 months ago

FATAL EXCEPTION: main Process: com.example.bluemail, PID: 23770 java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/ui/platform/LocalSoftwareKeyboardController;

dokar3 commented 8 months ago

There seems to be some dependency conflicts here, can you provide a minimal build.gradle to reproduce it?

IuliuCristianDumitrache commented 8 months ago

implementation 'androidx.core:core-ktx:1.12.0' implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0') implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' implementation 'androidx.activity:activity-compose:1.8.0' implementation platform('androidx.compose:compose-bom:2023.10.01') implementation 'androidx.compose.ui:ui' implementation 'androidx.compose.ui:ui-graphics' implementation 'androidx.compose.ui:ui-tooling-preview' implementation 'androidx.compose.ui:ui-viewbinding:1.6.0-alpha08' implementation 'androidx.compose.material3:material3' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.3.2' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00') androidTestImplementation 'androidx.compose.ui:ui-test-junit4' debugImplementation 'androidx.compose.ui:ui-tooling' debugImplementation 'androidx.compose.ui:ui-test-manifest'

// Orbit
implementation("org.orbit-mvi:orbit-core:4.3.2")
implementation("org.orbit-mvi:orbit-viewmodel:4.3.2")
implementation("org.orbit-mvi:orbit-compose:4.3.2")

// Material Design
implementation("androidx.compose.material3:material3:1.1.2")
// Navigation
implementation "androidx.navigation:navigation-compose:2.5.3"

// HILT
implementation 'androidx.work:work-runtime-ktx:2.8.1'
implementation "com.google.dagger:hilt-android:2.47"
kapt "com.google.dagger:hilt-android-compiler:2.47"
kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation "androidx.hilt:hilt-navigation-fragment:1.0.0"
implementation "androidx.hilt:hilt-navigation-compose:1.0.0"

// Lifecycle
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.4.1")

implementation ("androidx.compose.material:material:1.5.4")

// Gson
implementation 'com.google.code.gson:gson:2.8.7'

// Import the Firebase BoM
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
// Add the dependency for the Firebase SDK for Google Analytics
implementation "com.google.firebase:firebase-crashlytics-ktx"
implementation "com.google.firebase:firebase-analytics-ktx"
// ADD the API-only library to all variants
implementation("com.google.firebase:firebase-appdistribution-api-ktx:16.0.0-beta10")

// Coil Image
implementation "io.coil-kt:coil-compose:2.3.0"

// Constraint Layout
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"

// Lottie animation
implementation "com.airbnb.android:lottie-compose:4.0.0"

// Zoom
implementation "net.engawapg.lib:zoomable:1.5.1"

// WebView
implementation "com.google.accompanist:accompanist-webview:0.33.2-alpha"

// RTE
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.jakewharton.timber:timber:5.0.1'
implementation 'commons-io:commons-io:2.6'

// Permissions
implementation 'com.google.accompanist:accompanist-permissions:0.23.1'

// Swipe
implementation 'de.charlex.compose:revealswipe:1.2.0'
dokar3 commented 8 months ago

Okay, will check this later.

dokar3 commented 8 months ago

Issue confirmed, there is a conflict between accompanist libs, chiptextfield, and androidx.compose.ui:ui-viewbinding:1.6.0-alpha08. Use stable Compose lib versions to solve:

-implementation("androidx.compose.ui:ui-viewbinding:1.6.0-alpha08")
+implementation("androidx.compose.ui:ui-viewbinding")

-implementation("com.google.accompanist:accompanist-webview:0.33.2-alpha")
+implementation("com.google.accompanist:accompanist-webview:0.32.0")

-implementation("com.google.accompanist:accompanist-permissions:0.23.1")
+implementation("com.google.accompanist:accompanist-permissions:0.32.0")
EdricChan03 commented 7 months ago

I'm experiencing this issue as well with Compose 1.6.0-beta02, and have found that the following issue comment can be used to resolve the issue for now: https://github.com/stripe/stripe-android/issues/7184#issuecomment-1776245431

One possible workaround for apps that are facing this issue:

in app/src/main/kotlin/androidx/compose/ui/platform/LocalSoftwareKeyboardController.kt put this bridge:

package androidx.compose.ui.platform

import androidx.compose.runtime.Composable

// Used by Stripe Android SDK
// Work around for https://github.com/stripe/stripe-android/issues/7184
// This existed as Experimental in Compose 1.5, but was moved to a val in in Compose 1.6
@Suppress("unused")
object LocalSoftwareKeyboardController {
    val current
        @Composable
        get() = LocalSoftwareKeyboardController.current
}

(The linked comment also explains why such an exception occurred)

eldenskloss commented 7 months ago

Just for the next developer who comes along as lost as I was:

Step 1: Create a path in your project -> app/src/main/kotlin/androidx/compose/ui/platform (For me I had to create "/kotlin/androidx/compose/ui/platform"

Step 2: Create the LocalSoftwareKeyboardController class in that directory and copy the above code into it.

Step 3: You did it! Have a drink and stop hitting your head on the table.