Skip to content

Fix NegativeArraySizeException in MainActivity - #244

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
negativearraysizeexception--5-ku7bl9
Draft

Fix NegativeArraySizeException in MainActivity#244
cursor[bot] wants to merge 1 commit into
mainfrom
negativearraysizeexception--5-ku7bl9

Conversation

@cursor

@cursor cursor Bot commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Fixed the NegativeArraySizeException that occurs when clicking the 'negative_index' button in MainActivity.

Root Cause

The bug was caused by a hardcoded negative array size at line 61 in MainActivity.java:

int[] a = new int[-5];

Fix

Changed the array size from -5 to 5:

int[] a = new int[5];

The negative sign was a typo that caused Java to throw a NegativeArraySizeException when attempting to allocate an array with a negative size.

Testing

  • The app should no longer crash when the 'negative_index' button is clicked
  • The array is now allocated with the correct positive size of 5

Fixes ANDROID-HW

Open in Web Open in Cursor 

Change array size from -5 to 5 in negative_index button handler.
The negative array size was causing a NegativeArraySizeException when
the button was clicked. This was a typo where -5 should have been 5.

Fixes [ANDROID-HW](https://demo.sentry.io/issues/7553601968/)
@sentry

sentry Bot commented Jul 24, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Android com.example.vu.android 24.12.26 (241226) release
Android com.example.vu.android 24.12.26 (241226) debug
Android com.example.vu.android 24.12.26 (241226) release

⚙️ android Build Distribution Settings

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (410e6f1) to head (b1c8cb9).

Files with missing lines Patch % Lines
...main/java/com/example/vu/android/MainActivity.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #244   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         16      16           
  Lines        883     883           
  Branches      67      67           
=====================================
  Misses       883     883           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

1 participant