Collect 18.0.1 won't build in Android Studio 3.2.1


(Nik Holmes) #1

Hi All:
I've been working for some years now with a custom fork of Collect, which works in conjunction with my own PHP/MySQL backend. My system requires a few minor changes to Collect, and my version is distributed only as an APK to specific users, so I don't update it from the main Collect repo more than about once per year. I'm not comfortable with Java, don't understand much about Android, and find Android Studio and Gradle utterly incomprehensible! My last successful build was in Android Studio 2, about a year ago, and i think that was based on Collect 1.14 or thereabouts.
But it's about time for an update, so I've just tried to build a vanilla Collect app 1.18.1 in a fresh install of AS3 - and it failed spectacularly. At the outset I got this:

The Android Gradle plugin supports only Crashlytics Gradle plugin version 1.25.4 and higher. Project 'Workspace_Collect_1.18.1' is using version 1.25.2.

I don't even know what Crashlytics is doing, (or to be honest what Gradle is doing!) but can anyone help me fix this error?

And if anyone knows how to build an APK from the Collect source without using AS at all, I'd love to hear about it. AS just seems to add an extraordinary amount of complication to the process of compiling an app, and as someone who is only an occasional dabbler in Android app development, its evolution has left me completely baffled as to what it's doing most of the time!

Thanks, Nik


(Yaw Anokwa) #2

In the repo folder, what happens if you run ./gradlew clean assembleDebug on the command line.


(Nik Holmes) #3

Hi Yaw - thanks for the quick response.
Quick correction - I put the wrong version in the thread title, should have been 1.18.1, of course.
I tried your suggestion, and the response told me that java was not installed or could not be found. So I (re?)installed OpenJDK8, and ran the command again. The response was


Welcome to Gradle 4.7!

Here are the highlights of this release:

  • Incremental annotation processing
  • JDK 10 support
  • Grouped non-interactive console logs
  • Failed tests are re-run first for quicker feedback

For more details see https://docs.gradle.org/4.7/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

Configure project :collect_app
Could not find google-services.json while looking in [src/nullnull/odkCollectRelease, src/odkCollectRelease/nullnull, src/nullnull, src/odkCollectRelease, src/nullnullOdkCollectRelease]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

FAILURE: Build failed with an exception.

  • What went wrong:
    The Android Gradle plugin supports only Crashlytics Gradle plugin version 1.25.4 and higher. Project 'Workspace_Collect_1.18.1' is using version 1.25.2.

Does that shed any light on the problem?

But I would still like to know whether it's possible to build an APK without using AS3..? The AS project seems to be making life more and more complicated, and increasingly difficult for part-time dabblers to keep up with.
Thanks
Nik


(Nik Holmes) #4

UPDATE - this article:


...suggests changing build.gradle as follows:

dependencies {
classpath 'io.fabric.tools:gradle:1.25.2'
...
}

change to...

  classpath 'io.fabric.tools:gradle:1.25.4'

and the project now builds! Perhaps someone could change this in the main repo?

Thanks
Nik


(Yaw Anokwa) #5

Glad to hear you've resolved the issue.

You can be the someone that makes the change! Send in a pull request at https://github.com/opendatakit/collect. https://github.com/opendatakit/collect/blob/master/CONTRIBUTING.md describes the process.


(Nik Holmes) #6

I'm afraid that working with github is beyond the abilities of my tiny mind - I'm an old-school (and actually quite old) programmer who cut my teeth on assembler, and am not safe to be let loose on modern repo-based java development. Example - both of my posts above had to be edited some hours after posting, because they contained incorrect version numbers!
And while I can easily google a problem and find a fix on stackoverflow, I don't really have any idea how the change I just made to the build.gradle file might break something somewhere else. I assume that the code is how it is because people who know what they are doing wrote it like that - and certainly don't know what I'm doing with AS3 and Gradle!
So if it's OK with you I'll carry on making suggestions in the forum, and leave it to wiser folks to incorporate anything useful into the repo.
Thanks
Nik


(Yaw Anokwa) #7

That's absolutely fine! Just note that there isn't a large pool of wiser folks waiting to incorporate things. If you want something added, the best way is to try to add it yourself. This helps future people who have a similar issue (including you!). It helps enables the core team to focus on the harder problems (including providing guidance for new contributors like yourself).