java.lang.NullPointerException on emulator running 19 api
The library works on android 5.1 and above(both emulators and real phones) and there is no problem. However, when I ran my app on the emulator(19 level API), the app got crashed. I don't know whether there is the same problem on the real phone running 19 API.
Stacktrace:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.app.test, PID: 4578 java.lang.NullPointerException at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:505) at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:487) at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:517) at android.animation.ValueAnimator.start(ValueAnimator.java:936) at android.animation.ValueAnimator.start(ValueAnimator.java:946) at android.animation.ObjectAnimator.start(ObjectAnimator.java:465) at android.animation.AnimatorSet.start(AnimatorSet.java:563) at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.d(CircularProgressButton.java:513) at com.app.test.MainActivity.m(MainActivity.java:123) at com.app.test.MainActivity.onClick(MainActivity.java:54) at android.view.View.performClick(View.java:4438) at android.view.View$PerformClick.run(View.java:18422) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) 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)
The app crashes at line circularProgressButton.startAnimation();
Is the library compatible with emulators? And does it work with prelollipop devices?
The library works normally in emulators with API 19. You can test the sample of this repository in an emulator with API 19 to see that it works normally. Could you provide the code that made this bug, so I can help you?
I have same issue ! how i can solve this ?!
@sinadalvand Could you provide the code that made your crash? Or more detail about your problem?
Tested it on real devices (4.4.2 and 4.4.4), it works for me.
It works in those versions without problems. Maybe what caused those NPE was some specific usage, but I can't help without some code/details about the problem.
So, I created a new project which contains only one activity and only one xml. But issue is the same. Launched on emulator(19 API)
MainActivity.java
package com.example.homesystem.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import br.com.simplepass.loading_button_lib.customViews.CircularProgressButton;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
CircularProgressButton circularProgressButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
circularProgressButton = findViewById(R.id.circular_button);
circularProgressButton.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.circular_button:
circularProgressButton.startAnimation();
break;
}
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.homesystem.myapplication.MainActivity">
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="24dp">
<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
android:id="@+id/circular_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginBottom="8dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:text="Next"
app:spinning_bar_color="@color/colorPrimary" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
Stacktrace
FATAL EXCEPTION: main
Process: com.example.homesystem.myapplication, PID: 2970
java.lang.NullPointerException
at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:505)
at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:487)
at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:517)
at android.animation.ValueAnimator.start(ValueAnimator.java:936)
at android.animation.ValueAnimator.start(ValueAnimator.java:946)
at android.animation.ObjectAnimator.start(ObjectAnimator.java:465)
at android.animation.AnimatorSet.start(AnimatorSet.java:563)
at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.startAnimation(CircularProgressButton.java:513)
at com.example.homesystem.myapplication.MainActivity.onClick(MainActivity.java:25)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
Also I don't know whether this is important but when launching app I see this error in logs:
E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
I have the same issue. Not only on emulator but on Samsung Galaxy s3 too. 19 API
In my case crash happened when I had no target in ObjectAnimator that animates corners. For that moment mGradientDrawable was null. Solved by assigning some drawable in xml as a background.
This library was reimplemented. Try to use the version 2.0.6 instead of 1.14.0.