类型的非法开始,预期 <identifier>,';'预期错误
illegal start of type, <identifier> expected, ';' expected errors
我试图设置只有当构建类型是 eng 时它才会显示构建号。但是编译的时候出现了很多错误:
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:106: error: illegal start of type
if (android.os.Build.TYPE.equals("eng")) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:106: error: <identifier> expected
if (android.os.Build.TYPE.equals("eng")) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:106: error: illegal start of type
if (android.os.Build.TYPE.equals("eng")) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:108: error: ';' expected
public void onChange(boolean selfChange, Uri uri) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:108: error: ';' expected
public void onChange(boolean selfChange, Uri uri) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:108: error: not a statement
public void onChange(boolean selfChange, Uri uri) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:108: error: ';' expected
public void onChange(boolean selfChange, Uri uri) {
^
你的代码有问题,请检查这个函数
private final ContentObserver mDeveloperSettingsObserver = new ContentObserver(
new Handler(mContext.getMainLooper())) {
if (android.os.Build.TYPE.equals("eng")) {
@Override
public void onChange(boolean selfChange, Uri uri) {
super.onChange(selfChange, uri);
setBuildText();
}
}
};
// new Handler(...) { }, is a functional interface and you can only write inside th `onChange` method , curly braces after constructor is class body, you cannot write statements there, so put your checks inside the function. It will compile.
我可以在 L104 到 L113 行看到问题。您正在尝试基于不允许的 if 条件覆盖方法。您需要将条件放在方法定义本身中。
private final ContentObserver mDeveloperSettingsObserver = new ContentObserver(
new Handler(mContext.getMainLooper())) {
@Override
public void onChange(boolean selfChange, Uri uri) {
super.onChange(selfChange, uri);
// put if condition here
if (android.os.Build.TYPE.equals("eng")) {
setBuildText();
}
}
};
其语法错误大括号未正确闭合
试试这个:
private final ContentObserver mDeveloperSettingsObserver = new ContentObserver(
new Handler(mContext.getMainLooper()) {
@Override
public void onChange(boolean selfChange, Uri uri) {
if (android.os.Build.TYPE.equals("eng")) {
super.onChange(selfChange, uri);
setBuildText();
}
}});
我试图设置只有当构建类型是 eng 时它才会显示构建号。但是编译的时候出现了很多错误:
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:106: error: illegal start of type
if (android.os.Build.TYPE.equals("eng")) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:106: error: <identifier> expected
if (android.os.Build.TYPE.equals("eng")) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:106: error: illegal start of type
if (android.os.Build.TYPE.equals("eng")) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:108: error: ';' expected
public void onChange(boolean selfChange, Uri uri) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:108: error: ';' expected
public void onChange(boolean selfChange, Uri uri) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:108: error: not a statement
public void onChange(boolean selfChange, Uri uri) {
^
error: /home/android/lineage-17.1/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java:108: error: ';' expected
public void onChange(boolean selfChange, Uri uri) {
^
你的代码有问题,请检查这个函数
private final ContentObserver mDeveloperSettingsObserver = new ContentObserver(
new Handler(mContext.getMainLooper())) {
if (android.os.Build.TYPE.equals("eng")) {
@Override
public void onChange(boolean selfChange, Uri uri) {
super.onChange(selfChange, uri);
setBuildText();
}
}
};
// new Handler(...) { }, is a functional interface and you can only write inside th `onChange` method , curly braces after constructor is class body, you cannot write statements there, so put your checks inside the function. It will compile.
我可以在 L104 到 L113 行看到问题。您正在尝试基于不允许的 if 条件覆盖方法。您需要将条件放在方法定义本身中。
private final ContentObserver mDeveloperSettingsObserver = new ContentObserver(
new Handler(mContext.getMainLooper())) {
@Override
public void onChange(boolean selfChange, Uri uri) {
super.onChange(selfChange, uri);
// put if condition here
if (android.os.Build.TYPE.equals("eng")) {
setBuildText();
}
}
};
其语法错误大括号未正确闭合
试试这个:
private final ContentObserver mDeveloperSettingsObserver = new ContentObserver(
new Handler(mContext.getMainLooper()) {
@Override
public void onChange(boolean selfChange, Uri uri) {
if (android.os.Build.TYPE.equals("eng")) {
super.onChange(selfChange, uri);
setBuildText();
}
}});