aclassen / ComposeReorderable

Enables reordering by drag and drop in Jetpack Compose (Desktop) LazyList & LazyGrid.
Apache License 2.0
844 stars 89 forks source link

Main Branch Missing Android Library Publishing #221

Open wakaztahir opened 1 year ago

wakaztahir commented 1 year ago

https://github.com/aclassen/ComposeReorderable/blob/main/reorderable/build.gradle.kts#L15

I realized it after forking and then publishing this library that build.gradle.kts is missing android configuration in kotlin block

android {
    publishLibraryVariants("release")
}

This can be added if android library plugin is present

plugins {
    id("com.android.library")
}

The library works fine but in debug but release versions of the app gives this exception upon usage

Capture

its also missing the following Android Block , it should probably have a manifest file as well

android {
    compileSdk = 33
    defaultConfig {
        minSdk = 21
    }
}

I addressed these issues in my fork in the following commit https://github.com/Qawaz/ComposeReorderable/commit/d4b01c3385f1c7e0005aea029d05f4138134146e

aclassen commented 1 year ago

This library is published as jvm library.

wakaztahir commented 1 year ago
Fatal Exception: java.lang.NoSuchMethodError: No direct method <init>(Ljava/lang/Object;Landroidx/compose/animation/core/TwoWayConverter;Ljava/lang/Object;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V in class Landroidx/compose/animation/core/Animatable; or its super classes (declaration of 'androidx.compose.animation.core.Animatable' appears in /data/app/~~yBg7Hv2SRfNHe7V4OAXfxA==/com.wakaztahir.sketchapp-pLCox6Ln09yUyeUFbMP7pQ==/base.apk)
       at org.burnoutcrew.reorderable.SpringDragCancelledAnimation.<init>(DragCancelledAnimation.kt:41)
       at org.burnoutcrew.reorderable.SpringDragCancelledAnimation.<init>(DragCancelledAnimation.kt:40)
       at org.burnoutcrew.reorderable.ReorderableLazyListStateKt.rememberReorderableLazyListState-WH-ejsw(ReorderableLazyListState.kt:43)
       at com.wakaztahir.sketchable.components.tools.LayersPanelKt.LayersPanel(LayersPanel.kt:61)
       at com.wakaztahir.sketchapp.activities.EditorActivity$EditorDialogs$5.invoke(EditorActivity.kt:329)
       at com.wakaztahir.sketchapp.activities.EditorActivity$EditorDialogs$5.invoke(EditorActivity.kt:328)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
       at com.wakaztahir.helpers.DialogBoxKt$DialogBox$1.invoke(DialogBox.kt:37)
       at com.wakaztahir.helpers.DialogBoxKt$DialogBox$1.invoke(DialogBox.kt:27)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
       at androidx.compose.ui.window.AndroidDialog_androidKt$Dialog$dialog$1$1$1$2.invoke(AndroidDialog.android.kt:181)
       at androidx.compose.ui.window.AndroidDialog_androidKt$Dialog$dialog$1$1$1$2.invoke(AndroidDialog.android.kt:180)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
       at androidx.compose.ui.window.AndroidDialog_androidKt.DialogLayout(AndroidDialog.android.kt:496)
       at androidx.compose.ui.window.AndroidDialog_androidKt.access$DialogLayout(AndroidDialog.android.kt:1)
       at androidx.compose.ui.window.AndroidDialog_androidKt$Dialog$dialog$1$1$1.invoke(AndroidDialog.android.kt:178)
       at androidx.compose.ui.window.AndroidDialog_androidKt$Dialog$dialog$1$1$1.invoke(AndroidDialog.android.kt:175)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
       at androidx.compose.ui.window.DialogLayout.Content(AndroidDialog.android.kt:272)
       at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:250)
       at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:249)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
       at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
       at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:177)
       at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:123)
       at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:122)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
       at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
       at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:114)
       at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:157)
       at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:156)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
       at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
       at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:156)
       at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:140)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
       at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78)
       at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3248)
       at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3238)
       at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
       at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(:1)
       at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3238)
       at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3173)
       at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:587)
       at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:950)
       at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3848)
       at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3848)
       at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
       at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)
       at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
       at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1060)
       at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:131)
       at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:182)
       at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:360)
       at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:202)
       at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:138)
       at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
       at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1147)
       at android.view.View.dispatchAttachedToWindow(View.java:20483)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3489)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2435)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1948)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8177)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
       at android.view.Choreographer.doCallbacks(Choreographer.java:796)
       at android.view.Choreographer.doFrame(Choreographer.java:731)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:223)
       at android.app.ActivityThread.main(ActivityThread.java:7701)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
wakaztahir commented 1 year ago

Hi , where in kotlin documentation is there a mention about the usage of jvm source set as a common set for android & desktop jvm

the closest thing I can find is https://kotlinlang.org/docs/multiplatform-share-on-platforms.html#share-code-in-libraries

I always assumed you had to create android() source set in kotlin to be able to use the library in android , I know that if the library source sets are android and jvm then the commonMain code can include code that is shared like java File class.

I am using common jvm source set for android and jvm , however I do it this way , I got this from here https://github.com/JetBrains/kotlin-native/issues/2577

val commonJvmMain by creating {
 dependsOn(commonMain)
}
val androidMain by getting {
 dependsOn(commonJvmMain)
}
val desktopMain by getting {
 dependsOn(commonJvmMain)
}