У меня был код для получения списка всех классов в пакете, который выглядел примерно так:
try {
DexFile df = new DexFile(context.getPackageCodePath());
for (Enumeration<String> iter = df.entries(); iter.hasMoreElements();) {
String s = iter.nextElement();
}
} catch (IOException e) {
e.printStackTrace();
}
Однако этот код перестал работать, так как я обновил свою Android Studio до версии 2.0. Я обнаружил, что виновником является Instant Run. Если я отлаживаю приложение, я вижу, что без запуска экземпляра переменная DexFile, df, содержит список имен классов (более 4000 из них). Когда Instant Run включен, я получаю около 30 имен классов, а классов, которые я ищу, нет. У меня есть ощущение, что это как-то связано с мультидексом, но я не уверен, как Instant Run работает под обложками (мое приложение не использует мультидекс).
Кто-нибудь знает, как я могу получить список таких классов с включенным Instant Run? Или кто-нибудь точно знает, почему я вижу такое поведение (было бы здорово это понять)?