Open miketrinh1995 opened 7 years ago
Same here
Same here
Same here
Same.. is there a fix ?
i just downgraded build gradle tools version to 'com.android.tools.build:gradle:2.3.3' for example to run my projects , i believe it's not the perfect solution. but it's helpful until this bug fixed with the new build gradle tools
Me too. Please help!
Same issue here.
Nobody has the solution for this issue. Anybody know another library like this?
There is a solution: you just need to remove it from build.gradle and import it as a module. Then need to delete 3 lines from build.gradle of the library: version, group and apply from... And add it to your app: Project structure -> Modules -> yourmodule-> dependencies
It still doesn't work for me. Still getting this error: java.lang.RuntimeException: Unknown animation name: cn.pedant.SweetAlert.Rotate3dAnimation error:null
Are you sure you commented out it from build.gradle? // compile 'cn.pedant.sweetalert:library:1.3'
I did that, but now I got a new error: Unable to resolve dependency for ':app@appNameDebug/compileClasspath': Could not resolve project :sweetalertdialog.
But now I fixed it by putting this in my build.gradle: compile project(':library')
Since I could not choose 'compile'
Now it works, thank you
i solved this error by modify the source code the mothod createAnimationFromXml from Class OptAnimationLoader add } else if (name.equals("YOURPATH.Rotate3dAnimation")) { anim = new Rotate3dAnimation(c, attrs); }
@JokerHYC Can you show more details. Step by step. Thank you so much!
Same Here
@JokerHYC what do you mean by "YOURPATH"?
have any solution?
I found the solution. https://jitpack.io/p/Leogiroux/sweet-alert-dialog .
same error
me too! come on baby...
Fork from this guy is useful. https://github.com/F0RIS/sweet-alert-dialog
NO above issue. He has also added custom views to SweetAlertDialog.
BTW, for those still following this thread:
This is happening because it's failing to turn the 50%
string from pivotX
/ pivotY
into the integer '50', which it needs.
It's failing on this line in OptAnimationLoader.java
, specifically the call to .newInstance(c, attrs);
anim = (Animation) Class.forName(name).getConstructor(Context.class, AttributeSet.class).newInstance(c, attrs);
I forked the repo and changed 50%
to 50
and it worked. This is the error I was seeing:
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)
For the record, this repo is unmaintained, and everyone should switch over to @thomper 's fork at https://github.com/pedant/sweet-alert-dialog/ which works perfectly (thanks @thomper !!).
https://github.com/F0RIS/sweet-alert-dialog
this works for me .
https://github.com/F0RIS/sweet-alert-dialog
this worked for me
just change android.enableAapt2=false in gradle.properties but layout stops show previews
i have got the solution no thing to do use same compile 'cn.pedant.sweetalert:library:1.3' and copy the 2 file from library and first
import android.content.Context; import android.content.res.TypedArray; import android.graphics.Camera; import android.graphics.Matrix; import android.util.AttributeSet; import android.util.TypedValue; import android.view.animation.Animation; import android.view.animation.Transformation; import cn.pedant.SweetAlert.sample.R;
public class Rotate3dAnimation extends Animation { private int mPivotXType = ABSOLUTE; private int mPivotYType = ABSOLUTE; private float mPivotXValue = 0.0f; private float mPivotYValue = 0.0f;
private float mFromDegrees;
private float mToDegrees;
private float mPivotX;
private float mPivotY;
private Camera mCamera;
private int mRollType;
public static final int ROLL_BY_X = 0;
public static final int ROLL_BY_Y = 1;
public static final int ROLL_BY_Z = 2;
protected static class Description {
public int type;
public float value;
}
Description parseValue(TypedValue value) {
Description d = new Description();
if (value == null) {
d.type = ABSOLUTE;
d.value = 0;
} else {
if (value.type == TypedValue.TYPE_FRACTION) {
d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
d.value = TypedValue.complexToFloat(value.data);
return d;
} else if (value.type == TypedValue.TYPE_FLOAT) {
d.type = ABSOLUTE;
d.value = value.getFloat();
return d;
} else if (value.type >= TypedValue.TYPE_FIRST_INT &&
value.type <= TypedValue.TYPE_LAST_INT) {
d.type = ABSOLUTE;
d.value = value.data;
return d;
}
}
d.type = ABSOLUTE;
d.value = 0.0f;
return d;
}
public Rotate3dAnimation (Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Rotate3dAnimation);
mFromDegrees = a.getFloat(R.styleable.Rotate3dAnimation_fromDeg, 0.0f);
mToDegrees = a.getFloat(R.styleable.Rotate3dAnimation_toDeg, 0.0f);
mRollType = a.getInt(R.styleable.Rotate3dAnimation_rollType, ROLL_BY_X);
Description d = parseValue(a.peekValue(R.styleable.Rotate3dAnimation_pivotX));
mPivotXType = d.type;
mPivotXValue = d.value;
d = parseValue(a.peekValue(R.styleable.Rotate3dAnimation_pivotY));
mPivotYType = d.type;
mPivotYValue = d.value;
a.recycle();
initializePivotPoint();
}
public Rotate3dAnimation (int rollType, float fromDegrees, float toDegrees) {
mRollType = rollType;
mFromDegrees = fromDegrees;
mToDegrees = toDegrees;
mPivotX = 0.0f;
mPivotY = 0.0f;
}
public Rotate3dAnimation (int rollType, float fromDegrees, float toDegrees, float pivotX, float pivotY) {
mRollType = rollType;
mFromDegrees = fromDegrees;
mToDegrees = toDegrees;
mPivotXType = ABSOLUTE;
mPivotYType = ABSOLUTE;
mPivotXValue = pivotX;
mPivotYValue = pivotY;
initializePivotPoint();
}
public Rotate3dAnimation (int rollType, float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) {
mRollType = rollType;
mFromDegrees = fromDegrees;
mToDegrees = toDegrees;
mPivotXValue = pivotXValue;
mPivotXType = pivotXType;
mPivotYValue = pivotYValue;
mPivotYType = pivotYType;
initializePivotPoint();
}
private void initializePivotPoint() {
if (mPivotXType == ABSOLUTE) {
mPivotX = mPivotXValue;
}
if (mPivotYType == ABSOLUTE) {
mPivotY = mPivotYValue;
}
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
mCamera = new Camera();
mPivotX = resolveSize(mPivotXType, mPivotXValue, width, parentWidth);
mPivotY = resolveSize(mPivotYType, mPivotYValue, height, parentHeight);
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final Matrix matrix = t.getMatrix();
mCamera.save();
switch (mRollType) {
case ROLL_BY_X:
mCamera.rotateX(degrees);
break;
case ROLL_BY_Y:
mCamera.rotateY(degrees);
break;
case ROLL_BY_Z:
mCamera.rotateZ(degrees);
break;
}
mCamera.getMatrix(matrix);
mCamera.restore();
matrix.preTranslate(-mPivotX, -mPivotY);
matrix.postTranslate(mPivotX, mPivotY);
}
}
then anim/error_in_frame.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sweet="http://schemas.android.com/apk/res-auto" android:interpolator="@android:anim/linear_interpolator" android:shareInterpolator="true">
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:duration="400"/>
<sweet: com.packagename.Rotate3dAnimation
sweet:rollType="x"
sweet:fromDeg="100"
sweet:toDeg="0"
sweet:pivotX="50%"
sweet:pivotY="50%"
android:duration="400"/>
For those who are still following the issue: Please find below the link to fixed version of the library.
https://jitpack.io/#AbhisheKundalia/sweet-alert-dialog/v2.0.0
This supports latest android SDK.
@AbhisheKundalia you could just do PR but not another one fork, more forks - more confusion for people, which they should use. I update my repo, now it works with Android Studio 3.0 too
java.lang.RuntimeException appears in Android Studio 3.X using Sweet Alert Dialog: Unknown animation name: cn.pedant.SweetAlert.Rotate3dAnimation error: null error
I read a lot of blogs on the Internet and said that using Sweet Alert Dialog has encountered similar problems. The solution is very strange. Some say that it is to download lib and import it into the project.
Some say it is a confusion problem, in fact, the solution is very simple, you can change the added dependency library.
Errored library, comment out
implementation 'cn.pedant.sweetalert:library:1.3'
Add the following library
implementation 'com.github.f0ris.sweetalert:library:1.5.1
Ok run again, problem solving
On click to show dialog, this error " java.lang.RuntimeException: Unknown animation name: cn.pedant.SweetAlert.Rotate3dAnimation error:null" Please help me!