I've been bothered for a long time About How to calculate the number of variables in the smali file during decompilation what i need is:One idea, one solution, one light bulb!
def parse_smali_field_num(smali_path):
count = 0
with open(smali_path, 'r', 4096, 'utf-8') as f:
text = f.readline()
if (not text.startswith('.class')):
print('Warning:Not a class smali file:' + str(smali_path))
return 0
while (text):
text = f.readline()
if (text.startswith('.field')):
count += 1
return count