Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usage on Android #3929

Open
geoffrey-vl opened this issue Oct 22, 2024 · 1 comment
Open

usage on Android #3929

geoffrey-vl opened this issue Oct 22, 2024 · 1 comment

Comments

@geoffrey-vl
Copy link

How can this be used in Android applications now that ApplicationInsights-Android has been deprecated?
Specifically configuring the connection string is a bit non-Android. On Android you don't typically set environment variables, or put Json config files next to your appinsights jar file as there are no jar files in the end.

@geoffrey-vl
Copy link
Author

For now I have something in line of this:

build.gradle:

dependencies {
    ....
    implementation "com.microsoft.azure:applicationinsights-core:3.6.1"
    implementation "com.microsoft.azure:applicationinsights-runtime-attach:3.6.1"
    ....
}

Java:

private static final String SYSPROP_CONN_STRING = "applicationinsights.connection.string";

// setup
System.setProperty(SYSPROP_CONN_STRING, connString);
com.microsoft.applicationinsights.attach.ApplicationInsights.attach();

// use
TelemetryClient client = new TelemetryClient();
client.trackEvent("somedata");
client.flush();

It fails however due to missing Java Optional class (java.lang.NoClassDefFoundError: Failed resolution of: Ljava/util/Optional;). Our target platform is still running Android 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant