Reputation: 6731
I have this code:
import static com.example.test.Utils.getPackageManagerReflection;
...
public class MainActivity extends AppCompatActivity {
...
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
PackageManager packageManagerReflection;
try {
packageManagerReflection = getPackageManagerReflection(...);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if(packageManagerReflection == null) {
finish();
return;
}
}
...
}
com.example.test.Utils.getPackageManagerReflection:
public static <A, B> B getPackageManagerReflection(A param1, Class<B> param2, byte[] param2, Object param4) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
...
}
Analyzing the generated apk with Android Studio, in classes.dex there is packageManagerReflection clearly readable, but getPackageManagerReflection
doesn't:
.line 225
.end local v2 # "packageManagerReflection":Landroid/content/pm/PackageManager;
.end local v3 # "deviceId":Ljava/lang/String;
.end local v5 # "exception":Ljava/lang/IllegalArgumentException;
:catch_301
move-exception v2
.line 231
.local v2, "packageManagerReflection":Landroid/content/pm/PackageManager;
nop
I'm using the latest version of Android Studio and all its components.
Why the name for member packageManagerReflection
is keeped in the generated code?
I already tried to rename it to something different without reflection
in its name (e.g. packageManagerRef
but it still compare in classes.dex.
I also already seen in seeds.txt
, mapping.txt
and usage.txt
in app/build/outputs/mapping/debug
but there is no occurrence for it.
Thanks a lot!
Upvotes: 0
Views: 616
Reputation: 583
Local variable names would be expected to be stripped in release versions of an app, they aren't necessary for execution (and aren't available through reflection). Thus, R8 wouldn't need to and doesn't rename them. Try looking for the same information in a release build, it shouldn't be present.
Upvotes: 2