Android inspections/duplicates are broken on TC?

 

I have an Android (gradle) project which I manage to build on TeamCity with gradle runner.

Now I'm trying to setup Duplicates Finder and Inspections runners which should support Android according to this  https://confluence.jetbrains.com/display/TCD10/IntelliJ+IDEA+Project

However it seems this feature is simply broken because both runners could not detect Android SDK and there is no way to specify it.

 

Things I tried to make it see SDK:

  • specify ANDROID_HOME env var
  • add sdk.dir to local.properties file
  • use different versions of Intellij engine

No luck :(

I tried 2 different build agents - Docker container with Android SDK and Mac Dev environment, both produce same results.

 

Here is an example of log output:

[Step 3/4] in directory: /opt/buildagent/work/873199a770bca67
[14:55:13][Step 3/4] Starting up IntelliJ IDEA 2018.1.3 (build IU-181.4892.42) ...done.
[14:55:37][Step 3/4] [ 27944] WARN - ule.android.SdkModuleSetupStep - Path to Android SDK not set
[14:55:37][Step 3/4] [ 27945] WARN - ule.android.SdkModuleSetupStep - # of eligible SDKs: 0
[14:55:37][Step 3/4] [ 28320] WARN - ule.android.SdkModuleSetupStep - Path to Android SDK not set
[14:55:37][Step 3/4] [ 28320] WARN - ule.android.SdkModuleSetupStep - # of eligible SDKs: 0
[14:55:37][Step 3/4] [ 28333] WARN - ule.android.SdkModuleSetupStep - Path to Android SDK not set
[14:55:37][Step 3/4] [ 28334] WARN - ule.android.SdkModuleSetupStep - # of eligible SDKs: 0
[14:55:40][Step 3/4] Opening project...done.
...
Step 3/4] Initializing project...done.
[14:55:42][Step 3/4] Please configure library 'Gradle: com.android.support:support-v4-27.1.1' which is used in module 'app'
[14:55:42][Step 3/4] Please configure library 'Gradle: com.google.android.gms:play-services-auth-base-license-11.8.0' which is used in module 'app'
...
[ 62409] WARN - roid.inspections.LintIdeClient - Unexpected failure during lint analysis of null (this is a bug in lint or one of the libraries it depends on)
[14:56:11][Step 3/4] `NullPointerException:GradleDetector.checkDependency(GradleDetector.java:1085)←GradleDetector.checkDslPropertyAssignment(GradleDetector.java:638)←LintIdeGradleDetector.access$200(LintIdeGradleDetector.java:51)←LintIdeGradleDetector$1$1.visitClosure(LintIdeGradleDetector.java:125)←GrClosableBlockImpl.accept(GrClosableBlockImpl.java:57)←GroovyPsiElementImpl.acceptGroovyChildren(GroovyPsiElementImpl.java:77)←GroovyPsiElementImpl.acceptChildren(GroovyPsiElementImpl.java:61)←GroovyRecursiveElementVisitor.visitElement(GroovyRecursiveElementVisitor.java:28)`
[14:56:11][Step 3/4] You can set environment variable `LINT_PRINT_STACKTRACE=true` to dump a full stacktrace to stdout.
[14:56:11][Step 3/4] java.lang.NullPointerException
[14:56:11][Step 3/4] at com.android.tools.lint.checks.GradleDetector.checkDependency(GradleDetector.java:1085)
...
[Step 3/4] [ 103155] ERROR - mpl.search.PsiSearchHelperImpl - Could not initialize class com.android.tools.idea.res.SampleDataResourceRepository
[14:56:52][Step 3/4] java.lang.NoClassDefFoundError: Could not initialize class com.android.tools.idea.res.SampleDataResourceRepository
[14:56:52][Step 3/4] at com.android.tools.idea.res.AppResourceRepository.computeRepositories(AppResourceRepository.java:160)
...
Tons of exceptions.
 
Version info:
- TeamCity 2017.2.4 (build 51228)
- IntelliJ IDEA 2017.2.6
- Android SDK 27
 
Did someone manage to make it work?
Thanks.
1
6 comments

Hi Maksym,

How are you trying to load the inspections/duplicates? As an IntelliJ project or as a Gradle project? By default, android projects are gradle based, which means that you should select gradle as the inspection/duplicates project type. The errors you get seem to indicate you have selected IntelliJ instead, so if you are using gradle, please make sure to select it. If not, please send us a screenshot of the build step configuration.

0
Avatar
Permanently deleted user

Hello. Here is an example of my build configuration.
Same build agent was able to build signed APKs


 

0

Hi Maksym,

thanks for sharing the configuration. I've been running tests myself and I have seen some unexpected behavior:
-I've set the Android SDK as env.ANDROID_HOME for the build project and it seems to detect it just fine. On the other hand, trying to run ./gradlew from a shell without local.properties but with ANDROID_HOME available seems to fail to detect it, I don't really know why. This would be more of a gradle/android issue so I'm afraid it's out of our reach, as I mentioned, I did it in a shell, not from within teamcity.

-I've configured the step just like you and run the inspections profile. While it does show all the warnings and errors you see, the build succeeds and the code inspections can be seen in the build results. The errors and warnings can only be found in the build log.

Duplicates on the other hand seem to produce the same errors but not work at all.

I've passed this internally and we are investigating this further, as soon as I have something I'll answer back.

0
Avatar
Permanently deleted user

Hello. ./gradlew works fine for me as well. As for Intellij inspections - I don't think that is correct. I've been running the build for 2 minutes and got 20 MB of logs with exception stacktraces.

0
Avatar
Permanently deleted user

We have the same problem and as you mentioned, Douplicates check failed at all. Can you link the issue for this?

0

https://youtrack.jetbrains.com/issue/TW-48390

In this issue there is a workaround to import them, and eventually we added the following service message:

##teamcity[importData type='intellij-inspections' path='pathToDirectoryWithInspectionsResults']

 Otherwise, I can't seem to find the issue for the duplicates, so please feel free to open a new one.

0

Please sign in to leave a comment.