elastic / elastic/apm-agent-android

I'm getting the following crash on Android 11 and 12

Open
#338 3 comments 0 reactions 0 assignees View on GitHub
agent-android agent-mobile community needs author feedback triage
Dominant language
Kotlin
Stars
43
Forks
22
Avg merge
2d 1h
Merged PRs (30d)
26

Description

Hi, I've been getting the following crash with Android versions 11 and 12

```
java.lang.VerifyError: Verifier rejected class io.opentelemetry.sdk.metrics.SdkDoubleGauge$SdkDoubleGaugeBuilder: io.opentelemetry.api.incubator.metrics.DoubleGauge io.opentelemetry.sdk.metrics.SdkDoubleGauge$SdkDoubleGaugeBuilder.build() failed to verify: io.opentelemetry.api.incubator.metrics.DoubleGauge io.opentelemetry.sdk.metrics.SdkDoubleGauge$SdkDoubleGaugeBuilder.build(): [0x4] can't resolve returned type 'Unresolved Reference: io.opentelemetry.api.incubator.metrics.DoubleGauge' or 'Unresolved Reference: io.opentelemetry.sdk.metrics.SdkDoubleGauge' (declaration of 'io.opentelemetry.sdk.metrics.SdkDoubleGauge$SdkDoubleGaugeBuilder' appears in /data/app/~~OaE29eflqDJYvUe5K7KmLQ==/com.hummloan.au.sit-TUsSobuj2avVjcLsdx-nJw==/base.apk!classes7.dex)
at io.opentelemetry.sdk.metrics.SdkMeter.gaugeBuilder(SdkMeter.java:111)
at co.elastic.apm.android.sdk.internal.features.launchtime.LaunchTimeApplicationListener.sendAppLaunchTimeMetric(LaunchTimeApplicationListener.java:47)
at co.elastic.apm.android.sdk.internal.features.launchtime.LaunchTimeApplicationListener.onApplicationForegrounded(LaunchTimeApplicationListener.java:39)
at io.opentelemetry.android.ApplicationStateWatcher.onActivityStarted(ApplicationStateWatcher.java:27)
at android.app.Application.dispatchActivityStarted(Application.java:386)
at android.app.Activity.dispatchActivityStarted(Activity.java:1366)
at android.app.Activity.onStart(Activity.java:1878)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:344)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
at au.com.flexirent.humm.views.landing.SplashActivity.onStart(SplashActivity.kt:67)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1455)
at android.app.Activity.performStart(Activity.java:8076)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3660)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)


```

My code to initialise Elastic is

```
val configuration = ElasticApmConfiguration.builder()
.setServiceName(BuildConfig.ELASTIC_SERVICE_NAME)
.setServiceVersion(BuildConfig.VERSION_NAME)
.setDeploymentEnvironment(BuildConfig.ELASTIC_DEPLOYMENT_ENVIRONMENT)
.build()

val connectivity = Connectivity.simple(BuildConfig.ELASTIC_SERVER_URL)
ElasticApmAgent.initialize(this, configuration, connectivity)
```

which is happening just after the Application onCreate super call.

Commenting out the Elastic monitoring initialisation method above prevents the crash.

On the Android versions mentioned below, there are no issues and everything is coming through as expected.

Any ideas what could be the issue?

Update: Testing results on my Pixel 3a emulator for different Android versions (API level)
Works: 34, 33, 29, 28

Not working: 32, 31, 30

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.