Android Project

Hey all,

I was wondering if there is a way to detect if the active project is an Android project or not, as I want this plugin to be supported both on IntelliJ and AS. And second thing, would it be possible to extract the application ID? without guessing and fiddling with the (mostly used) build.gradle file?

Thanks in advance.

Comment actions Permalink

There is no such thing as an "Android project" in IntelliJ IDEA. A project can contain multiple modules, some of which can be Android applications or libraries, and some can be something else.

To find out if a module is an Android module, call AndroidFacet.getInstance(module) and check if it returns not null.

As far as I understand, the concept of "application ID" does not exist in non-Gradle-based projects. To get the package name from the manifest, use:

VirtualFile manifestFile = AndroidRootUtil.getPrimaryManifestFile(facet);
Manifest manifest = AndroidUtils.loadDomElement(facet.getModule(), manifestFile, Manifest.class);
return manifest.getPackage().getValue();

Comment actions Permalink

Dmitry, thank you for the response!


Please sign in to leave a comment.