Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,20 @@ and let the next build download the pre-built SDK again:
$ rm -rf modules/sentry-cocoa
$ dotnet build ... # downloads pre-built Cocoa SDK into modules/sentry-cocoa
```

## Local Sentry Android SDK checkout

Similarly, by default, `Sentry.Bindings.Android` downloads a pre-built Sentry Android SDK from
Maven. The version is specified in the `SentryAndroidSdkVersion` build property in `Sentry.Bindings.Android.csproj`.

If you want to build an unreleased Sentry Android SDK version from source instead,
you'll need to clone both the sentry-java and the sentry-native repositories and publish these locally:
```sh
$ cd $(LocalSentryJavaRepoDir) && ./gradlew publishToMavenLocal
$ cd $(LocalSentryNativeRepoDir)/ndk && ./gradlew publishToMavenLocal
```

You'll also need to set `<UseLocalSentryMavenRepo>true</UseLocalSentryMavenRepo>` and `<SentryNativeNdkVersion>{whatever_version_you_checked_out}</SentryNativeNdkVersion>`
in the `Sentry.Bindings.Android.csproj`file.

To switch back again, simply revert those two build properties to their original values.
2 changes: 1 addition & 1 deletion src/Sentry.Bindings.Android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Instead, reference one of the following:

## SDK Developers and Contributors

For .NET SDK contributors, most of the classes in this package are generated automatically.
For .NET SDK contributors, most of the classes in this package are generated automatically. These can be found in the `src/Sentry.Bindings.Android/obj/{Configuration}/{tfm}/generated/src/` folder after building the project.

- Post generation transformations are controlled via various XML files stored in the `/Transforms` directory (see [Java Bindings Metadata documentation](https://learn.microsoft.com/en-gb/previous-versions/xamarin/android/platform/binding-java-library/customizing-bindings/java-bindings-metadata) for details).

Expand Down
47 changes: 44 additions & 3 deletions src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,37 @@
<TargetFrameworks>$(LatestAndroidTfm);$(PreviousAndroidTfm)</TargetFrameworks>
<SentryAndroidSdkVersion>8.29.0</SentryAndroidSdkVersion>
<SentryAndroidSdkDirectory>$(BaseIntermediateOutputPath)sdks\$(TargetFramework)\Sentry\Android\$(SentryAndroidSdkVersion)\</SentryAndroidSdkDirectory>
<!-- This gets resolved by the DownloadSentryAndroidSdk target -->
<!-- This gets resolved by the DownloadSentryAndroidSdk unless using local maven references -->
<SentryNativeNdkVersion></SentryNativeNdkVersion>
<Description>.NET Bindings for the Sentry Android SDK</Description>

<!--
Optional dev override: enable to resolve local maven references
Example:
dotnet build -p:UseLocalSentryMavenRepo=true

To populate MavenLocal from your checkout:
cd $(LocalSentryJavaRepoDir) && ./gradlew publishToMavenLocal
cd $(LocalSentryNativeRepoDir)/ndk && ./gradlew publishToMavenLocal

Note:
1. Make sure the native-ndk-version you check out and build matches what the android sdk expects (or a fork of it)
2. You will need to manually set the `SentryNativeNdkVersion` property as this no longer gets resolved from
the POM files from the Java SDK when using local maven artifacts.
-->
<UseLocalSentryMavenRepo>false</UseLocalSentryMavenRepo>
<LocalSentryMavenRepoDir Condition="'$(LocalSentryMavenRepoDir)' == ''">$([System.Environment]::GetFolderPath(SpecialFolder.UserProfile))/.m2/repository/</LocalSentryMavenRepoDir>
<LocalSentryJarPath>$(LocalSentryMavenRepoDir)io/sentry/sentry/$(SentryAndroidSdkVersion)/sentry-$(SentryAndroidSdkVersion).jar</LocalSentryJarPath>
<LocalSentryAndroidCoreAarPath>$(LocalSentryMavenRepoDir)io/sentry/sentry-android-core/$(SentryAndroidSdkVersion)/sentry-android-core-$(SentryAndroidSdkVersion).aar</LocalSentryAndroidCoreAarPath>
<LocalSentryAndroidNdkAarPath>$(LocalSentryMavenRepoDir)io/sentry/sentry-android-ndk/$(SentryAndroidSdkVersion)/sentry-android-ndk-$(SentryAndroidSdkVersion).aar</LocalSentryAndroidNdkAarPath>
<LocalSentryAndroidReplayAarPath>$(LocalSentryMavenRepoDir)io/sentry/sentry-android-replay/$(SentryAndroidSdkVersion)/sentry-android-replay-$(SentryAndroidSdkVersion).aar</LocalSentryAndroidReplayAarPath>
<LocalSentryPomPath>$([System.String]::Copy($(LocalSentryJarPath)).Replace('.jar', '.pom'))</LocalSentryPomPath>
<LocalSentryAndroidCorePomPath>$([System.String]::Copy($(LocalSentryAndroidCoreAarPath)).Replace('.aar', '.pom'))</LocalSentryAndroidCorePomPath>
<LocalSentryAndroidNdkPomPath>$([System.String]::Copy($(LocalSentryAndroidNdkAarPath)).Replace('.aar', '.pom'))</LocalSentryAndroidNdkPomPath>
<LocalSentryAndroidReplayPomPath>$([System.String]::Copy($(LocalSentryAndroidReplayAarPath)).Replace('.aar', '.pom'))</LocalSentryAndroidReplayPomPath>
<LocalSentryNativeNdkAarPath>$(LocalSentryMavenRepoDir)io/sentry/sentry-native-ndk/$(SentryNativeNdkVersion)/sentry-native-ndk-$(SentryNativeNdkVersion).aar</LocalSentryNativeNdkAarPath>
<LocalSentryNativeNdkPomPath>$([System.String]::Copy($(LocalSentryNativeNdkAarPath)).Replace('.aar', '.pom'))</LocalSentryNativeNdkPomPath>

<!-- Android binding warnings - these are largely unavoidable due to Java interface circular dependencies -->
<!-- Only suppress warnings that are confirmed to be expected/unavoidable -->
<!-- BG8801: Invalid parameter types - caused by circular interface dependencies in Sentry Java SDK -->
Expand Down Expand Up @@ -73,13 +100,27 @@
</ItemGroup>

<!-- Starting with .NET 9 we can detect Java dependencies using POM files and AndroidMavenLibrary references -->
<ItemGroup>
<ItemGroup Condition="'$(UseLocalSentryMavenRepo)' != 'true'">
<AndroidMavenLibrary Include="io.sentry:sentry" Version="$(SentryAndroidSdkVersion)" />
<AndroidMavenLibrary Include="io.sentry:sentry-android-core" Version="$(SentryAndroidSdkVersion)" />
<AndroidMavenLibrary Include="io.sentry:sentry-android-ndk" Version="$(SentryAndroidSdkVersion)" />
<AndroidMavenLibrary Include="io.sentry:sentry-android-replay" Version="$(SentryAndroidSdkVersion)" />
</ItemGroup>

<!-- Resolve Java dependencies from local sentry-java build outputs instead, if appropriate -->
<ItemGroup Condition="'$(UseLocalSentryMavenRepo)' == 'true'">
<AndroidLibrary Include="$(LocalSentryJarPath)" Manifest="$(LocalSentryPomPath)"
JavaArtifact="io.sentry:sentry:$(SentryAndroidSdkVersion)" />
<AndroidLibrary Include="$(LocalSentryAndroidCoreAarPath)" Manifest="$(LocalSentryAndroidCorePomPath)"
JavaArtifact="io.sentry:sentry-android-core:$(SentryAndroidSdkVersion)" />
<AndroidLibrary Include="$(LocalSentryAndroidNdkAarPath)" Manifest="$(LocalSentryAndroidNdkPomPath)"
JavaArtifact="io.sentry:sentry-android-ndk:$(SentryAndroidSdkVersion)" />
<AndroidLibrary Include="$(LocalSentryAndroidReplayAarPath)" Manifest="$(LocalSentryAndroidReplayPomPath)"
JavaArtifact="io.sentry:sentry-android-replay:$(SentryAndroidSdkVersion)" />
<AndroidLibrary Include="$(LocalSentryNativeNdkAarPath)" Manifest="$(LocalSentryNativeNdkPomPath)"
JavaArtifact="io.sentry:sentry-native-ndk:$(SentryNativeNdkVersion)" />
</ItemGroup>

<ItemGroup>
<AndroidLibrary Include="..\..\lib\sentry-android-supplemental\bin\sentry-android-supplemental.jar" />
<AndroidNativeLibrary Include="..\..\lib\sentrysupplemental\bin\arm64-v8a\libsentrysupplemental.so" Abi="arm64-v8a" />
Expand All @@ -88,7 +129,7 @@
<AndroidNativeLibrary Include="..\..\lib\sentrysupplemental\bin\x86_64\libsentrysupplemental.so" Abi="x86_64" />
</ItemGroup>

<Target Name="DownloadSentryAndroidSdk" BeforeTargets="CollectPackageReferences">
<Target Name="DownloadSentryAndroidSdk" BeforeTargets="CollectPackageReferences" Condition="'$(UseLocalSentryMavenRepo)' != 'true'">
Comment thread
sentry[bot] marked this conversation as resolved.
<!-- The native-ndk exists outside of the android-ndk now. We're downloading the POM file to get the version of the native-ndk. -->
<DownloadFile
SourceUrl="https://repo1.maven.org/maven2/io/sentry/sentry-android-ndk/$(SentryAndroidSdkVersion)/sentry-android-ndk-$(SentryAndroidSdkVersion).pom"
Expand Down
Loading