-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fields are not initialized after setContentView [core] #1599
Comments
@redmi111 can you share a sample for this issue? Also share class which contains this code. Without this, it is hard to understand the issue. |
Here is the APK and you can find this inside ExitDialog class |
@redmi111 If you look at the smali code then you will see that the decompiled code is correct, they are initialized in |
Understood, Thanks for the clarification. |
As I understand @redmi111 point to the incorrect initialization order and indeed this is an issue here. StringBuilder sb;
int field;
public TestCls() {
initBuilder(new StringBuilder("sb"));
this.field = initField();
this.sb.append(this.field);
}
private void initBuilder(StringBuilder sb) {
this.sb = sb;
}
private int initField() {
return sb.length();
} Decompiled code: int field = initField();
StringBuilder sb;
public TestCls() {
initBuilder(new StringBuilder("sb"));
this.sb.append(this.field);
}
... Decompiled code throw NPE from |
Fixed. |
Fields on the image are supposed to be initialized after setContentView because right now in this way objects are null since they're not initialized properly.
v1.4.3
![image](https://user-images.githubusercontent.com/35992798/182283361-e934d815-4ca9-44ed-be8b-8e428bca0a91.png)
P.S: Those are global variable and not inside onCreate method and that's the problem (trying to initialize in the field declaration itself)
The text was updated successfully, but these errors were encountered: