mathew-kurian / TextJustify-Android

:page_facing_up: Android Text Full Jusiftication / Wrapping / Justify / Hyphenate - V2.0
https://github.com/bluejamesbond/TextJustify-Android/wiki
Apache License 2.0
1.86k stars 369 forks source link

Toast triggering NullPointerException #65

Open ghost opened 9 years ago

ghost commented 9 years ago

While editing the DocumentView on Android Studio this errors are generated and there is no preview of the widget.

java.lang.NullPointerException
    at android.widget.Toast.makeText(Toast.java:255)
    at com.bluejamesbond.text.IDocumentLayout.<init>(IDocumentLayout.java:69)
    at com.bluejamesbond.text.StringDocumentLayout.<init>(StringDocumentLayout.java:50)
    at com.bluejamesbond.text.DocumentView$3.<init>(DocumentView.java:372)
    at com.bluejamesbond.text.DocumentView.getDocumentLayoutInstance(DocumentView.java:372)
    at com.bluejamesbond.text.DocumentView.initDocumentView(DocumentView.java:338)
    at com.bluejamesbond.text.DocumentView.<init>(DocumentView.java:107)
    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:408)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:176)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:708)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:697)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
    at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:697)
    at com.android.tools.idea.rendering.RenderService.render(RenderService.java:816)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:646)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:589)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:584)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
android.view.InflateException
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:136)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
    at android.view.BridgeInflater.inflate(BridgeInflater.java:184)
    at android.widget.Toast.makeText(Toast.java:254)
    at com.bluejamesbond.text.IDocumentLayout.<init>(IDocumentLayout.java:69)
    at com.bluejamesbond.text.StringDocumentLayout.<init>(StringDocumentLayout.java:50)
    at com.bluejamesbond.text.DocumentView$3.<init>(DocumentView.java:372)
    at com.bluejamesbond.text.DocumentView.getDocumentLayoutInstance(DocumentView.java:372)
    at com.bluejamesbond.text.DocumentView.initDocumentView(DocumentView.java:338)
    at com.bluejamesbond.text.DocumentView.<init>(DocumentView.java:107)
    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:408)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:176)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:708)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:697)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
    at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:697)
    at com.android.tools.idea.rendering.RenderService.render(RenderService.java:816)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:646)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:589)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:584)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class TextView
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:128)
    ... 56 more
Caused by: java.lang.ClassNotFoundException: onCreateView
    at android.view.BridgeInflater.onCreateView(BridgeInflater.java:114)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
    ... 57 more
Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class <unknown>
    at android.view.LayoutInflater.createView(LayoutInflater.java:633)
    at android.view.BridgeInflater.onCreateView(BridgeInflater.java:82)
    ... 59 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedConstructorAccessor61.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at android.view.LayoutInflater.createView(LayoutInflater.java:607)
    ... 60 more
Caused by: android.content.res.Resources$NotFoundException
    at com.android.layoutlib.bridge.android.BridgeContext.obtainStyledAttributes(BridgeContext.java:490)
    at android.content.res.Resources_Theme_Delegate.obtainStyledAttributes(Resources_Theme_Delegate.java:70)
    at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java:1393)
    at android.widget.TextView.<init>(TextView.java:682)
    at android.widget.TextView.<init>(TextView.java:629)
    at android.widget.TextView.<init>(TextView.java:625)
    ... 64 more

XML of my project

<com.bluejamesbond.text.DocumentView
        xmlns:ext="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        ext:documentView_antialias="true"
        ext:documentView_cacheConfig="auto_quality"
        ext:documentView_hyphen="-"
        ext:documentView_lineHeightMultiplier="2.0"
        ext:documentView_maxLines="100"
        ext:documentView_offsetX="10dp"
        ext:documentView_offsetY="10dp"
        ext:documentView_insetPadding="10dp"
        ext:documentView_insetPaddingBottom="10dp"
        ext:documentView_insetPaddingLeft="10dp"
        ext:documentView_insetPaddingRight="10dp"
        ext:documentView_insetPaddingTop="10dp"
        ext:documentView_reverse="false"
        ext:documentView_textAlignment="justified"
        ext:documentView_textColor="@android:color/white"
        ext:documentView_textFormat="plain"
        ext:documentView_textSize="12sp"
        ext:documentView_textStyle="bold|strikeThru|underline"
        ext:documentView_textSubPixel="true"
        ext:documentView_textTypefacePath="fonts/helvetica.ttf"
        ext:documentView_wordSpacingMultiplier="5.0" />
kikijiki commented 9 years ago

Me too, it says Couldn't resolve resource @style/TextAppearance.Toast among the other things.

zdd commented 9 years ago

Got the same error, anyone has a solution?

muhammad-naderi commented 9 years ago

same error here !

sigrlami commented 9 years ago

@vyscond @kikijiki @zdd @muhammad-naderi Could you specify Android versions you targeting? Do you use custom theme?

MaxenceMax commented 9 years ago

Same error for me ...

ghost commented 9 years ago

No. I just finished the project already :( don't wanna touch it for at least 1 year @_@

kikijiki commented 9 years ago

@sigrlami sorry I didn't see the message. That project is long gone, I fear I can't give more details.

MaxenceMax commented 9 years ago

@kikijiki do you fix the problem ?

kikijiki commented 9 years ago

@MaxenceMax Not that I remember.