delight-im / Android-AdvancedWebView

Enhanced WebView component for Android that works as intended out of the box
MIT License
2.39k stars 574 forks source link

The following classes could not be instantiated: - im.delight.android.webview.AdvancedWebView #61

Closed Mohammad699 closed 8 years ago

Mohammad699 commented 8 years ago

Hi, I'm getting this error in the layout editor and it covers the preview window and when I close it it shows again when I edit anything in the layout

The following classes could not be instantiated: - im.delight.android.webview.AdvancedWebView (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE

image

Please fix it.

Thank you very much

ocram commented 8 years ago

Thanks for your report!

Can you at least run your app, i.e. install and open it on a device or emulator? That should work. If there's really a problem here, it should only affect the preview in Android Studio, nothing else.

Can you try clicking the "Clear Cache" link in that window or clear the cache otherwise? Does that help?

Otherwise, the exception stack trace listed under "Exception Details" in that window might be helpful, but it's not completely visible.

Please try changing your dependency for this library from

compile 'com.github.delight-im:Android-AdvancedWebView:v2.1.1'

to

compile 'com.github.delight-im:Android-AdvancedWebView:8ce79f208f9c819a950f0b0375cd0bd5a5a41f52'

and see if this changes anything. Maybe you have to refresh the project or clean the cache again after this change.

Mohammad699 commented 8 years ago

@mwaclawek Thank you very much.

compile 'com.github.delight-im:Android-AdvancedWebView:8ce79f208f9c819a950f0b0375cd0bd5a5a41f52' This solved the issue

Here is the full stack trace :

java.lang.NullPointerException at im.delight.android.webview.AdvancedWebView.init(AdvancedWebView.java:389) at im.delight.android.webview.AdvancedWebView.<init>(AdvancedWebView.java:112) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465) at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172) at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105) at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:178) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70) at android.view.LayoutInflater.rInflate(LayoutInflater.java:834) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:197) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:902) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:854) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70) at android.view.LayoutInflater.rInflate(LayoutInflater.java:834) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.inflate(LayoutInflater.java:518) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:317) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:962) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$58(RenderTask.java:659) at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:380) at com.android.tools.idea.rendering.RenderTask.inflate(RenderTask.java:659) at com.android.tools.idea.uibuilder.model.NlModel.inflate(NlModel.java:327) at com.android.tools.idea.uibuilder.model.NlModel.render(NlModel.java:384) at com.android.tools.idea.uibuilder.editor.NlPreviewForm$Pending.<init>(NlPreviewForm.java:234) at com.android.tools.idea.uibuilder.editor.NlPreviewForm.setFile(NlPreviewForm.java:293) at com.android.tools.idea.uibuilder.editor.NlPreviewManager$3.run(NlPreviewManager.java:290) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:333) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:323) at com.intellij.util.ui.update.MergingUpdateQueue$3.run(MergingUpdateQueue.java:267) at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2440) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:279) at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:234) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.Alarm$Request$1.run(Alarm.java:378) at com.intellij.util.Alarm$Request.run(Alarm.java:398) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:227) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:726) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:857) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:658) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:386) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

ocram commented 8 years ago

@EgyptianM Thanks for the stack trace and for testing the bug fix! Glad that it seems to resolve the issue :)

Now that this library works in the preview mode of Android Studio, does it also still work in your app? That is, are the main features still working and is the view displaying correctly in your app?

If it works correctly, we can merge this bug fix into the main branch and prepare a new release so that everybody can benefit from this fix.

Thanks!

Mohammad699 commented 8 years ago

@mwaclawek Yes the library is working fine with no issues so far.

If I noticed anything new I'll post it here.

Thanks a lot

Best regards.

jollero commented 8 years ago

I am also testing this library. Unfortunately I'm getting a

Failed to resolve: com.github.delight-im:Android-AdvancedWebView:8ce79f208f9c819a950f0b0375cd0bd5a5a41f52'

Anyone know how to fix this?

ocram commented 8 years ago

@EgyptianM Thanks again! The changes have now been integrated into the main branch. This means that, from now on, you can use the latest releases again, as shown in the README. Please note that you will have to take a look at the notes in Migration.md, however.

The fix is in https://github.com/delight-im/Android-AdvancedWebView/commit/5f2a8cc85b66d965669e460d10f6d91e541d87e1

@jollero Are you sure you followed what's shown in the "Installation" section of the README? In particular, do you have the maven { url "https://jitpack.io" } entry shown there? Anyway, in the future, please open a separate issue if your question is not related. Thanks!