在Android Studio中使用Sweet Alert Dialog出现cn.pedant.SweetAlert.Rotate3dAnimation error:null错误解决方法

在Android Studio 3.1.3 中使用Sweet Alert Dialog出现java.lang.RuntimeException: Unknown animation name: cn.pedant.SweetAlert.Rotate3dAnimation error:null错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
java.lang.RuntimeException: Unknown animation name: cn.pedant.SweetAlert.Rotate3dAnimation error:null
at cn.pedant.SweetAlert.OptAnimationLoader.createAnimationFromXml(OptAnimationLoader.java:77)
at cn.pedant.SweetAlert.OptAnimationLoader.createAnimationFromXml(OptAnimationLoader.java:64)
at cn.pedant.SweetAlert.OptAnimationLoader.createAnimationFromXml(OptAnimationLoader.java:41)
at cn.pedant.SweetAlert.OptAnimationLoader.loadAnimation(OptAnimationLoader.java:22)
at cn.pedant.SweetAlert.SweetAlertDialog.<init>(SweetAlertDialog.java:80)
at lanweihong.com.activity.Login2Activity$1.onClick(Login2Activity.java:54)
at android.view.View.performClick(View.java:5655)
at android.view.View$PerformClick.run(View.java:22633)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:159)
at android.app.ActivityThread.main(ActivityThread.java:6378)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1099)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)

我的配置:

1
2
3
dependencies {
implementation 'cn.pedant.sweetalert:library:1.3'
}

解决方法:

使用com.github.f0ris.sweetalert:library:1.5.1替换原来的库:

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

参考: https://stackoverflow.com/questions/47195517/android-studio-3-0-error-with-sweet-alert-dialog-library