google / blockly-android

Blockly for Android
Apache License 2.0
672 stars 209 forks source link

Proguard "Unable to instantiate VerticalBlockViewFactory" error #748

Closed dhruvbhatia7 closed 5 years ago

dhruvbhatia7 commented 5 years ago

Hi, I'm getting an "Unable to instantiate VerticalBlockViewFactory" error when using Proguard. Everything works fine without Proguard.

The same issue was observed here as well. I tried creating an exclusion for the VerticalBlockViewFactory class but that didn't work.

Please help. Thanks

AnmAtAnm commented 5 years ago

Make sure the VerticalBlockViewFactory class is not renamed. It is loaded by name as a convenience since most developers will use this library for block rendering, while preventing a circular dependency between the two libraries.

As I noted in the thread you pointed to, you need to add an exception to prevent Proguard from renaming VerticalBlockViewFactory. I haven't tested it, but it looks like...

-keepnames class com.google.blockly.android.ui.vertical.VerticalBlockViewFactory

...is the right option. As noted previously, there may me other classes (particularly field view classes with loaded by layout files) that may also need to be excluded.

dhruvbhatia7 commented 5 years ago

Thanks, the exception worked for me, so I closed the issue.

Cheers!