Jacob Holloway
Jacob Holloway

Reputation: 887

Android Gradle - Gitlab CI - Docker - CMake - NullPointerException

I'm trying to get simple Android Unit Tests to run on Gitlab CI, but I'm having troubles getting things to build correctly in the CI Docker image. I have the master project which pulls from a Library project. The Library has C code in it, so I need to use CMake to get it to build. All of this is working locally on my windows machine when using Android Studio. However, once I move to the CI server, things break with the following error:

Using incremental javac compilation for :Library debug.
Incremental java compilation is an incubating feature.
Checking the license for package CMake 3.6.3155560 in /android-sdk-linux/licenses
License for package CMake 3.6.3155560 accepted.
Preparing "Install CMake 3.6.3155560 (revision: 3.6.3155560)".
"Install CMake 3.6.3155560 (revision: 3.6.3155560)" ready.
Finishing "Install CMake 3.6.3155560 (revision: 3.6.3155560)"
Installing CMake 3.6.3155560 in /android-sdk-linux/cmake/3.6.3155560
"Install CMake 3.6.3155560 (revision: 3.6.3155560)" complete.
"Install CMake 3.6.3155560 (revision: 3.6.3155560)" finished.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':Library'.
> java.lang.NullPointerException (no error message)

* Try:
Run with --debug option to get more log output.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':Library'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:94)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:89)
    ...
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: java.lang.NullPointerException
    at com.android.builder.sdk.DefaultSdkLoader.installSdkTool(DefaultSdkLoader.java:572)
    at com.android.build.gradle.internal.SdkHandler.installCMake(SdkHandler.java:302)
    at com.android.build.gradle.tasks.ExternalNativeJsonGenerator.create(ExternalNativeJsonGenerator.java:628)
    at com.android.build.gradle.internal.TaskManager.createExternalNativeBuildJsonGenerators(TaskManager.java:1241)
    at com.android.build.gradle.internal.LibraryTaskManager.lambda$createTasksForVariantData$11(LibraryTaskManager.java:240)
    ...
    at com.sun.proxy.$Proxy15.afterEvaluate(Unknown Source)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:82)
    ... 56 more


BUILD FAILED

Total time: 1 mins 25.384 secs
Stopped 0 worker daemon(s).
Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring project ':Library'.] from daemon DaemonInfo{pid=39, address=[1f3b75f9-7080-48b5-b298-0e6136640a0a port:41964, addresses:[/127.0.0.1]],     state=Busy, lastBusy=1496784783851, context=DefaultDaemonContext[uid=0e3eadf0-a7bd-4ede-9eb8-0c2a96ebef58,javaHome=/usr/lib/jvm/java-8-openjdk-amd64,daemonRegistryDir=/root/.gradle/daemon,pid=39,idleTimeout=10800000,daemonOpts=-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country,-Duser.language=en,    -Duser.variant]} (build should be done).
ERROR: Job failed: exit code 1

Judging by the line

Caused by: java.lang.NullPointerException
    at com.android.builder.sdk.DefaultSdkLoader.installSdkTool(DefaultSdkLoader.java:572)
    at com.android.build.gradle.internal.SdkHandler.installCMake(SdkHandler.java:302)

it looks like it is a problem with the CMake. But it looks like it is installed and the licence is accepted as noted by the output at the start of that block above.


Can anyone give me some pointers on what is the problem?
* Is it that gradle doesn't know where CMake was installed? * Is it a problem perhaps with the NDK? * Or perhaps where I can find the source code for com.android.build.gradle.internal.SdkHandler.installCMake and com.android.builder.sdk.DefaultSdkLoader.installSdkTool.
My searches have been unfruitful.

I can provide more about my setup upon request. (i.e. android project, docker image, gitlab-ci.yml, etc.)

Upvotes: 1

Views: 586

Answers (1)

Jacob Holloway
Jacob Holloway

Reputation: 887

Well, mbertin commented on Feb 2 at here that by using a lower gradle build tool, it solved the problem for him. (i.e. classpath 'com.android.tools.build:gradle:2.2.2).

After giving it an attempt, my build script got passed that error! (anyone know why?)

Thanks for the emotional support Stack Overflow! You are the best!

Upvotes: 1

Related Questions