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
1 change: 1 addition & 0 deletions sentry-samples/sentry-samples-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ dependencies {
implementation(libs.sentry.native.ndk)
implementation(libs.timber)

debugImplementation(projects.sentryAndroidDistribution)
debugImplementation(libs.leakcanary)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import io.sentry.Attachment;
import io.sentry.ISpan;
import io.sentry.MeasurementUnit;
import io.sentry.Sentry;
import io.sentry.UpdateStatus;
import io.sentry.instrumentation.file.SentryFileOutputStream;
import io.sentry.protocol.Feedback;
import io.sentry.protocol.User;
Expand Down Expand Up @@ -304,6 +306,40 @@ public void run() {
Sentry.replay().enableDebugMaskingOverlay();
});

binding.checkForUpdate.setOnClickListener(
view -> {
Toast.makeText(this, "Checking for updates...", Toast.LENGTH_SHORT).show();
Sentry.distribution()
.checkForUpdate(
result -> {
runOnUiThread(
() -> {
String message;
if (result instanceof UpdateStatus.NewRelease) {
UpdateStatus.NewRelease newRelease = (UpdateStatus.NewRelease) result;
message =
"Update available: "
+ newRelease.getInfo().getBuildVersion()
+ " (Build "
+ newRelease.getInfo().getBuildNumber()
+ ")\nDownload URL: "
+ newRelease.getInfo().getDownloadUrl();
} else if (result instanceof UpdateStatus.UpToDate) {
message = "App is up to date!";
} else if (result instanceof UpdateStatus.NoNetwork) {
UpdateStatus.NoNetwork noNetwork = (UpdateStatus.NoNetwork) result;
message = "No network connection: " + noNetwork.getMessage();
} else if (result instanceof UpdateStatus.UpdateError) {
UpdateStatus.UpdateError error = (UpdateStatus.UpdateError) result;
message = "Error checking for updates: " + error.getMessage();
} else {
message = "Unknown status";
}
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
});
});
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Debug Dependency Causes Release Build Failures

The checkForUpdate button handler in MainActivity unconditionally calls Sentry.distribution().checkForUpdate() and references UpdateStatus types. Since sentry-android-distribution is a debugImplementation dependency, release builds will encounter compilation errors or runtime crashes when this code is executed.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@runningcode I'm assuming cursor is incorrect here since the Sentry noop impl for sentry-android-distribution implements checkForUpdate to always return UpdateStatus.UpToDate or similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good to check this. UpdateStatus is part of the api in sentry (not sentry-android-distribution) so it is always there.
The NoOpDistributionApi will be available in release builds that don’t have sentry-android-distribution and this check will always return UpdateStatus.UpToDate


setContentView(binding.getRoot());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@
android:layout_height="wrap_content"
android:text="@string/enable_replay_debug_mode"/>

<Button
android:id="@+id/check_for_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/check_for_update"/>

</LinearLayout>

</ScrollView>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<string name="throw_in_coroutine">Throw exception in coroutine</string>
<string name="enable_replay_debug_mode">Enable Replay Debug Mode</string>
<string name="show_dialog">Show Dialog</string>
<string name="check_for_update">Check for Update</string>
<string name="back_main">Back to Main Activity</string>
<string name="tap_me">text</string>
<string name="lipsum">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh lorem, venenatis sed nulla vel, venenatis sodales augue. Mauris varius elit eu ligula volutpat, sed tincidunt orci porttitor. Donec et dignissim lacus, sed luctus ipsum. Praesent ornare luctus tortor sit amet ultricies. Cras iaculis et diam et vulputate. Cras ut iaculis mauris, non pellentesque diam. Nunc in laoreet diam, vitae accumsan eros. Morbi non nunc ac eros molestie placerat vitae id dolor. Quisque ornare aliquam ipsum, a dapibus tortor. In eu sodales tellus.
Expand Down
Loading