DanielMartinus / Konfetti

Celebrate more with this lightweight confetti particle system 🎊
ISC License
3.19k stars 301 forks source link

java.lang.NoSuchMethodError: No direct method <init> #235

Closed akashraghav closed 3 years ago

akashraghav commented 3 years ago

I'm facing NoSuchMethodError, with basic implementation, I've tried, adding keep rules in proguard and changing gradle version also.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <nl.dionsegijn.konfetti.KonfettiView
        android:id="@+id/viewKonfetti"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <Button
        android:id="@+id/animate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="40dp"
        android:layout_gravity="bottom|center_horizontal"
        android:text="confetti"/>

</FrameLayout>
animate.setOnClickListener {
            viewKonfetti.build()
                .addColors(Color.YELLOW, Color.GREEN, Color.MAGENTA)
                .setDirection(0.0, 359.0)
                .setSpeed(1f, 5f)
                .setFadeOutEnabled(true)
                .setTimeToLive(2000L)
                .addShapes(Shape.Square, Shape.Circle)
                .addSizes(Size(12))
                .setPosition(-50f, viewKonfetti.width + 50f, -50f, -50f)
                .streamFor(300, 5000L)
}

Exception log :

java.lang.NoSuchMethodError: No direct method <init>(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V in class Lkotlin/jvm/internal/FunctionReferenceImpl; or its super classes (declaration of 'kotlin.jvm.internal.FunctionReferenceImpl' appears in /data/app/com.example.konfettitest-K-vK9P7-SagmiSz-gOOCTA==/base.apk)
        at nl.dionsegijn.konfetti.emitters.RenderSystem$1.<init>(Unknown Source:10)
        at nl.dionsegijn.konfetti.emitters.RenderSystem.<init>(RenderSystem.kt:40)
        at nl.dionsegijn.konfetti.emitters.RenderSystem.<init>(RenderSystem.kt:27)
        at nl.dionsegijn.konfetti.ParticleSystem.startRenderSystem(ParticleSystem.kt:286)
        at nl.dionsegijn.konfetti.ParticleSystem.streamFor(ParticleSystem.kt:245)
        at com.example.konfettitest.MainActivity.animateView4(MainActivity.kt:34)
        at com.example.konfettitest.MainActivity.access$animateView4(MainActivity.kt:11)
        at com.example.konfettitest.MainActivity$onCreate$1.onClick(MainActivity.kt:17)
        at android.view.View.performClick(View.java:6597)
        at android.view.View.performClickInternal(View.java:6574)
        at android.view.View.access$3100(View.java:778)
        at android.view.View$PerformClick.run(View.java:25885)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
DanielMartinus commented 3 years ago

hey @akashraghav, do you have a little more info about your project?

For instance, is it a java code base and have you tried this? https://github.com/DanielMartinus/Konfetti#java-project

Also, is it a new and small or a large codebase?

akashraghav commented 3 years ago

Hey @DanielMartinus, It's a new blank project with kotlin supported. I also tried running the java code but got the same result.

Here are the dependencies in build.gradle:

implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'nl.dionsegijn:konfetti:1.2.6-rc1'
akashraghav commented 3 years ago

Hey @DanielMartinus, I looked into the closed issues, found duplicate, should've looked there in first place. Issue got fixed by changing 1.3.72 to 1.4.10. Seems to be some reliability on latest kotlin version. You should add this to the wiki for future users. Thank you.