Get List of Android Product Flavours to use in Android Studio Plugin

Answered

I am building a plugin for Android Studio that needs to know all the product flavours of the Android project that is currently open. Unfortunately, I am clueless how to get them into the Java plugin and I am not sure if this is even the correct place to ask. Can anyone offer any advice if this is even possible? Thank you.

6 comments
Comment actions Permalink

com.android.tools.idea.gradle.project.model.AndroidModuleModel contains a number of "Flavor" methods (make sure to add dependency to Android plugin http://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html)

1
Comment actions Permalink

Yann, thank you! I wish I knew about this sooner - the Android plugin has so many things that I've been looking for.

I do however have a quick question. I am importing the plugin in the below way

intellij {
    plugins 'android'
...
}

When I compile my own plugin into a jar and add it to Android Studio, I get the below error when I try to use any of the Android methods or classes.

java.lang.NoClassDefFoundError: com/android/tools/idea/gradle/project/ProjectStructure

I understand that this may be because I do not have the Android plugin in Android Studio, but if it isn't one of the plugins from the screenshot below, then which plugin is it? I know this isn't an Android Studio support page, so I highly appreciate any help.

0
Comment actions Permalink

I can't find the ID of the plugin (to be honest I can't even find it online). I have the :android: jar in my Gradle Dependencies, but don't see it in my Libraries, so can't go and check the ID. Do you know it?

0
Comment actions Permalink

"org.jetbrains.android" you should have autocompletion as well

1
Comment actions Permalink

That works! Thank you, Yann!!

0

Please sign in to leave a comment.