ModuleBridgeImpl: Error trying to get the selected variant Follow
Im updating an old plugin that stopped working in a newer version of IDEA/AS where I'm trying to get the currently selected build variant.
Module modules = ModuleManager.getInstance(project).getModules();
AndroidModuleModel module = AndroidModuleModel.get(modules);
IdeVariant variant = module.getSelectedVariant();
AndroidModuleModel.get() now returns a ModuleBridgeImpl instead, which causes an error.
The new code I found that worked is:
final Module modules = ModuleManager.getInstance(project).getModules();
NdkFacet ndkFacet = NdkFacet.getInstance(modules);
VariantAbi variant = ndkFacet.getSelectedVariantAbi();
final String selectedVariantName = variant.getVariant();
This new solution doesn't seem to be backwards compatible. Preferably I need something that works from 2019+
Please sign in to leave a comment.
Backward compatibility is sometimes broken, and it is required to either bump the since-version in plugin.xml or release two versions of the plugin - one targeting version before the breaking change was introduced and one for the newer API.
See https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html#idea-plugin__idea-version for information about specifying target versions.
Is there a way to get the AndroidModel with older API or is that not possible?
If I upgraded this plugin to the newer version, it there a way to do something similar to
Or maybe wrap them in functions with some annotation to the function for which should be used based on the version I'm compiling for?