I've been developing a library that can be seen here: https://github.com/afollestad/material-dialogs
I recently created a new project and copied over the Java/XML/Drawables due to the new Android Studio (0.8.14 Beta), Gradle, and SDK Build Tools updates. Suddenly I've run into an issue when I attempt to run the sample project I've created, it had been working fine yesterday.
Here's the exception throw at Runtime when the user clicks one of the buttons in the sample:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/afollestad/materialdialogs/R$color;
at com.afollestad.materialdialogs.MaterialDialog$Builder.<init>(MaterialDialog.java:389)
at com.afollestad.materialdialogssample.MainActivity.showCallbacks(MainActivity.java:143)
at com.afollestad.materialdialogssample.MainActivity.access$400(MainActivity.java:24)
at com.afollestad.materialdialogssample.MainActivity$5.onClick(MainActivity.java:62)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.afollestad.materialdialogs.R$color" on path: DexPathList[[zip file "/data/app/com.afollestad.materialdialogssample-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.afollestad.materialdialogs.MaterialDialog$Builder.<init>(MaterialDialog.java:389)
at com.afollestad.materialdialogssample.MainActivity.showCallbacks(MainActivity.java:143)
at com.afollestad.materialdialogssample.MainActivity.access$400(MainActivity.java:24)
at com.afollestad.materialdialogssample.MainActivity$5.onClick(MainActivity.java:62)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Suppressed: java.lang.ClassNotFoundException: com.afollestad.materialdialogs.R$color
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
When the class MaterialDialog
is instantiated, it retrieves resources such as colors and dimensions. For whatever reason, it appears these aren't be transferred to the APK file. I thought it might be a manifest merger issue.
Solved it by creating yet another project. Not sure what was different the second time o.O