Assertion failed in BUILD.gn due to android_java_prebuilt

295 views
Skip to first unread message

Iker Jamardo

unread,
Aug 8, 2016, 1:55:35 PM8/8/16
to Chromium-dev
Hello,

I just checked out the latest tag in the chromium repo and something that was working previously now is giving me an assertion fail in a BUILD.gn. I cannot come up with a different solution and I was wondering if there is someone that could help me.

In the chromium webview BUILD.gn I am trying to add 3 .jar files I need. AFAIK, from the rules.gni file, the way to do it is using the template "android_java_prebuilt" and it worked just fine in previous version of chromium checkouts I have done, but is failing in the latest tag I have checked out (54.0.2796.3).

I am not going to copy the whole BUILD.gn but this is the extract that is giving me problems:

...


# GYP: //android_webview/android_webview_tests.gypi:android_webview_apk
android_apk
("android_webview_apk") {
  deps
= [
   
":vrwebgl_zxing_jar",
   
":android_webview_apk_assets",
   
":android_webview_apk_resources",
   
"//android_webview:android_webview_java",
   
"//base:base_java",
   
"//base:base_java_test_support",
   
"//components/policy/android:policy_java_test_support",
   
"//content/public/android:content_java",
   
"//ui/android:ui_java",
 
]


...


android_java_prebuilt
("vrwebgl_zxing_jar") {

  jar_path
= "shell/zxing-2.3.0/android-integration-2.3.0-supportv4.jar"
}

As you may see, the apk generation entry is referencing the jars I need to reference. Of course, these jars need to be included in the final APK too. This is the error I am getting:

ERROR at //build/config/android/internal_rules.gni:92:9: Assertion failed.
       
assert(false, "Invalid java target name: $_target_label")
       
^-----
Invalid java target name: //android_webview/test:vrwebgl_zxing_jar
See //build/config/android/internal_rules.gni:1676:5: whence it was called.
    write_build_config
(_build_config_target_name) {
   
^----------------------------------------------
See //build/config/android/rules.gni:1363:5: whence it was called.
    java_prebuilt_impl
(target_name) {
   
^--------------------------------
See //android_webview/test/BUILD.gn:340:1: whence it was called.
android_java_prebuilt
("vrwebgl_zxing_jar") {
^-------------------------------------------
See //BUILD.gn:404:9: which caused the file to be included.
       
"//android_webview/test",
       
^-----------------------


From my understanding, the problem is that the names of the entries "android_java_prebuilt" is not correct. But, why is it working previously? I guess something has changed in ninja/gn?

Any help would be MUCH appreciated! Thanks in advance for you time!

Iker.

John Budorick

unread,
Aug 8, 2016, 2:51:01 PM8/8/16
to ik...@ludei.com, Chromium-dev
Hi Iker,

This failure means that your target does not match the naming rules laid out in _java_target_whitelist. Something like "vrwebgl_zxing_javalib" should work.

John

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Iker Jamardo

unread,
Aug 8, 2016, 3:19:35 PM8/8/16
to Chromium-dev, ik...@ludei.com
Thank you very much! How can I be aware of this type of changes in the future? Is there a mailing list or changelog I should definitively follow to check on these changes?

Regards,
Iker

Andrew Grieve

unread,
Aug 9, 2016, 10:14:44 PM8/9/16
to ik...@ludei.com, Chromium-dev
I added this assert and made no announcement for it. The assert() was supposed to be the way to inform other people that hit this that there is now a naming scheme. The error message could clearly be improved (it should probably say to refer to the comments in the file, which contain the whitelist). Perhaps this thread will make this infomation now just a web search away though :).
Reply all
Reply to author
Forward
0 new messages