Solved

Compilation error after generating code

  • 5 October 2022
  • 3 replies
  • 113 views

Userlevel 2
Badge

I am trying to follow the documentation here: https://www.docs.developers.amplitude.com/data/sdks/java/ampli/#track

generating code into a backend kotlin project, similar to this example https://github.com/amplitude/ampli-examples/tree/main/jre/kotlin/AmpliApp

 

However when I generate the code there is a compilation error in the generated file Ampli.kt, line 207

 

    open fun identify(userId: String?, event: Identify? = null, options: EventOptions? = null, extra: MiddlewareExtra? = null) {
if (!this.isInitializedAndEnabled()) {
return
}
val amplitudeEvent = this.createAmplitudeEvent(event?.eventType, event?.options, options, userId)
amplitudeEvent.userProperties = this.getEventPropertiesJson(event)

this._client?.logEvent(amplitudeEvent, extra)
}

 

the problem is that event is a nullable type.

 

In the example repo i pasted above, this argument is non-nullable

icon

Best answer by Amplitude Admin 12 October 2022, 17:11

View original

3 replies

Userlevel 2
Badge

I have noticed that this section of code only generates if you specify some user properties

Userlevel 6
Badge +9

Hi @KatSharp, Thank you for writing this post! Please allow me to check this internally and get back to you! 

Userlevel 2
Badge

there are also some compiler warnings, like usage of deprecated methods.

Plus it fails a bunch of tests run by common tools, such as detekt.

It would be nice is the code generated adhered to these checks

Reply