Skip to content

Android Studio Rendering Problems #393

@diogotcorreia

Description

@diogotcorreia

I've got this stack trace while rendering on Android Studio:

 java.lang.NullPointerException	at com.alamkanak.weekview.WeekView.drawHeaderRowAndEvents(WeekView.java:613)	at com.alamkanak.weekview.WeekView.onDraw_Original(WeekView.java:488)	at com.alamkanak.weekview.WeekView.onDraw(WeekView.java)	at android.view.View.draw(View.java:17068)	at android.view.View.draw(View.java:16976)	at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)	at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)	at android.view.ViewGroup.drawChild(ViewGroup.java:3764)	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)	at android.view.View.draw(View.java:16974)	at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)	at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)	at android.view.ViewGroup.drawChild(ViewGroup.java:3764)	at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1195)	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)	at android.view.View.draw(View.java:16974)	at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)	at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)	at android.view.ViewGroup.drawChild(ViewGroup.java:3764)	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)	at android.view.View.draw(View.java:16974)	at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)	at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)	at android.view.ViewGroup.drawChild(ViewGroup.java:3764)	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)	at android.view.View.draw(View.java:17071)	at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:394)	at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:505)	at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:87)	at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:154)	at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:136)	at com.android.tools.idea.rendering.RenderTask.lambda$renderInner$54(RenderTask.java:698)	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) 

This is my XML file:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/content_schedule" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="<hidden>.app.MainActivity" tools:showIn="@layout/app_bar_main"> <com.alamkanak.weekview.WeekView android:id="@+id/weekView" android:layout_width="match_parent" android:layout_height="match_parent" app:eventTextColor="@android:color/white" app:textSize="12sp" app:hourHeight="60dp" app:headerColumnPadding="8dp" app:headerColumnTextColor="#8f000000" app:headerRowPadding="12dp" app:columnGap="8dp" app:noOfVisibleDays="5" app:headerRowBackgroundColor="#ffefefef" app:dayBackgroundColor="#05000000" app:todayBackgroundColor="#1848adff" app:headerColumnBackground="#ffffffff" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> </RelativeLayout> 

The calendar works fine on the final product, but I can't preview it on Android Studio (sadly). It's annoying because I can't preview the other app layouts because of this problem.

Android Studio Rendering Problems

Can you please solve it?

(From the method names, it looks like Android Studio doesn't provide the current time, so it doesn't work)

EDIT: Confirmed with the source code. On line 555 of WeekView, today() returns null.

It can be easily solved by replacing that line with Calendar today = today(); if(today == null) today = new GregorianCalendar(2000, 1, 1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions