Generate .INFO for including .AAR in Android build?

261 views
Skip to first unread message

Dean Wedel

unread,
Jan 29, 2025, 9:12:18 AM1/29/25
to Chromium-dev
I'm trying to include a pre-built Sentry AAR file downloaded from:

But my Android APK build fails complaining about the missing ".info" file.
What should I do to correct this problem?

Dean Wedel

unread,
Jan 29, 2025, 9:14:47 AM1/29/25
to Chromium-dev, Dean Wedel
FYI:
My BUILD.gn entry looks like this:
android_aar_prebuilt("sentry-android-core") {
  aar_path = "android/sentry-android-core-${_sentry_version}.aar"
  info_path = "android/sentry-android-core-${_sentry_version}.info"
  proguard_configs = [ "android/proguard-rules.pro" ]
}

Sam Maier

unread,
Jan 29, 2025, 9:32:13 AM1/29/25
to dean....@gmail.com, Chromium-dev
The error message you should have got explains it:
"android_aar_prebuilt() cached .info file is out-of-date. Run gn gen with update_android_aar_prebuilts=true to update it"

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/03be7619-560b-4270-a9b0-aa9b661c783en%40chromium.org.

Dean Wedel

unread,
Jan 29, 2025, 11:12:40 AM1/29/25
to Chromium-dev, Sam Maier, Chromium-dev, dean....@gmail.com
Thanks for that direction.

I ran the command like this:
$ gn gen update_android_aar_prebuilts=true
Done. Made 20437 targets from 3681 files in 2485ms


And next when I tried to build it failed like this:
$ autoninja -C out/Default chrome_public_apk -j 10
ninja: Entering directory `out/Default'
[0/1] Regenerating ninja files
ERROR at //build/config/android/rules.gni:4201:32: Could not read file.
    _scanned_files = read_file(_info_path, "scope")
                               ^---------
I resolved this to "/home/dean/chromium5a/src/third_party/sentry/android/sentry-android-core-8.0.0.info".
See //third_party/sentry/BUILD.gn:10:1: whence it was called.
android_aar_prebuilt("sentry-android-core") {
^---------------------------------------------
See //build/android/BUILD.gn:91:9: which caused the file to be included.
        "//third_party/sentry:sentry",
        ^----------------------------
FAILED: build.ninja.stamp
../../buildtools/linux64/gn --root=../.. -q --regeneration gen .
ninja: error: rebuilding 'build.ninja': subcommand failed


I'm not sure what "scope" file it is wanting? or how to fix this?

Dean Wedel

unread,
Jan 29, 2025, 1:02:05 PM1/29/25
to Chromium-dev, Dean Wedel, Sam Maier, Chromium-dev
One thing that I notice is that the "gn gen update_android_aar_prebuilts=true" command didn't generate any ".info" file for the Sentry .aar ~ at least not in it's directory.
Did I need to add something else onto that command?

Dean Wedel

unread,
Jan 30, 2025, 7:08:38 AM1/30/25
to Chromium-dev, Dean Wedel, Sam Maier, Chromium-dev
Just an answer if anyone else is stumbling on a similar missing ".info" file problem. I generated it from the ".aar" with these steps in my situation:
1. Changed to the directory below where the ".aar" file is located: $ cd third_party/sentry
2. Ran this command: $ gn gen --args='target_os="android" update_android_aar_prebuilts=true' out/tmp
3. Then cleaned the unneeded output which leaves the newly created "info" file: $ rm -r out/tmp

Dean Wedel

unread,
Jan 30, 2025, 7:15:15 AM1/30/25
to Chromium-dev, Dean Wedel, Sam Maier, Chromium-dev
However that build results in the following failure: Any ideas what I need to change to fix this problem?
$ autoninja -C out/Default chrome_public_apk -j 10
ninja: Entering directory `out/Default'
[0/1] Regenerating ninja files
ERROR at //build/config/android/internal_rules.gni:139:9: Assertion failed.
        assert(false, "Invalid java library target name: $_target_label")
        ^-----
Invalid java library target name: //third_party/sentry:sentry-android-core__classes
See //build/config/android/internal_rules.gni:3746:5: whence it was called.
    write_build_config(_build_config_target_name) {
    ^----------------------------------------------
See //build/config/android/rules.gni:1419:5: whence it was called.
    java_library_impl(target_name) {
    ^-------------------------------
See //build/config/android/rules.gni:4371:7: whence it was called.
      java_prebuilt(_jar_target_name) {
      ^--------------------------------

See //third_party/sentry/BUILD.gn:10:1: whence it was called.
android_aar_prebuilt("sentry-android-core") {
^---------------------------------------------
See //chrome/android/BUILD.gn:273:7: which caused the file to be included.

      "//third_party/sentry:sentry",
      ^----------------------------
FAILED: build.ninja.stamp
../../buildtools/linux64/gn --root=../.. -q --regeneration gen .
ninja: error: rebuilding 'build.ninja': subcommand failed

Sam

unread,
Jan 31, 2025, 3:37:37 PM1/31/25
to Chromium-dev, Dean Wedel, Sam Maier, Chromium-dev
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",
]

Sam

unread,
Jan 31, 2025, 3:37:39 PM1/31/25
to Chromium-dev, Dean Wedel, Sam Maier, Chromium-dev
Another option there is to open the file `build/config/android/config.gni` and change the value of `update_android_aar_prebuilts = false` to `update_android_aar_prebuilts = true`. This will update .info files for all dependencies and integrates nicely into a build system.
Reply all
Reply to author
Forward
0 new messages