Testing plugin with dependencies and testProject setup with AndroidFacet

Hello,

I am testing my plugin, which takes project having Android facets and do its analysis on the project. While setting up tests, I have added files to the module and tried to check if the project is having Android facets. The result was false. 

So I created FacetManager instance

val facetManager = FacetManager.getInstance(firstModule!!)

And tried to create AndroidFacet

val facetType = AndroidFacetType()
val facet = facetManager.createFacet(facetType, facetType.defaultFacetName, null)

But error was Cannot find facet by id 'android'

So, I added org.jetbrains.android dependency in Xml file. I am getting following error:

ERROR: Problems found loading plugins:<p/>Plugin "Gradle" was not loaded: required plugin "org.intellij.groovy" not installed.<p/>Plugin "Android Support" was not loaded: required plugin "JUnit" not installed.<p/>Plugin "KilaCrypto" was not loaded: required plugin "JUnit" not installed.<p/><br><a href="disable">Disable not loaded plugins</a><p/><a href="edit">Open plugin manager</a>

 

 

7 comments
Comment actions Permalink

I have added following code to Plugin.xml

<extensions defaultExtensionNs="com.intellij">
<facetType implementation="org.jetbrains.android.facet.AndroidFacetType"/>
</extensions>

I am still unable to get Android facet. Still getting the AssertionError: Cannot find facet by id 'android'

 

0
Comment actions Permalink

I have updated the code to setting up module with facets

fun setupAndroidProject() {
val facetManager = FacetManager.getInstance(firstModule!!)
val facet = facetManager.createFacet(AndroidFacet.getFacetType(), "android", null)
val model = facetManager.createModifiableModel()
model.addFacet(facet)
ApplicationManager.getApplication().runWriteAction {
model.commit()
}

After debugging, 

com.intellij.facet.impl#loadExtensions() tries to get the extension with extensionPoint "com.intellij.facetType"

I have already specified 

<facetType implementation="org.jetbrains.android.facet.AndroidFacetType"/>

in my Plugin.xml file.

After the execution of com.intellij.facet.impl#loadExtensions()



0
Comment actions Permalink

Some implementations on github are having 

<component name="UnknownFeatures">
<option featureType="com.intellij.facetType" implementationName="android" />
</component>

in their workspace.xml.

I have added this manually, just to see the effect, and after this addition, the first run was able to return the Android facet :)

But after restarting the project, getting the same AssertionError: Cannot find facet by id 'android'

0
Comment actions Permalink

> ERROR: Problems found loading plugins:<p/>Plugin "Gradle" was not loaded: required plugin "org.intellij.groovy" not installed.<p/>Plugin "Android Support" was not loaded: required plugin "JUnit" not installed.<p/>Plugin "KilaCrypto" was not loaded: required plugin "JUnit" not installed.<p/><br><a href="disable">Disable not loaded plugins</a><p/><a href="edit">Open plugin manager</a>

Have you tried to add dependencies on Gradle, Groovy, JUnit plugins?

0
Comment actions Permalink

This error has been resolved after I loaded plugins while testing using VM options:

<option name="VM_PARAMETERS" value="-ea -Xbootclasspath/p:../out/classes/production/boot
-XX:+HeapDumpOnOutOfMemoryError -Xmx512m
-XX:MaxPermSize=320m
-Didea.system.path=$USER_HOME$/Library/Caches/IntelliJIdea2018.1/plugins-sandbox/system
-Didea.home.path=$USER_HOME$/Library/Caches/IntelliJIdea2018.1/plugins-sandbox
-Didea.config.path=$USER_HOME$/Library/Caches/IntelliJIdea2018.1/plugins-sandbox/config
-Didea.load.plugins.id=org.jetbrains.android
-Didea.load.plugins.id=com.intellij.junit5
-Didea.test.group=ALL_EXCLUDE_DEFINED" />
0
Comment actions Permalink

Alexander, 

how to resolve the error Cannot find facet by id 'android'?

 I have added 

<extensions defaultExtensionNs="com.intellij">
<facetType implementation="org.jetbrains.android.facet.AndroidFacetType"/>
</extensions>

Still facing the issue. What am I missing here?

 

0
Comment actions Permalink

Do you have android plugin enabled in the debugged IDE? Have you tried to debug code that actually leads to the assertion?

0

Please sign in to leave a comment.