This repository was archived by the owner on Aug 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 30
feat: NDK #52
Merged
Merged
feat: NDK #52
Changes from 27 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
858e35a
plug in sentry-native
bruno-garcia bca5858
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia f775e74
fix: lib name
bruno-garcia 62dc8ff
feat: Link with sentry-native
tonyo 80c1630
Update sentry-android-ndk/build.gradle.kts
bruno-garcia 39cc3f4
ref: self close tag
bruno-garcia 0e8cec2
ref: fix symlink
mitsuhiko bd46263
ref: Fixed the print callback
mitsuhiko 25081a8
Update sentry-android-ndk/CMakeLists.txt
bruno-garcia b50fdab
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia dbc9c11
fix: Rely on permission defined in SDK
bruno-garcia f623c99
Update sentry-android-ndk/CMakeLists.txt
bruno-garcia 2a1e1e0
Update sentry-android-ndk/CMakeLists.txt
bruno-garcia 6a8635a
Update sentry-android-ndk/CMakeLists.txt
bruno-garcia 68a2047
feat: Init SentryNdk when available
bruno-garcia 40fd845
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia eba52d1
Merge branch 'feat/ndk' of github.com:getsentry/sentry-android into f…
bruno-garcia 0b682d0
fix merge conflict
8b0d497
feat: Some ugly code to do something
mitsuhiko ce4e004
lint
bruno-garcia 63efb43
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia 12e6b9f
ref: remove symlink
bruno-garcia afbb473
feat: sentry-native submodule ndk branch
bruno-garcia e0bcee9
feat(ndk): Specify SENTRY_NATIVE_SRC in build.gradle
tonyo 8c62844
try: Conditional sentry-native usage
tonyo 5f8e145
feat: Use submodule or local override
bruno-garcia d11b2b7
ref: set compat version
bruno-garcia 5fa906a
feat: Build NDK only for specific platforms if ABI is set
tonyo 0f1fa04
fix: target of the symbolic link is taken literally from the first ar…
bruno-garcia 6331600
Update README.md
bruno-garcia 51c439e
Update README.md
bruno-garcia 95b7f18
Merge branch 'master' into feat/ndk-submodule
bruno-garcia d779142
ref: API 14 doesn't support multi catch exception
bruno-garcia 5f43c79
feat: Use API 14
bruno-garcia adc8f19
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia 8c9ea4d
ref: Use const for version
bruno-garcia 9e03b27
ref: Fix linter
bruno-garcia 88c0285
ref: meta-package requires highest API lvl
bruno-garcia 3613ee2
Merge branch 'master' of github.com:getsentry/sentry-android into fea…
bruno-garcia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,6 @@ out/ | |
| local.properties | ||
| **.iml | ||
| *.hprof | ||
| .cxx | ||
| sentry-native-local/ | ||
| **/sentry-native-local | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [submodule "sentry-android-ndk/sentry-native"] | ||
| path = sentry-android-ndk/sentry-native | ||
| url = https://github.com/getsentry/sentry-native |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| cmake_minimum_required(VERSION 3.4.1) | ||
| project("sentry-android") | ||
|
|
||
| # Adding sentry-native submodule subdirectory | ||
| add_subdirectory(${SENTRY_NATIVE_SRC}) | ||
|
|
||
| # sentry-native submodule include path. | ||
| include_directories(${SENTRY_NATIVE_SRC}/include) | ||
|
|
||
| # sentry-native source code. | ||
| file(GLOB SENTRY_ANDROID_SOURCES ${CMAKE_SOURCE_DIR}/src/main/jni/*.c) | ||
|
|
||
| # Adding dynamic library and linking it with log and sentry-native. | ||
| add_library("sentry-android" SHARED ${SENTRY_ANDROID_SOURCES}) | ||
| find_library(LOG_LIB log) | ||
| target_link_libraries("sentry-android" "sentry" ${LOG_LIB}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
|
|
||
| plugins { | ||
| id("com.android.library") | ||
| } | ||
|
|
||
| android { | ||
| compileSdkVersion(Config.Android.compileSdkVersion) | ||
| buildToolsVersion(Config.Android.buildToolsVersion) | ||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_1_8 | ||
| targetCompatibility = JavaVersion.VERSION_1_8 | ||
| } | ||
| defaultConfig { | ||
| targetSdkVersion(Config.Android.targetSdkVersion) | ||
| javaCompileOptions { | ||
| annotationProcessorOptions { | ||
| includeCompileClasspath = true | ||
| } | ||
| } | ||
|
|
||
| minSdkVersion(21) | ||
| externalNativeBuild { | ||
| val sentryNativeSrc = if (File("${project.projectDir}/sentry-native-local").exists()) { | ||
| "sentry-native-local" | ||
| } else { | ||
| "sentry-native" | ||
| } | ||
| cmake { | ||
| arguments.add(0, "-DANDROID_STL=c++_static") | ||
| arguments.add(0, "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON") | ||
| arguments.add(0, "-DSENTRY_NATIVE_SRC=" + sentryNativeSrc) | ||
| } | ||
| } | ||
| ndk { | ||
| abiFilters("x86", "armeabi-v7a", "x86_64", "arm64-v8a") | ||
| } | ||
|
|
||
| missingDimensionStrategy(Config.Flavors.dimension, Config.Flavors.production) | ||
| } | ||
|
|
||
| externalNativeBuild { | ||
| cmake { | ||
| setPath("CMakeLists.txt") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| api(project(":sentry-core")) | ||
| api(project(":sentry-android-core")) | ||
| } | ||
|
|
||
| val initNative = tasks.register<Exec>("initNative") { | ||
| logger.log(LogLevel.LIFECYCLE, "Initializing git submodules") | ||
| commandLine("git", "submodule", "update", "--init", "--recursive") | ||
| } | ||
|
|
||
| tasks.named("preBuild") { | ||
| dependsOn(initNative) | ||
| } |
Submodule sentry-native
added at
03b86e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest package="io.sentry.android.ndk" /> |
24 changes: 24 additions & 0 deletions
24
sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdk.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package io.sentry.android.ndk; | ||
|
|
||
| import io.sentry.core.SentryOptions; | ||
|
|
||
| public class SentryNdk { | ||
| static { | ||
| System.loadLibrary("sentry"); | ||
| } | ||
|
|
||
| static { | ||
| System.loadLibrary("sentry-android"); | ||
| } | ||
|
|
||
| private static native void initSentryNative(String cacheDirPath); | ||
|
|
||
| public static void notifyNewSerializedEnvelope(String path) { | ||
| System.out.println("envelope written to " + path); | ||
| } | ||
|
|
||
| public static void init(SentryOptions options, String cacheDirPath) { | ||
| // Java_example | ||
| initSentryNative(cacheDirPath); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #include <string.h> | ||
| #include <sentry.h> | ||
| #include <jni.h> | ||
| #include <malloc.h> | ||
| #include <android/log.h> | ||
|
|
||
| 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_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, send_envelope, NULL); | ||
|
|
||
| sentry_options_set_environment(options, "Production"); | ||
| sentry_options_set_release(options, "5fd7a6cd"); | ||
| sentry_options_set_debug(options, 1); | ||
| sentry_options_set_dsn(options, "http://[email protected]/1322857"); | ||
|
|
||
| sentry_init(options); | ||
|
|
||
| sentry_value_t event = sentry_value_new_event(); | ||
| sentry_value_set_by_key(event, "message", | ||
| sentry_value_new_string("Hello World!")); | ||
|
|
||
| sentry_capture_event(event); | ||
|
|
||
| sentry_shutdown(); | ||
|
|
||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| rootProject.name = "sentry" | ||
| rootProject.buildFileName = "build.gradle.kts" | ||
|
|
||
| include("sentry-android", "sentry-android-core", "sentry-core", "sentry-sample") | ||
| include("sentry-android", "sentry-android-ndk", "sentry-android-core", "sentry-core", "sentry-sample") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.