tangqi92 / WaveLoadingView

An Android library providing to realize wave loading effect.
1.73k stars 313 forks source link

Could not instantiate view in layout editor #30

Open Meowzz95 opened 7 years ago

Meowzz95 commented 7 years ago

Hi, I'm having this weird problem, please take a look. I just import the library and try to put it in an empty activity but AS layout editor can't show preview. Here's the exception java.lang.IllegalArgumentException: java.lang.ClassCastException@4edc8afc at sun.reflect.GeneratedMethodAccessor2683.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108) at android.animation.PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:145) at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java) at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38) at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1359) at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:989) at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:612) at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:578) at android.animation.ValueAnimator.start(ValueAnimator.java:1001) at android.animation.ValueAnimator.start(ValueAnimator.java:1010) at android.animation.ObjectAnimator.start(ObjectAnimator.java:852) at android.animation.AnimatorSet.start(AnimatorSet.java:678) at android.animation.AnimatorSet.onChildAnimatorEnded(AnimatorSet.java:807) at android.animation.AnimatorSet.start(AnimatorSet.java:640) at me.itangqi.waveloadingview.WaveLoadingView.setProgressValue(WaveLoadingView.java:564) at me.itangqi.waveloadingview.WaveLoadingView.init(WaveLoadingView.java:171) at me.itangqi.waveloadingview.WaveLoadingView.<init>(WaveLoadingView.java:137) at me.itangqi.waveloadingview.WaveLoadingView.<init>(WaveLoadingView.java:132) 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:186) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245) 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.inflate(LayoutInflater.java:518) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324) 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:966) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$70(RenderTask.java:659) 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)

Here's my layout xml

`<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/activity_main" android:orientation="horizontal" 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" android:background="@color/colorAccent" tools:context="com.mewozz.standaloneexergame.MainActivity">

<me.itangqi.waveloadingview.WaveLoadingView
    android:id="@+id/waveLoadingView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:wlv_borderColor="@color/colorAccent"
    app:wlv_borderWidth="3dp"
    app:wlv_progressValue="40"
    app:wlv_shapeType="circle"
    app:wlv_round_rectangle="true"
    app:wlv_triangle_direction="north"
    app:wlv_titleCenterStrokeColor="@android:color/holo_blue_dark"
    app:wlv_titleCenterStrokeWidth="3dp"
    app:wlv_titleCenter="Center Title"
    app:wlv_titleCenterColor="@android:color/white"
    app:wlv_titleCenterSize="24sp"
    app:wlv_waveAmplitude="70"
    app:wlv_waveColor="@color/colorAccent"/>

`

Screenshot

image

tangqi92 commented 7 years ago

Can you build this project properly?

Or just can't show preview?

Meowzz95 commented 7 years ago

The project can be successfully built, just the preview always throws exception.

tangqi92 commented 7 years ago

It seems to be a common problem caused by AS.

This post would be help. (http://stackoverflow.com/questions/16592965/android-studio-layout-editor-cannot-render-custom-views)

Meowzz95 commented 7 years ago

Ah... Hasn't everyone moved to AS from Eclipse already..? :)

Meowzz95 commented 7 years ago

Any idea on how to solve this? Thanks!

Meowzz95 commented 7 years ago

I've submitted a pull request, pls take a look :)