Status Update
Comments
so...@google.com <so...@google.com> #2
com.android.tools.idea.model.AndroidModel.getAllApplicationIds
now returns all non-test application ids.
aa...@google.com <aa...@google.com> #3
Thanks Yuriy
I am about to change my code from:
override fun getPackageNames(): Set<String> =
moduleManager.modules.mapNotNullTo(mutableSetOf()) { AndroidModuleInfo.getInstance(it)?.`package` }
To:
override fun getPackageNames(): Set<String> =
moduleManager.modules.flatMapTo(mutableSetOf()) { AndroidModel.get(it)?.allApplicationIds ?: emptyList() }
When I tested it, I opened up a project and found that my new getPackageNames()
returned an empty set.
So, I recompiled to add some logging info but I can't repro. It now seems to work.
Can you think of any reason why this could happen? Is it possible that the project was in an unsynced state when I first loaded it but when I restarted AS after the code modifications, it had already synced?
I am considering making my code look like this, just in case:
override fun getPackageNames(): Set<String> =
moduleManager.modules.mapNotNullTo(mutableSetOf()) { AndroidModuleInfo.getInstance(it)?.`package` } +
moduleManager.modules.flatMapTo(mutableSetOf()) { AndroidModel.get(it)?.allApplicationIds ?: emptyList() }
WDYT?
BTW, when it works, it works great, I added build types and variants and I get:
getPackageNames:
From module info: [com.example.myapplication.demo.debug]
From Android model: [com.example.myapplication.demo.debug, com.example.myapplication.full.debug, com.example.myapplication.demo, com.example.myapplication.full]
cm...@google.com <cm...@google.com> #4
Is it possible you had cached sync in studio from before this change landed in studio?
I'll bump ourAndroidSyncVersion again as it wasn't increased after the semantic change to force a resync so you don't have to do this.
cm...@google.com <cm...@google.com> #6
AndroidModel,allApplicationIds
method should now always work
Description
No description yet.