Android App Crashes When Adding Layout Containing Fragment


#1

I am trying to impliment the simple example here in Android Studio:

https://www.shinobicontrols.com/android/shinobicharts/quickstartguide/draw-a-simple-chart

The problem is the app crashes as soon as I try and add the layout to the activity. If I take the fragment out of the activity, it adds fine. 

setContentView(R.layout.activity_shanobi);

IT doesn’t really throw an exception, it just “quits”. This is what is in the log. 

11:17:42 AM CalledFromWrongThreadException

            Access is allowed from event dispatch thread only.

            Details: EventQueue.isDispatchThread()=false

            isDispatchThread()=false

            Toolkit.getEventQueue()=com.intellij.ide.IdeEventQueue@27a05dcf

            Current thread: Thread[ApplicationImpl pooled thread 28,4,main] 1955286092

            SystemEventQueueThread: Thread[AWT-EventQueue-1 1.5#AI-141.2422023, eap:false,6,main] 554087786

            “AWT-EventQueue-1 1.5#AI-141.2422023, eap:false” prio=0 tid=0x0 nid=0x0 waiting on condition

            java.lang.Thread.State: WAITING

            on com.intellij.ide.IdeEventQueue@27a05dcf

            at java.lang.Object.wait(Native Method)

            at java.lang.Object.wait(Object.java:485)

            at java.awt.EventQueue.getNextEvent(EventQueue.java:558)

            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:263)

            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)

            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)

            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)… (show balloon)

In the variables, this equals:

RuntimeInit$UncaughtHandler@4154

Thanks for any help


#2

Hi.

Can you please tell us a little more about your environment? What OS are you developing on? I am assuming you are using Android Studio - if so which version of this are you using? Also, what JDK are you using? I am not familiar with this exception which you are getting but my initial research suggests it may be related to the environment (for example version of Android Studio).

Please advise.

Thanks,

Kai.