如何修复“ java.lang.NoSuchMethodError:android.graphics.Canvas.drawArc”

时间:2019-01-12 11:22:27

标签: android

我尝试为我的项目制作动画登录应用程序,但无法正常工作

我的方法如下:

const obj = {
  id: 50,
  code: 112,
  applicant: "individual", 
  application_id: 53, 
  appref: "ZAK00053", 
  date: "2019-01-11", 
};
const index = Object.keys(obj).indexOf('applicant');
const values = Object.values(obj).slice(index);
console.log(values);

以及我出错的部分

 @Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isLogin) {
        canvas.drawText(getString(R.string.sign_up), width / 2, dpToPixels(457), signUpPaint);
    } else {
        canvas.drawText(getString(R.string.login), width / 2, dpToPixels(457), loginPaint);
    }

    if (isLogin) {
        canvas.drawPath(loginButtonPath, loginButtonPaint);
        canvas.drawArc(
                currentRight - getButtonHeight() / 2 + currentArcX,
                buttonTop,
                currentRight + getButtonHeight() / 2 - currentArcX,
                buttonBottom,
                0,
                360,
                false,
                loginButtonPaint);

        canvas.drawText(getString(R.string.or), loginOrX, buttonCenter + dpToPixels(8), orPaint);
        canvas.drawText(getString(R.string.login), currentLoginX, currentLoginY, loginPaint);
    } else {
        canvas.drawPath(signUpButtonPath, signUpButtonPaint);
        canvas.drawArc(
                currentLeft - getButtonHeight() / 2 + currentArcX,
                buttonTop,
                currentLeft + getButtonHeight() / 2 - currentArcX,
                buttonBottom,
                0,
                360,
                false,
                signUpButtonPaint);

        canvas.drawText(getString(R.string.or), signUpOrX, buttonCenter + dpToPixels(8), orPaint);

        canvas.drawText(getString(R.string.sign_up), currentSignUpTextX, currentSignUpTextY, signUpPaint);
    }
}

在这里我得到了错误:

  

进程:com.myhexaville.login,PID:2758       java.lang.NoSuchMethodError:android.graphics.Canvas.drawArc           在com.myhexaville.login.login.LoginButton.onDraw(LoginButton.java:230)           在android.view.View.draw(View.java:14465)           在android.view.View.getDisplayList(View.java:13362)           在android.view.View.getDisplayList(View.java:13404)

我找不到该语法的任何解决方案。需要帮助

  

01-12 15:33:26.467 2758-2758 /? E / AndroidRuntime:致命异常:main       流程:com.myhexaville.login,PID:2758       java.lang.NoSuchMethodError:android.graphics.Canvas.drawArc           在com.myhexaville.login.login.LoginButton.onDraw(LoginButton.java:230)

0 个答案:

没有答案