Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
858e35a
plug in sentry-native
bruno-garcia Oct 3, 2019
bca5858
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia Oct 7, 2019
f775e74
fix: lib name
bruno-garcia Oct 8, 2019
62dc8ff
feat: Link with sentry-native
tonyo Oct 8, 2019
80c1630
Update sentry-android-ndk/build.gradle.kts
bruno-garcia Oct 9, 2019
39cc3f4
ref: self close tag
bruno-garcia Oct 9, 2019
0e8cec2
ref: fix symlink
mitsuhiko Oct 9, 2019
bd46263
ref: Fixed the print callback
mitsuhiko Oct 10, 2019
25081a8
Update sentry-android-ndk/CMakeLists.txt
bruno-garcia Oct 12, 2019
b50fdab
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia Oct 14, 2019
dbc9c11
fix: Rely on permission defined in SDK
bruno-garcia Oct 14, 2019
f623c99
Update sentry-android-ndk/CMakeLists.txt
bruno-garcia Oct 14, 2019
2a1e1e0
Update sentry-android-ndk/CMakeLists.txt
bruno-garcia Oct 14, 2019
6a8635a
Update sentry-android-ndk/CMakeLists.txt
bruno-garcia Oct 14, 2019
68a2047
feat: Init SentryNdk when available
bruno-garcia Oct 14, 2019
40fd845
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia Oct 14, 2019
eba52d1
Merge branch 'feat/ndk' of github.com:getsentry/sentry-android into f…
bruno-garcia Oct 15, 2019
0b682d0
fix merge conflict
Oct 18, 2019
8b0d497
feat: Some ugly code to do something
mitsuhiko Oct 22, 2019
ce4e004
lint
bruno-garcia Oct 22, 2019
63efb43
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia Oct 22, 2019
12e6b9f
ref: remove symlink
bruno-garcia Oct 22, 2019
afbb473
feat: sentry-native submodule ndk branch
bruno-garcia Oct 22, 2019
e0bcee9
feat(ndk): Specify SENTRY_NATIVE_SRC in build.gradle
tonyo Oct 22, 2019
8c62844
try: Conditional sentry-native usage
tonyo Oct 22, 2019
5f8e145
feat: Use submodule or local override
bruno-garcia Oct 22, 2019
d11b2b7
ref: set compat version
bruno-garcia Oct 22, 2019
5fa906a
feat: Build NDK only for specific platforms if ABI is set
tonyo Oct 23, 2019
0f1fa04
fix: target of the symbolic link is taken literally from the first ar…
bruno-garcia Oct 23, 2019
6331600
Update README.md
bruno-garcia Oct 23, 2019
51c439e
Update README.md
bruno-garcia Oct 23, 2019
95b7f18
Merge branch 'master' into feat/ndk-submodule
bruno-garcia Oct 23, 2019
d779142
ref: API 14 doesn't support multi catch exception
bruno-garcia Oct 23, 2019
5f43c79
feat: Use API 14
bruno-garcia Oct 23, 2019
adc8f19
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia Oct 23, 2019
8c9ea4d
ref: Use const for version
bruno-garcia Oct 23, 2019
9e03b27
ref: Fix linter
bruno-garcia Oct 23, 2019
88c0285
ref: meta-package requires highest API lvl
bruno-garcia Oct 23, 2019
3613ee2
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia Oct 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Some ugly code to do something
  • Loading branch information
mitsuhiko committed Oct 22, 2019
commit 8b0d497d1de9bbc43d8873a66c9b94b3dca191ea
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.content.Context;
import io.sentry.core.SentryLevel;
import io.sentry.core.SentryOptions;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

Expand All @@ -19,8 +21,17 @@ static void init(SentryOptions options, Context context) {
try {
// TODO: Create Integrations interface and use that to initialize NDK
Class cls = Class.forName("io.sentry.android.ndk.SentryNdk");
Method method = cls.getMethod("init", String.class);
method.invoke(null, new Object[0]);

// XXX: temporary hack
String cacheDirPath = context.getCacheDir().getAbsolutePath() + "/sentry-envelopes";
File f = new File(cacheDirPath);
f.mkdirs();

Method method = cls.getMethod("init", SentryOptions.class, String.class);
Object[] args = new Object[2];
args[0] = options;
args[1] = cacheDirPath;
method.invoke(null, args);
} catch (ClassNotFoundException exc) {
options.getLogger().log(SentryLevel.ERROR, "Failed to load SentryNdk.");
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
Expand Down
7 changes: 7 additions & 0 deletions sentry-android-ndk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ android {
ndk {
abiFilters("x86", "armeabi-v7a", "x86_64", "arm64-v8a")
}

missingDimensionStrategy(Config.Flavors.dimension, Config.Flavors.production)
}

externalNativeBuild {
Expand All @@ -33,3 +35,8 @@ android {
}
}
}

dependencies {
api(project(":sentry-core"))
api(project(":sentry-android-core"))
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.sentry.android.ndk;

import io.sentry.core.SentryOptions;

public class SentryNdk {
static {
System.loadLibrary("sentry");
Expand All @@ -9,10 +11,14 @@ public class SentryNdk {
System.loadLibrary("sentry-android");
}

public static native void example();
private static native void initSentryNative(String cacheDirPath);

public static void notifyNewSerializedEnvelope(String path) {
System.out.println("envelope written to " + path);
}

public static void init() {
public static void init(SentryOptions options, String cacheDirPath) {
// Java_example
example();
initSentryNative(cacheDirPath);
}
}
29 changes: 25 additions & 4 deletions sentry-android-ndk/src/main/jni/sentry.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
#include <string.h>
#include <sentry.h>
#include <jni.h>
#include <malloc.h>
#include <android/log.h>

void print(sentry_value_t event, void *data) {
__android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "EVENTTTTTTTTTTT: %s",sentry_value_to_json(event));
struct transport_options {
jmethodID notify_envelope_mid;
jclass cls;
JNIEnv *env;
char event_path[4096];
};

struct transport_options g_transport_options;

static void send_envelope(const sentry_envelope_t *envelope, void *data) {
char event_path[4096];
strcpy(event_path, g_transport_options.event_path);
strcat(event_path, "/test.envelope");
sentry_envelope_write_to_file(envelope, event_path);
jstring jevent_path = (*g_transport_options.env)->NewStringUTF(g_transport_options.env, event_path);
(*g_transport_options.env)->CallStaticVoidMethod(g_transport_options.env, g_transport_options.cls, g_transport_options.notify_envelope_mid, jevent_path);
}

JNIEXPORT void JNICALL Java_io_sentry_android_ndk_SentryNdk_example(JNIEnv *env, jclass clazz) {
JNIEXPORT void JNICALL Java_io_sentry_android_ndk_SentryNdk_initSentryNative(JNIEnv *env, jclass cls, jstring cache_dir_path) {
const char *path = (*env)->GetStringUTFChars(env, cache_dir_path, 0);
strcpy(g_transport_options.event_path, path);
g_transport_options.env = env;
g_transport_options.cls = cls;
g_transport_options.notify_envelope_mid = (*env)->GetStaticMethodID(env, cls, "notifyNewSerializedEnvelope", "(Ljava/lang/String;)V");

sentry_options_t *options = sentry_options_new();

sentry_options_set_transport(options, print, NULL);
sentry_options_set_transport(options, send_envelope, NULL);

sentry_options_set_environment(options, "Production");
sentry_options_set_release(options, "5fd7a6cd");
Expand Down