java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:696)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:659)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:552)
at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
at com.yanzhenjie.permission.task.WaitDialog.<init>(WaitDialog.java:32)
at com.yanzhenjie.permission.task.TaskExecutor.<init>(TaskExecutor.java:35)
at com.yanzhenjie.permission.runtime.MRequest$1.<init>(MRequest.java:101)
at com.yanzhenjie.permission.runtime.MRequest.onCallback(MRequest.java:101)
at com.yanzhenjie.permission.runtime.MRequest.start(MRequest.java:81)
AppCompatDelegateImpl.createSubDecor具体报异常的源码:
TypedArray a = mContext.obtainStyledAttributes(R.styleable.AppCompatTheme);
if (!a.hasValue(R.styleable.AppCompatTheme_windowActionBar)) {
a.recycle();
throw new IllegalStateException(
"You need to use a Theme.AppCompat theme (or descendant) with this activity.");
}
手机型号:华为 Mate 9 品牌系统版本:EMUI 9.1 Android系统版本: 9 targetSdkVersion:28 权限:Permission.RECORD_AUDIO
调用AndPermission.with(this).runtime().permission(Permission.Group.MICROPHONE).onGranted(...).start()就报异常了,看起来是因为WaitDialog继承了AppCompatDialog但是设置的style缺少了AppCompat必需的属性,我确认了一下androidx.appcompat的版本是1.1.0
AppCompatDelegateImpl.createSubDecor具体报异常的源码: