我在Android Studio上遇到一些麻烦,我的编码很好,并且在我跑到设备时起作用,但是当我generate signed APK
这是错误消息:
Error:(25) Error: This class should be public (com.myapp.SoundLevelView) [Instantiatable]
我的编码:
public SoundLevelView(Context context, AttributeSet attrs) {
super(context, attrs);
mGreen = context.getResources().getDrawable(
R.drawable.greenbar);
mRed = context.getResources().getDrawable(
R.drawable.redbar);
mWidth = mGreen.getIntrinsicWidth();
setMinimumWidth(mWidth*10);
mHeight = mGreen.getIntrinsicHeight();
setMinimumHeight(mHeight);
//Used to paint canvas background color
mBackgroundPaint = new Paint();
mBackgroundPaint.setColor(Color.BLACK);
}
我尝试从Android首选项中禁用皮棉,并添加
lintOptions {
abortOnError false
}
到我的成绩。内部Android标签。但是它似乎也行不通。有人面对我的问题吗?
注意:我也尝试使用Invalidated Cache and Restart
,但不起作用
尝试以下:
public class SoundLevelView(Context context, AttributeSet attrs) {
super(context, attrs);
mGreen = context.getResources().getDrawable(
R.drawable.greenbar);
mRed = context.getResources().getDrawable(
R.drawable.redbar);
mWidth = mGreen.getIntrinsicWidth();
setMinimumWidth(mWidth*10);
mHeight = mGreen.getIntrinsicHeight();
setMinimumHeight(mHeight);
//Used to paint canvas background color
mBackgroundPaint = new Paint();
mBackgroundPaint.setColor(Color.BLACK);
}