GrenderG / Toasty

The usual Toast, but with steroids 💪
GNU Lesser General Public License v3.0
6.58k stars 811 forks source link

Caused by: java.lang.NoSuchFieldError: es.dmoral.toasty.R$id.toast_icon #117

Open LeOnArDIOz opened 5 years ago

LeOnArDIOz commented 5 years ago

I created a clean project for API 16 and connected the library. Code: import es.dmoral.toasty.Toasty; public void click(View view) { Toasty.error(getApplicationContext(), "This is an error toast!", Toast.LENGTH_SHORT, true).show(); } And I get this exception: 06-15 17:55:47.116 16727-16727/com.example.toast E/AndroidRuntime: FATAL EXCEPTION: main java.lang.IllegalStateException: Could not execute method for android:onClick at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390) at android.view.View.performClick(View.java:4091) at android.view.View$PerformClick.run(View.java:17072) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:5037) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) at android.view.View.performClick(View.java:4091)  at android.view.View$PerformClick.run(View.java:17072)  at android.os.Handler.handleCallback(Handler.java:615)  at android.os.Handler.dispatchMessage(Handler.java:92)  at android.os.Looper.loop(Looper.java:153)  at android.app.ActivityThread.main(ActivityThread.java:5037)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.NoSuchFieldError: es.dmoral.toasty.R$id.toast_icon at es.dmoral.toasty.Toasty.custom(Toasty.java:303) at es.dmoral.toasty.Toasty.error(Toasty.java:242) at com.example.toast.MainActivity.click(MainActivity.java:70) at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)  at android.view.View.performClick(View.java:4091)  at android.view.View$PerformClick.run(View.java:17072)  at android.os.Handler.handleCallback(Handler.java:615)  at android.os.Handler.dispatchMessage(Handler.java:92)  at android.os.Looper.loop(Looper.java:153)  at android.app.ActivityThread.main(ActivityThread.java:5037)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)  at dalvik.system.NativeStart.main(Native Method)  I run on the phone with android 4.1.1. Help

GrenderG commented 5 years ago

Which version of the library are you using?

wjploop commented 5 years ago

@LeOnArDIOz I meet the same error and find it occur just because I created a file named toast_layout.xml

tranvantam310 commented 4 years ago

error when you already had toast_layout.xml. Check it in app/res/layout