0

I am trying to create a plugin for Android Studio. From the plugin itself I have the reference to the project and the files via IntelliJ API but I can't get to gradle's build variant which user selected.

Is it possible to somehow get the build variant selected by user from the plugin code itself?

1 Answer 1

3

I would suggest you look at BuildVariantView.java, line 147 down.

Basically (skipping the null checks):

ModuleManager moduleManager = ModuleManager.getInstance(myProject); Module module = ...; // Depending on your requirements AndroidFacet androidFacet = AndroidFacet.getInstance(module); IdeaAndroidProject ideaAndroidProject = androidFacet.getIdeaAndroidProject(); Variant variant = ideaAndroidProject.getSelectedVariant(); 

Please be sure to check that the module is both Android and Gradle project - especially if you wish for your plugin to work with IntelliJ Idea.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.