A support library for VectorDrawable and AnimatedVectorDrawable classes introduced in Lollipop

Overview

vector-compat

A support library for VectorDrawable and AnimatedVectorDrawable introduced in Lollipop with fully backwards compatible tint support (api 14+ so far)

vector-compat provides the necessary tools to make animated icons similar to the new drawer hamburger icon that morphs to a back arrow when clicked. Any other morph animation between icons can be defined purely in xml (no java code required) and the library takes care of the transformation animation. Because they are in vector format, these drawables can be of any height and width with no resulting pixelation.

Example Example 1 Example 2

The library will transparently fall back to the lollipop implementation of VectorDrawable and AnimatedVectorDrawable on api 21+ devices

##Commonly used animations The library packs some ready-made morph animations developers can use in their code with MorphButton. More will be added soon as this is a work-in-progress. The library has the following morph animations :

  • Play-Pause morph animation (bi-directional morph)
  • Play-Stop morph animation (bi-directional morph)
  • Arrow-Hamburger menu morph animation (bi-directional morph)

The goal is to, with time, create a repo of commonly used morph animations that lots of developers find useful.

If you have requests for particular morph animations, please open a new issue and I'll work on adding them to the library. You are also welcome to create a pull request if you've created some of your own. Please contribute :)

Download

Add the vector-compat dependency to your build.gradle file and make sure to use buildToolsVersion 22 or higher:

Maven Central

android {
    // use version 22 or higher
    buildToolsVersion "22.0.1"
    ...
}
dependencies {
    compile 'com.wnafee:vector-compat:1.0.5'
    ...
}

Proguard

If you're using proguard for code shrinking and obfuscation, make sure to add the following:

   -keep class com.wnafee.vector.** { *; }

Usage

VectorDrawable and AnimatedVectorDrawable xml drawable syntax is exactly the same as the lollipop documentation (can be seen here and here respectively). With 2 caveats:

  • Some attributes under the <vector> nodes must be listed once for the android: namespace and once for the local namespace with a vc_ prefix (e.g. app:vc_fillColor). See example here. (For a complete list of vc_ prefixed attributes see attr.xml for )
  • Any pathType anim xml must have the android:valueType="pathType" in addition to app:vc_valueType="pathType" to allow for lollipop implementation fallback. See example here.

Inflation

VectorDrawable and AnimatedVectorDrawable in this support library can be inflated in one of 2 ways:

  • Calling static getDrawable() methods:
//This will only inflate a drawable with <vector> as the root element
VectorDrawable.getDrawable(context, R.drawable.ic_arrow_vector);

//This will only inflate a drawable with <animated-vector> as the root element
AnimatedVectorDrawable.getDrawable(context, R.drawable.ic_arrow_to_menu_animated_vector);

// This will inflate any drawable and will auto-fallback to the lollipop implementation on api 21+ devices
ResourcesCompat.getDrawable(context, R.drawable.any_drawable);

If inflating the Drawable in java code, it is recommended to always use ResourcesCompat.getDrawable() as this handles Lollipop fallback when applicable. This allows the system to cache Drawable ConstantState and hence is more efficient

  • directly from the MorphButton view in xml:
<!-- Insert xmlns:app="http://schemas.android.com/apk/res-auto" in your root layout element -->
<com.wnafee.vector.MorphButton
    android:id="@+id/playPauseBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:vc_startDrawable="@drawable/ic_pause_to_play"
    app:vc_endDrawable="@drawable/ic_play_to_pause" /> 

MorphButton

MorphButton is a CompoundButton with 2 states: MorphState.START or MorphState.END. The attributes vc_startDrawable and vc_endDrawable define which foreground drawables to use for the button depending on the button's state. These can be any type of drawable (e.g. BitmapDrawable, ColorDrawable, VectorDrawable, AnimatedVectorDrawable etc.)

To use MorphButton in your app, make sure to include the morphButtonStyle item in your base app theme:

<style name="MyAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="morphButtonStyle">@style/Widget.MorphButton</item>
</style>

MorphButtons allow you to tint your foreground drawables (i.e. vc_startDrawable and vc_endDrawable) and background drawable separately in both xml and java. See the following examples for defining MorphButtons:

XML:

<com.wnafee.vector.MorphButton
    android:id="@+id/drawerBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="fitCenter"
    app:vc_backgroundTint="#f50057"
    app:vc_foregroundTint="#3F51B5"
    app:vc_startDrawable="@drawable/ic_arrow_to_drawer"
    app:vc_endDrawable="@drawable/ic_drawer_to_arrow"/>

Java:

    MorphButton mb = new MorphButton(this);
    mb.setBackgroundTintList(getResources().getColorStateList(R.color.background_tint_color));
    mb.setForegroundTintList(ColorStateList.valueOf(Color.RED));
    mb.setStartDrawable(R.drawable.ic_pause_to_play);
    mb.setEndDrawable(R.drawable.ic_play_to_pause);
    mb.setState(MorphState.END);

The scaleType attribute defines how to scale the foreground drawable to fill the button's background. This is the same as ImageView.ScaleType which you can take a look at here.

Button clicks will toggle between the foreground drawables. If the drawables happen to implement the Animatable interface (e.g. AnimatedVectorDrawable or AnimationDrawable) then start() will be automatically called to animate between the start and end drawables defined in xml.

MorphButton states can be set manually via setState() methods:

// transition with no animation
myMorphButton.setState(MorphState.END) 

// ... or transition with animation if drawable is Animatable
myMorphButton.setState(MorphState.START, true) 

If you need to be informed of button state changes you need to add an OnStateChangedListener:

MyMorphButton.setOnStateChangedListener(new OnStateChangedListener() {
    @Override
    public void onStateChanged(MorphState changedTo, boolean isAnimating) {
        // changeTo is the new state
        // isAnimating = true if the state changed with animation
        // Do something here
    }
});

License

Copyright 2015 Wael Nafee

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Using vector-compat library along with ViewPagerIndicator library produces gradle errors

    Using vector-compat library along with ViewPagerIndicator library produces gradle errors

    Hi.

    I am using your lib and also ViewPagerIndicator (com.viewpagerindicator:library:2.4.1@aar). Gradle gets me these errors: Error:(1) Attribute "strokeWidth" has already been defined Error:(1) Attribute "strokeWidth" has already been defined Error:(1) Attribute "fillColor" has already been defined

    I think it is something with naming convention (i found similiar problem here for some other lib, maybe it can help you: https://bitbucket.org/mobigosoft/graphlib/issue/1/error-attribute-strokecolor-has-already)

    opened by Lukafin 20
  • Button with AnimatedVectorDrawable compat doesn't show background

    Button with AnimatedVectorDrawable compat doesn't show background

    Maybe I've missed something, but I stumbled a little. I have an xml layout with button, in Java code I'm using

    Drawable avd = ResourcesCompat.getDrawable(getActivity(), R.drawable.btn_signin_avd);
    mBtnSignin.setBackground(avd);
    

    Animations working good, but when not animating my button is transparent, though on Lollipop devices it shows background descrided in the <vector><path>pathData</path></vector> section. And I duplicate pathData attribute value with app:vc_pathData.

    opened by olegosipenko 10
  • Crash on KitKat

    Crash on KitKat

    Is there some trick to getting a project to use vector-compat, beyond adding it to the gradle dependency list? When I try to display a vector drawable (not animated, not MorphButton), it crashes when run under KitKat (API 19).

    The error is:

    org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag vector
    

    The stack trace shows no sign of com.wnafee, so I can't tell if it is actually functioning.

    For reference, here is the drawable I'm trying to display (as a Button background):

    <?xml version="1.0" encoding="utf-8"?>
    <vector xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:width="24dp"
            android:height="24dp"
            app:vc_viewportHeight="24"
            app:vc_viewportWidth="24"
            android:viewportHeight="24"
            android:viewportWidth="24">
        <path
            app:vc_fillColor="#FFFFFF"
            app:vc_pathData="@string/vector_qrcode"
            android:fillColor="#FFFFFF"
            android:pathData="@string/vector_qrcode"/>
    </vector>
    
    opened by Nairou 7
  • <vector> requires API level 21

    requires API level 21

    In my drawable folder I have a ic_menu_refresh.xml file, which defines a refresh symbol vector:

    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24"
        android:viewportHeight="24"
        android:tint="?attr/colorControlNormal">
    <path
        android:pathData="M17.6,6.4C16.2,4.9 14.2,4 12,4c-4.4,0 -8,3.6 -8,8s3.6,8 8,8c3.7,0 6.8,-2.6 7.7,-6l-2.1,0c-0.8,2.3 -3,4 -5.6,4c-3.3,0 -6,-2.7 -6,-6s2.7,-6 6,-6c1.7,0 3.1,0.7 4.2,1.8L13,11l7,0L20,4L17.6,6.4z"
        android:fillColor="@color/white"/>
    

    I get an error in Android Studio that says, <vector> requires API level 21. I want the app to support versions of Android lower than API level 21. My minSdkVersion is 16, compileSdkVersion and targetSdkVersion are 22.

    And I have a Floating Button which uses this icon:

    <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:src="@drawable/ic_menu_refresh"
            app:elevation="6dp"
            app:pressedTranslationZ="12dp" />
    

    When I run my app it gives me an error: Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector

    opened by JeffreyCA 6
  • <menu_vector> tag requires viewportWidth > 0

    tag requires viewportWidth > 0

    Hi,

    I've attempted to implement your library and it works great on Android 5.X.X and above however Im getting some issues on devices running 4.X.X. Below is a partial of my xml for the vector drawable as the path data is quite long. Ive also got both app:vc_pathData and app:vc_fillColor on every path tag as well as the normal android: ones

    <vector xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:width="85dp"
            android:height="36dp"
            android:viewportWidth="85"
            android:viewportHeight="36"
    
            app:vc_viewportWidth="85"
            app:vc_viewportHeight="36">
    

    Im applying this to the MorphButton in xml in my layout however I get the error in the title when I run on devices 4.X.X.

    What am I missing?

    opened by RadicalMonkey 4
  • Failed to load animators on android 6.0

    Failed to load animators on android 6.0

    I receive this error on Nexus 7 2013 with my project using vector-compat:

    Failed to load animators. Either the AnimatedVectorDrawable must be created using a Resources object or applyTheme() must be called with a non-null Theme object.

    The button is not functional, can't be clicked.

    Is there a way how to fix this ? Working good on L devices and Kitkat.

    opened by marianpavel 3
  • vector-compat doesn't work with 21.1.2 build tools

    vector-compat doesn't work with 21.1.2 build tools

    steps to repro - update demo/build.gradle and change the buildToolsVersion to 21.1.2. compile and run. observe a crash on launch.

    E/VectorDrawable( 1528): parser error
    E/VectorDrawable( 1528): org.xmlpull.v1.XmlPullParserException: Binary XML file line #2<menu_vector> tag requires width > 0
    E/VectorDrawable( 1528):    at com.wnafee.vector.compat.VectorDrawable.updateStateFromTypedArray(VectorDrawable.java:400)
    E/VectorDrawable( 1528):    at com.wnafee.vector.compat.VectorDrawable.inflate(VectorDrawable.java:330)
    E/VectorDrawable( 1528):    at com.wnafee.vector.compat.VectorDrawable.create(VectorDrawable.java:304)
    E/VectorDrawable( 1528):    at com.wnafee.vector.compat.AnimatedVectorDrawable.inflate(AnimatedVectorDrawable.java:229)
    E/VectorDrawable( 1528):    at com.wnafee.vector.compat.AnimatedVectorDrawable.create(AnimatedVectorDrawable.java:204)
    E/VectorDrawable( 1528):    at com.wnafee.vector.compat.AnimatedVectorDrawable.getDrawable(AnimatedVectorDrawable.java:185)
    E/VectorDrawable( 1528):    at com.wnafee.vector.compat.ResourcesCompat.getDrawable(ResourcesCompat.java:44)
    E/VectorDrawable( 1528):    at com.wnafee.vector.MorphButton.<init>(MorphButton.java:79)
    E/VectorDrawable( 1528):    at com.wnafee.vector.MorphButton.<init>(MorphButton.java:58)
    E/VectorDrawable( 1528):    at java.lang.reflect.Constructor.constructNative(Native Method)
    E/VectorDrawable( 1528):    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    E/VectorDrawable( 1528):    at android.view.LayoutInflater.createView(LayoutInflater.java:594)
    E/VectorDrawable( 1528):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
    E/VectorDrawable( 1528):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
    E/VectorDrawable( 1528):    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    E/VectorDrawable( 1528):    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    E/VectorDrawable( 1528):    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
    E/VectorDrawable( 1528):    at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:240)
    E/VectorDrawable( 1528):    at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
    E/VectorDrawable( 1528):    at com.wnafee.vector.compat.demo.MainActivity.onCreate(MainActivity.java:27)
    E/VectorDrawable( 1528):    at android.app.Activity.performCreate(Activity.java:5231)
    E/VectorDrawable( 1528):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    E/VectorDrawable( 1528):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
    E/VectorDrawable( 1528):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
    E/VectorDrawable( 1528):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    E/VectorDrawable( 1528):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    E/VectorDrawable( 1528):    at android.os.Handler.dispatchMessage(Handler.java:102)
    E/VectorDrawable( 1528):    at android.os.Looper.loop(Looper.java:136)
    E/VectorDrawable( 1528):    at android.app.ActivityThread.main(ActivityThread.java:5001)
    E/VectorDrawable( 1528):    at java.lang.reflect.Method.invokeNative(Native Method)
    E/VectorDrawable( 1528):    at java.lang.reflect.Method.invoke(Method.java:515)
    E/VectorDrawable( 1528):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    E/VectorDrawable( 1528):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    E/VectorDrawable( 1528):    at dalvik.system.NativeStart.main(Native Method)
    D/AndroidRuntime( 1528): Shutting down VM
    W/dalvikvm( 1528): threadid=1: thread exiting with uncaught exception (group=0xa4d82b20)
    E/AndroidRuntime( 1528): FATAL EXCEPTION: main
    E/AndroidRuntime( 1528): Process: com.wnafee.vector.compat.demo, PID: 1528
    E/AndroidRuntime( 1528): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wnafee.vector.compat.demo/com.wnafee.vector.compat.demo.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class com.wnafee.vector.MorphButton
    E/AndroidRuntime( 1528):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
    E/AndroidRuntime( 1528):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
    E/AndroidRuntime( 1528):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    E/AndroidRuntime( 1528):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    E/AndroidRuntime( 1528):    at android.os.Handler.dispatchMessage(Handler.java:102)
    E/AndroidRuntime( 1528):    at android.os.Looper.loop(Looper.java:136)
    E/AndroidRuntime( 1528):    at android.app.ActivityThread.main(ActivityThread.java:5001)
    E/AndroidRuntime( 1528):    at java.lang.reflect.Method.invokeNative(Native Method)
    E/AndroidRuntime( 1528):    at java.lang.reflect.Method.invoke(Method.java:515)
    E/AndroidRuntime( 1528):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    E/AndroidRuntime( 1528):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    E/AndroidRuntime( 1528):    at dalvik.system.NativeStart.main(Native Method)
    E/AndroidRuntime( 1528): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class com.wnafee.vector.MorphButton
    E/AndroidRuntime( 1528):    at android.view.LayoutInflater.createView(LayoutInflater.java:620)
    E/AndroidRuntime( 1528):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
    E/AndroidRuntime( 1528):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
    E/AndroidRuntime( 1528):    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    E/AndroidRuntime( 1528):    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    E/AndroidRuntime( 1528):    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
    E/AndroidRuntime( 1528):    at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:240)
    E/AndroidRuntime( 1528):    at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
    E/AndroidRuntime( 1528):    at com.wnafee.vector.compat.demo.MainActivity.onCreate(MainActivity.java:27)
    E/AndroidRuntime( 1528):    at android.app.Activity.performCreate(Activity.java:5231)
    E/AndroidRuntime( 1528):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    E/AndroidRuntime( 1528):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
    E/AndroidRuntime( 1528):    ... 11 more
    E/AndroidRuntime( 1528): Caused by: java.lang.reflect.InvocationTargetException
    E/AndroidRuntime( 1528):    at java.lang.reflect.Constructor.constructNative(Native Method)
    E/AndroidRuntime( 1528):    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    E/AndroidRuntime( 1528):    at android.view.LayoutInflater.createView(LayoutInflater.java:594)
    E/AndroidRuntime( 1528):    ... 22 more
    E/AndroidRuntime( 1528): Caused by: java.lang.NullPointerException
    E/AndroidRuntime( 1528):    at com.wnafee.vector.compat.AnimatedVectorDrawable.inflate(AnimatedVectorDrawable.java:229)
    E/AndroidRuntime( 1528):    at com.wnafee.vector.compat.AnimatedVectorDrawable.create(AnimatedVectorDrawable.java:204)
    E/AndroidRuntime( 1528):    at com.wnafee.vector.compat.AnimatedVectorDrawable.getDrawable(AnimatedVectorDrawable.java:185)
    E/AndroidRuntime( 1528):    at com.wnafee.vector.compat.ResourcesCompat.getDrawable(ResourcesCompat.java:44)
    E/AndroidRuntime( 1528):    at com.wnafee.vector.MorphButton.<init>(MorphButton.java:79)
    E/AndroidRuntime( 1528):    at com.wnafee.vector.MorphButton.<init>(MorphButton.java:58)
    E/AndroidRuntime( 1528):    ... 25 more
    W/ActivityManager(  511):   Force finishing activity com.wnafee.vector.compat.demo/.MainActivity
    

    upgrading to a newer build tools (22.0.1, for example) fixes this problem. filing this ticket for two reasons:

    1. to serve as a warning if anyone else runs into this problem
    2. to investigate and see whether this is broken due to a bug in the build tools (if so, the action item should just be to clearly document it so others don't run into it), or if it's something else.
    opened by ahmedre 3
  • Problem with setting VectorDrawables via setCompoundDrawables on a Button

    Problem with setting VectorDrawables via setCompoundDrawables on a Button

    I'm trying to use the vector drawables on a button, specifically the drawableLeft and drawableRight attributes. This is done in code like this:

        Drawable drawable = ResourcesCompat.getDrawable(context, R.drawable.vector_icon);
        button.setCompoundDrawables(drawable, null, null, null);
    

    However, if I put the same drawable inside an ImageView via setDrawable, then it works:

        imageView.setImageDrawable(drawable);
    

    This seems to be happening on 5.0, 4.4 and 4.3. And interestingly the drawable on the button would actually draw if I have an image view also visible in the view using the same drawable.

    opened by zaichang 2
  • Question About Installing The Library

    Question About Installing The Library

    Hey! I'm new to support libraries to please bear with me! I'm confused about how one installs the library: -Should I download the .pom or the .aar file? -Where should I put the file? Thanks for your help! (I'm using Android Studio and the Android SDK.)

    opened by averydelmiller 2
  • Add setColorFilter method to MorphButton.

    Add setColorFilter method to MorphButton.

    VectorDrawable and AnimatedVectorDrawable both support setColorFilter, but there's no easy way to apply the color filter to a MorphButton. This adds a method which proxies the setColorFilter calls to the respective drawables if they are set.

    opened by ahmedre 2
  • Color

    Color

    Quick question for ya, I'm still learning where to find everything but I cannot seem to locate where to change the color of the actual button, I can change the background and the foreground color but not the button. If you can point me to it, that would be fantastic!

    opened by Burdhan 1
  • app:vc_autoStartAnimation=

    app:vc_autoStartAnimation="false" doesn't work!

    I want to manually handle animation changes in code so I tried to set app:vc_autoStartAnimation="false" like this:

                    <com.wnafee.vector.MorphButton
                        android:id="@+id/play_pause"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        app:srcCompat="@drawable/ic_play"
                        app:vc_startDrawable="@drawable/ic_pause_to_play"
                        app:vc_endDrawable="@drawable/ic_play_to_pause"
                        app:vc_autoStartAnimation="false"
                        android:onClick="play_pause"/>
    

    But even if I remove the onClick function it autostarts when touching it on the smartphone! Is there any other possibility to do this?

    opened by thatDudo 0
  • can we make vector drawable from svg file programmatically?

    can we make vector drawable from svg file programmatically?

    Hello, Nice insightful library. I shall be very grateful if you could help me in this issue. I have svg file and want to convert it in to Vector Drawable programmatically. Please help in this. Looking forward to hear from you.

    opened by tulaParekh 0
  • compileSdkVersion 26  minSdkVersion 19   buildToolsVersion

    compileSdkVersion 26 minSdkVersion 19 buildToolsVersion "26.0.2"

    E/AndroidRuntime: FATAL EXCEPTION: main Process: com.wnafee.vector.compat.demo, PID: 2360 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wnafee.vector.compat.demo/com.wnafee.vector.compat.demo.MainActivity}: android.view.InflateException: Binary XML file line #0: Error inflating class com.wnafee.vector.MorphButton at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.wnafee.vector.MorphButton at android.view.LayoutInflater.createView(LayoutInflater.java:621) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.wnafee.vector.compat.demo.MainActivity.onCreate(MainActivity.java:37) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)  at android.app.ActivityThread.access$800(ActivityThread.java:135)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5017)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.createView(LayoutInflater.java:595) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.wnafee.vector.compat.demo.MainActivity.onCreate(MainActivity.java:37)  at android.app.Activity.performCreate(Activity.java:5231)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)  at android.app.ActivityThread.access$800(ActivityThread.java:135)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5017)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)  at dalvik.system.NativeStart.main(Native Method)  Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/ic_arrow_vector.png from xml type xml resource ID #0x7f060054 at android.content.res.Resources.loadXmlResourceParser(Resources.java:2361) at android.content.res.Resources.loadXmlResourceParser(Resources.java:2316) at android.content.res.Resources.getXml(Resources.java:988) at com.wnafee.vector.compat.VectorDrawable.create(VectorDrawable.java:290) at com.wnafee.vector.compat.AnimatedVectorDrawable.inflate(AnimatedVectorDrawable.java:229) at com.wnafee.vector.compat.AnimatedVectorDrawable.create(AnimatedVectorDrawable.java:204) at com.wnafee.vector.compat.AnimatedVectorDrawable.getDrawable(AnimatedVectorDrawable.java:185) at com.wnafee.vector.compat.ResourcesCompat.getDrawable(ResourcesCompat.java:44) at com.wnafee.vector.MorphButton.setStartDrawable(MorphButton.java:282) at com.wnafee.vector.MorphButton.(MorphButton.java:141) at com.wnafee.vector.MorphButton.(MorphButton.java:113) at java.lang.reflect.Constructor.constructNative(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  at android.view.LayoutInflater.createView(LayoutInflater.java:595)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.wnafee.vector.compat.demo.MainActivity.onCreate(MainActivity.java:37)  at android.app.Activity.performCreate(Activity.java:5231)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)  at android.app.ActivityThread.access$800(ActivityThread.java:135)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5017)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.io.FileNotFoundException: Corrupt XML binary file at android.content.res.AssetManager.openXmlAssetNative(Native Method) at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:488) at android.content.res.Resources.loadXmlResourceParser(Resources.java:2343) at android.content.res.Resources.loadXmlResourceParser(Resources.java:2316)  at android.content.res.Resources.getXml(Resources.java:988)  at com.wnafee.vector.compat.VectorDrawable.create(VectorDrawable.java:290)  at com.wnafee.vector.compat.AnimatedVectorDrawable.inflate(AnimatedVectorDrawable.java:229)  at com.wnafee.vector.compat.AnimatedVectorDrawable.create(AnimatedVectorDrawable.java:204)  at com.wnafee.vector.compat.AnimatedVectorDrawable.getDrawable(AnimatedVectorDrawable.java:185)  at com.wnafee.vector.compat.ResourcesCompat.getDrawable(ResourcesCompat.java:44)  at com.wnafee.vector.MorphButton.setStartDrawable(MorphButton.java:282)  at com.wnafee.vector.MorphButton.(MorphButton.java:141)  at com.wnafee.vector.MorphButton.(MorphButton.java:113)  at java.lang.reflect.Constructor.constructNative(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  at android.view.LayoutInflater.createView(LayoutInflater.java:595)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.wnafee.vector.compat.demo.MainActivity.onCreate(MainActivity.java:37)  at android.app.Activity.performCreate(Activity.java:5231)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)  at android.app.ActivityThread.access$800(ActivityThread.java:135)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5017)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)  at dalvik.system.NativeStart.main(Native Method) 

    opened by HotHat 0
  • Failed when try animate property trimPathEnd

    Failed when try animate property trimPathEnd

    Failed when try animate property trimPathEnd or try animate clip-path with pathData property.

    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/iid/InstanceID; at com.b.h.run(AppsFlyerLib.java:232) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.iid.InstanceID" on path: DexPathList[[zip file "/data/app/com.tarasovmobile.gtd-2/base.apk"],nativeLibraryDirectories=[/data/app/com.tarasovmobile.gtd-2/lib/arm, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at com.b.h.run(AppsFlyerLib.java:232)  at java.lang.Thread.run(Thread.java:818)  Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.iid.InstanceID at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 3 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

    opened by m4xp1 0
  • How to change StartDrawable and EndDrawable res programly?

    How to change StartDrawable and EndDrawable res programly?

    I tried:

     mButton.setStartDrawable(VectorDrawable.getDrawable(this, R.drawable.ic_play));
     mButton.setEndDrawable(VectorDrawable.getDrawable(this, R.drawable.ic_pause));
    

    Error is:

     java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Rect android.graphics.drawable.Drawable.getBounds()' on a null object reference
    

    I tried:

     mButton.setStartDrawable(AnimatedVectorDrawable.getDrawable(this, R.drawable.ic_play_animatable));
     mButton.setEndDrawable(AnimatedVectorDrawable.getDrawable(this, R.drawable.ic_pause_animatable));
    

    Error is:

     java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Rect android.graphics.drawable.Drawable.getBounds()' on a null object reference
    
    opened by Kolyall 0
Owner
Wael N
Wael N
Utility library that utilizes KSP to generate Room type converter classes.

Roomie Roomie is an annotation processing library that utilizes KSP to geaRoomie is an annotation processing library that utilizes KSP to generate TypeConverter classes for Room. TypeConverter classes most often involve same boiler-plate code and Roomie makes it really easy to quickly create them with a single annotation.nerate TypeConverter classes for Room. TypeConverter classes most often invol

Chukwuka Eze 12 Aug 26, 2022
A set of helper classes for using dagger 1 with Android components such as Applications, Activities, Fragments, BroadcastReceivers, and Services.

##fb-android-dagger A set of helper classes for using dagger with Android components such as Applications, Activities, Fragments, BroadcastReceivers,

Andy Dennie 283 Nov 11, 2022
FractalUtils - A collection of utility functions and classes, with an emphasis on game related utilities

A collection of utility functions and classes written in Kotlin. There is some emphasis on utilities useful for games (Geometry, Random, Time, Updating, etc).

null 2 Nov 11, 2022
A library to quickly and easily enable multiple monitoring & support platforms for your mobile apps

You have a small team. Setting up crash reporting tools, event tracking tools, and log management services is not what you want to spend your hours do

Percolate 65 Aug 8, 2022
a SharedPreferences replacement for Android with multiprocess support

DEPRECATED - no longer actively maintained Tray - a SharedPreferences replacement for Android If you have read the documentation of the SharedPreferen

HCI @ gcx 2.3k Nov 17, 2022
Long-term support releases of Birday updated with the latest translations

Note: this document is still a work in progress. Birday LTS This repository is based on the 2.1.0 release of https://github.com/m-i-n-a-r/birday. You

Dominik Novosel 1 May 16, 2022
A library for fast and safe delivery of parameters for Activities and Fragments.

MorbidMask - 吸血面具 Read this in other languages: 中文, English, Change Log A library for fast and safe delivery of parameters for Activities and Fragment

Season 67 Mar 29, 2022
A simple and easy to use stopwatch and timer library for android

TimeIt Now with Timer support! A simple and easy to use stopwatch and timer library for android Introduction A stopwatch can be a very important widge

Yashovardhan Dhanania 35 Dec 10, 2022
Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platform the code is running.

Trail Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platfor

Mauricio Togneri 13 Aug 29, 2022
UPnP/DLNA library for Java and Android

Cling EOL: This project is no longer actively maintained, code may be outdated. If you are interested in maintaining and developing this project, comm

4th Line 1.6k Jan 4, 2023
Android library for viewing, editing and sharing in app databases.

DbInspector DbInspector provides a simple way to view the contents of the in-app database for debugging purposes. There is no need to pull the databas

Infinum 924 Jan 4, 2023
Android library to easily serialize and cache your objects to disk using key/value pairs.

Deprecated This project is no longer maintained. No new issues or pull requests will be accepted. You can still use the source or fork the project to

Anup Cowkur 667 Dec 22, 2022
A small library which will save you from writing the same intent creation code again and again for the most simple tasks

Android Intents A small library which will save you from writing the same intent creation code again and again for the most simple tasks. I found myse

MarvinLabs 420 Nov 20, 2022
Error handling library for Android and Java

ErrorHandler Error handling library for Android and Java Encapsulate error handling logic into objects that adhere to configurable defaults. Then pass

null 237 Dec 29, 2022
Small Android library to help you incorporate MVP, Passive View and Presentation Model patterns in your app

DroidMVP About DroidMVP is a small Android library to help you incorporate the MVP pattern along with Passive View and Presentation Model (yes, those

Andrzej Chmielewski 225 Nov 29, 2022
A simple Android utils library to write any type of data into cache files and read them later.

CacheUtilsLibrary This is a simple Android utils library to write any type of data into cache files and then read them later, using Gson to serialize

Wesley Lin 134 Nov 25, 2022
A lightweight library for config and using SharedPreferences

preferences-helper SharePreferences is very popular with any project and all most all project has SharePreferences for saving data. This library will

Khang Tran 23 May 8, 2021
SharedPreference Library to save all types including your custom types and observe them if need be.

A SharedPreference Library that can be used to store all types including your custom classes and observe them too if needed.

Ehma Ugbogo 18 Nov 10, 2021
🐫🐍🍢🅿 Multiplatform Kotlin library to convert strings between various case formats including Camel Case, Snake Case, Pascal Case and Kebab Case

KaseChange Multiplatform Kotlin library to convert strings between various case formats Supported Case Formats SCREAMING_SNAKE_CASE snake_case PascalC

PearX Team 67 Dec 30, 2022