Android studio 3.0 error with sweet-alert-dialog library

Viewed 18878

On click to show the dialog this error occurs

java.lang.RuntimeException: Unknown animation-name: cn.pedant.SweetAlert.Rotate3dAnimation error:null

Anybody have solution step by step?

9 Answers

Add this library to app/build.gradle:

dependencies {
    ...
    implementation 'com.github.f0ris.sweetalert:library:1.5.1'
}

Usage:

SweetAlertDialog pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE);
pDialog.getProgressHelper().setBarColor(Color.parseColor("#A5DC86"));
pDialog.setTitleText("Loading");
pDialog.setCancelable(false);
pDialog.show();

for more usages about progress read THIS.

I got the solution!

if you are using implementation 'cn.pedant.sweetalert:library:1.3' library, just add the below line in your proguard-rules.pro file.

-keep class cn.pedant.** { *; }

Add this library to app/build.gradle:

dependencies { ... implementation 'com.github.f0ris.sweetalert:library:1.5.1' }

This will solve your problem.

Add this to proguard-rules.pro

-keep class cn.pedant.SweetAlert.Rotate3dAnimation {
    public <init>(...);
 }

I resolved the issue by just changing

mErrorInAnim = OptAnimationLoader.loadAnimation(getContext(), R.anim.error_frame_in); 

to

mErrorInAnim =  (AnimationSet)OptAnimationLoader.loadAnimation(getContext(), R.anim.error_x_in); 

in the file SweetAlertDialog.java

happy coding..

Add the error_frame_in.xml animation file to the anim directory of res

enter image description here

Open the error_frame_in.xml file add the following code

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha
        android:fromAlpha="0"
        android:toAlpha="1"
        android:duration="400"/>
</set>

if you are using implementation 'com.github.f0ris.sweetalert:library:1.5.1' library, just add the below line in your proguard-rules.pro file in project section. It will work in the production version of your app. I tried and it worked perfectly.

-keep class cn.pedant.** { *; }
Related