You're seeing this error because there are rules around naming for Java dependencies (the value passed to the android_aar_prebuilt target).
If you take a look at third_party/android_deps/BUILD.gn, you'll see that the linked libraries use underscores and a _java suffix.
Change the value passed to android_aar_prebuilt to be "sentry_android_core_java" and you'll be on your way.
A quick way to debug these issues is to search for the error message and review the logic that results in that error.
In this case, you need to look at build/config/android/internal_rules.gni
The logic in question is:
if (filter_exclude([ _target_label ], java_library_patterns) != [] ||
filter_exclude([ _target_label ], java_resource_patterns) == []) {
assert(false, "Invalid java library target name: $_target_label")
}
Search in the file for "java_library_patterns" and you'll find the following:
# All _java_library_types targets must conform to these patterns. This includes
# all non-leaf targets that use java_library_impl.
java_library_patterns = [
"*_java",
"*_javalib",
"*javatests",
"*_bundle_module",
"*:*_java_*", # E.g. chrome_java_test_support
"*:java",
"*/java", # to allow filtering without expanding labels //a/java ->
# //a/java:java
"*:junit",
"*/junit",
"*:junit_*",
"*:*_junit_*",
# TODO(agrieve): Rename to glue_java
"//android_webview/glue",
"//android_webview/glue:glue",
]