Adding new source files for android build

764 views
Skip to first unread message

Rishi Josan

unread,
Oct 31, 2013, 1:41:04 AM10/31/13
to chromi...@chromium.org
Hi,

I want to add new classes to add to the existing functionality for the Android app. I feel I have to modify some *.gypi file. It would be great if someone could let me know how this works?


Rishi Josan

unread,
Oct 31, 2013, 1:41:55 AM10/31/13
to chromi...@chromium.org
ad which .gypi files to modify to include these new sources

Daniel Bratell

unread,
Oct 31, 2013, 5:38:39 AM10/31/13
to chromi...@chromium.org, Rishi Josan
On Thu, 31 Oct 2013 06:41:04 +0100, Rishi Josan <josan...@gmail.com>
wrote:
The build system lists the files to compile in .gyp (and sometimes .gypi)
files. Look for other similar files listed in those files and add your own
new files next to the similar files and you should be fine.

/Daniel

Lambros Lambrou

unread,
Oct 31, 2013, 1:53:43 PM10/31/13
to bra...@opera.com, chromium-dev, Rishi Josan
Hopefully an Android expert (not me) will weigh in shortly. If you're talking about adding new Java classes to an existing project, I don't think you need to modify any *.gyp[i] files, because the gyp files only hold the top-level Java source directories.

However, I found that it is beneficial to re-run build/gyp_chromium (or gclient runhooks) after adding new .java files. Otherwise, when you edit the new files, they don't trigger a re-build (when using Ninja, at least). It's as if the dependency information needs to be re-generated to account for the new .java files.

Lambros





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

Rishi Josan

unread,
Oct 31, 2013, 2:50:04 PM10/31/13
to chromi...@chromium.org, bra...@opera.com, Rishi Josan
I tried without modifying the *.gypi files, but that didn't work. I did place the files in a folder which has source files which are definitely compiled. I guess this folder is not included in its entirety. I have found a .gypi that mentions some of these files in it. I'll try to add my files here and see how it urns out.

BTW, I do rerun android_gyp after adding the new java files

Chris Hopman

unread,
Oct 31, 2013, 3:04:00 PM10/31/13
to josan...@gmail.com, chromium-dev, bra...@opera.com
I don't think there are any directories with java files where we only include some of the files in the build.

Rishi Josan

unread,
Nov 1, 2013, 12:38:54 AM11/1/13
to chromi...@chromium.org, josan...@gmail.com, bra...@opera.com
I added three new java classes in the "src/content/public/android/java/src/org/chromium/content/browser" folder. I am trying to create an object of one of these classes in TouchPoint.java which is in the same folder. I tried adding these files to some gyp files but got errors. If i try to compile, i get the "Cannot find Symbols.." error.

Lambros Lambrou

unread,
Nov 1, 2013, 5:21:17 PM11/1/13
to Rishi Josan, chromium-dev, bra...@opera.com
Are you sure your newly added .java files are not being compiled? For example, if you insert a deliberate error into your new file, do you see the expected failure message in your build output?

Maybe your new .java files *are* being compiled, but the error is in your changes to TouchPoint.java? Or maybe you forgot a "package" declaration in your new file?

More details would be helpful, for example: what error do you see, from which file?

Vicky Android

unread,
Oct 4, 2016, 9:41:22 AM10/4/16
to Chromium-dev, josan...@gmail.com, bra...@opera.com
Hi Team,

     I am trying to add my own java class to Chromium android project and I find difficulty in executing this.
I am getting error when I try to run this project with new classes and it shows error near import and all class that I have added. Please help me how to build the project with this. I usually try to run the project using these to commands
    ninja -C out/Default chrome_public_apk_incremental
    out/Default/bin/install_chrome_public_apk_incremental -v
For your clarification I have added import for newly added files.

I have also attached my error message screen-shot with this
Screenshot from 2016-10-03 16-31-29.png

Andrew Grieve

unread,
Oct 4, 2016, 10:05:00 AM10/4/16
to vickyy...@gmail.com, Chromium-dev, josan...@gmail.com, Daniel Bratell
Sounds like you haven't added the new .java files to the corresponding BUILD.gn files.

Vicky Android

unread,
Oct 4, 2016, 10:13:27 AM10/4/16
to Chromium-dev, vickyy...@gmail.com, josan...@gmail.com, bra...@opera.com
Hi Andrew,
    Thanks for your reply and yes I dint have any idea about that. Will try and let you know soon.
Thanks again.

Vicky Android

unread,
Oct 4, 2016, 11:21:44 AM10/4/16
to Chromium-dev, vickyy...@gmail.com, josan...@gmail.com, bra...@opera.com
Hi Andrew

    I could find that I have a BUILD.gn file inside my Chrome-Android in following path  /home/user/Desktop/Chromium/android/src/chrome/android/BUILD.gn .
But I don't find any existing java file that has been mentioned there. Is that necessary only if I add new Java files to it ? or mandatory ?
sample data would be more helpful.
Thanks in advance.

  

On Tuesday, October 4, 2016 at 7:35:00 PM UTC+5:30, Andrew Grieve wrote:

Jeremy Roman

unread,
Oct 4, 2016, 11:33:57 AM10/4/16
to vickyy...@gmail.com, Chromium-dev, josan...@gmail.com, Daniel Bratell
See, e.g., chrome/android/java_sources.gni.

Thiago Farina

unread,
Oct 4, 2016, 11:40:26 AM10/4/16
to vickyy...@gmail.com, Chromium-dev, josan...@gmail.com, bra...@opera.com


On Tuesday, October 4, 2016, Vicky Android <vickyy...@gmail.com> wrote:
Hi Andrew

    I could find that I have a BUILD.gn file inside my Chrome-Android in following path  /home/user/Desktop/Chromium/android/src/chrome/android/BUILD.gn .
But I don't find any existing java file that has been mentioned there. Is that necessary only if I add new Java files to it ? or mandatory ? 

If you want to have your java class built you have to add it to some gn target, and that will
depend on what target you want to build. If you don't add your .java file to any BUILD.gn,
'gn gen' will not see it and thus when running ninja it won't be built.


--
Thiago Farina

Vicky Android

unread,
Oct 4, 2016, 11:46:56 AM10/4/16
to Chromium-dev, vickyy...@gmail.com, josan...@gmail.com, bra...@opera.com
Hi Jeremy,

       Perfect, That worked as expected and I hope this will solve my problem.
Thanks A lot. Andrew for you too.

Vicky Android

unread,
Oct 25, 2016, 10:12:30 AM10/25/16
to Chromium-dev, vickyy...@gmail.com, josan...@gmail.com, bra...@opera.com
Hi Devs,

     I am trying to make use of existing Guava library in android chromium source code.
in the  following path : /home/User/Desktop/Chromium/android/src/third_party/guava
When I tried using the Class files in Java class it throws error as expected, as I havnt imported it.

on Checking the procedure to add jar files for java class imports
https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/6csaJlocLSM

I have added the jar file to 

android_library("chrome_java") {
  deps = [ 
              ...
             "//third_party/guava:guava-18.0",
    ]
}

I have also tried this to android_resources("chrome_java_resources")  under deps and produce the same error message .

ERROR Unresolved dependencies.
//chrome/android:chrome_java__lint(//build/toolchain/android:clang_arm)
  needs //third_party/guava:guava-18.0(//build/toolchain/android:clang_arm)
//chrome/android:chrome_java__compile_java__javac(//build/toolchain/android:clang_arm)
  needs //third_party/guava:guava-18.0(//build/toolchain/android:clang_arm)
//chrome/android:chrome_java__compile_java__process_prebuilt__filter(//build/toolchain/android:clang_arm)
  needs //third_party/guava:guava-18.0(//build/toolchain/android:clang_arm)


please help me to import guava library into java files.

Thanks,
Vigneshwaran

Andrew Grieve

unread,
Oct 25, 2016, 2:31:02 PM10/25/16
to vicky Android, Chromium-dev, Rishi Josan, Daniel Bratell
I looks like the target name is "guava_java", not "guava-18.0".

Vicky Android

unread,
Oct 26, 2016, 3:19:17 AM10/26/16
to Chromium-dev, vickyy...@gmail.com, josan...@gmail.com, bra...@opera.com
Hi Andrew,

    Thanks Again, It worked as you said. I was not aware that I should use java_prebuilt target name.
and one more thing. Just to know. If I am planing to make use of some other libraray like gson or Volley, is it enough if i put the jar file in ThirdPaty folder with a libName_folder and create Build.gn with

import("//build/config/android/rules.gni")

java_prebuilt("libName_java") {
  supports_android = true
  jar_path = "lib/libName.jar"
}

Thanks,
Vigneshwaran

Andrew Grieve

unread,
Oct 28, 2016, 2:22:08 PM10/28/16
to vicky Android, Chromium-dev, Rishi Josan, Daniel Bratell
That should work fine :)
Message has been deleted

Vicky Android

unread,
Nov 3, 2016, 12:24:43 PM11/3/16
to Chromium-dev, vickyy...@gmail.com, josan...@gmail.com, bra...@opera.com

Hi Developers,
 
Finally I was able to build the Chromium apk successfully using GN build. And the problem I have is when I sign the apk, it doesn’t work on the mobile.  The process I tried with the apksigning using Command line. 
 
1.       I have used jarsigner and zipAlign for this. I am successful in creating the Signed Apk. But when I try to install on my device(5.0 L) and any other devices. I am getting "Describe error: There is a problem parsing the package". 
 
2.       I Have also tried apk-signer.jar that I downloaded from a website and even this produces the same result.
 
3.       When I had a look on AndroidStuido website for Command Line signing apk. Link : https://developer.android.com/studio/publish/app-signing.html
zipalign command is working fine and when I execute next command apksigner. It throws error: 'apksigner' is not recognized as an internal or external command, operable program or batch file. The zipAlign jar is available in android/buildtools/sdk/version , but could not locate apksigner.
 
Please help me on this.
 
I usally build android apk using : ninja -C out/Default chrome_public_apk and for faster deployment : ninja -C out/Default chrome_public_apk_incremental.

Thanks,
Vigneshwaran

Primiano Tucci

unread,
Nov 3, 2016, 12:52:19 PM11/3/16
to vickyy...@gmail.com, Chromium-dev, josan...@gmail.com, bra...@opera.com
Attaching logcat might help here. I suspect this might be related with the fact that, depending on which sdk level you are targeting, we might try to load the libchrome.so directly from the apk. Which requires the apk to stay aligned and the .so to stay non-compressed. 
Can you try setting load_library_from_apk = false in the GN args?

Torne (Richard Coles)

unread,
Nov 3, 2016, 1:10:21 PM11/3/16
to prim...@chromium.org, vickyy...@gmail.com, Chromium-dev, josan...@gmail.com, bra...@opera.com
The easiest way is to just let our build process sign and align the APK for you, instead of resigning it yourself. It already does this (just with generic, not private keys) and you can simply point the signing parameters somewhere else. See https://cs.chromium.org/chromium/src/build/config/android/config.gni?l=56
Just set default_android_keystore_path, default_android_keystore_name, and default_android_keystore_password to the appropriate values for your keystore, and the build will be signed with your keys instead of ours.

Vicky Android

unread,
Nov 4, 2016, 10:10:29 AM11/4/16
to Chromium-dev, prim...@chromium.org, vickyy...@gmail.com, josan...@gmail.com, bra...@opera.com
Hi Torne and Primiano Tucci,

     Thank you Torne, I was able to build the Signed .apk using my Keystore and password by changing the values in config.gni and placing the keystore in right place.
and Primiano Thanks for your suggestion.

Thanks.

Vicky Android

unread,
Nov 8, 2016, 3:27:07 AM11/8/16
to Chromium-dev, prim...@chromium.org, vickyy...@gmail.com, josan...@gmail.com, bra...@opera.com
Hi Developers,

     Now I am looking to find the direct Webservice calls made by Chromium While I click or POST on Webkit pages. I need to find
  •  Whether Its a GET or POST .
  •  Want to know where the core Http url request are processed to send data. 
  •  like wise in Google Chrome developers tool, network track on webpages gives me URL information like GET or Post and If it is POST it gives FormData that I have submitted.
  •  I want to get these details in Chromium android But I am not successful in finding this out in /home/user/Desktop/Chromium/android/src/chrome/android/java...
  •  I think Http request are not made in Java code in the path I given and Want to know where they actually Do. So that I can customize the code.

Thanks
Vigneshwaran.

Message has been deleted

Vicky Android

unread,
Jan 13, 2017, 10:20:36 AM1/13/17
to Chromium-dev, prim...@chromium.org, vickyy...@gmail.com, josan...@gmail.com, bra...@opera.com
 Hi Torne,

         I am facing issue in building the release for Android chromium I have followed the below steps
1) I have updated the args.gn file with the is_debug  = false
I have attached my args.gn File screen shot with the this

2) I am getting the below error on building it in this way

ERROR at //build/config/android/config.gni:160:3: Assertion failed.
  assert(!(enable_incremental_javac && !is_java_debug))
  ^-----
See //build/config/compiler/compiler.gni:5:1: whence it was imported.
import("//build/config/android/config.gni")
^-----------------------------------------
See //BUILD.gn:11:1: whence it was imported.
import("//build/config/compiler/compiler.gni")
^--------------------------------------------

But When I build it in is_debug  = true , App is working fine.

Thanks,

GN_args.png
ReleaseBuild_error.png

John Budorick

unread,
Jan 13, 2017, 10:30:57 AM1/13/17
to vickyy...@gmail.com, Chromium-dev, prim...@chromium.org, josan...@gmail.com, bra...@opera.com
On Fri, Jan 13, 2017 at 7:21 AM Vicky Android <vickyy...@gmail.com> wrote:
 Hi Torne,

         I am facing issue in building the release for Android chromium I have followed the below steps
1) I have updated the args.gn file with the is_debug  = false
I have attached my args.gn File screen shot with the this

2) I am getting the below error on building it in this way

ERROR at //build/config/android/config.gni:160:3: Assertion failed.
  assert(!(enable_incremental_javac && !is_java_debug))
  ^-----

You can't set both is_debug = false and enable_incremental_javac = true. If you want to do a release build, you'll need to set enable_incremental_javac = false.
 
See //build/config/compiler/compiler.gni:5:1: whence it was imported.
import("//build/config/android/config.gni")
^-----------------------------------------
See //BUILD.gn:11:1: whence it was imported.
import("//build/config/compiler/compiler.gni")
^--------------------------------------------

But When I build it in is_debug  = true , App is working fine.

Thanks,

Vicky Android

unread,
Jan 13, 2017, 10:57:00 AM1/13/17
to Chromium-dev, vickyy...@gmail.com, prim...@chromium.org, josan...@gmail.com, bra...@opera.com
Hi John Budorick,

      Great, this solution worked for me. Thank you very much John.
 I have two questions to clarify
1) will this change the Chromium developer build version in settings -> About page ?
2) Will this Chromium improve the speed ? because debug build is not responsive/faster than Stable Chrome App.

Thanks
 

John Budorick

unread,
Jan 13, 2017, 11:01:03 AM1/13/17
to vickyy...@gmail.com, Chromium-dev, prim...@chromium.org, josan...@gmail.com, bra...@opera.com
On Fri, Jan 13, 2017 at 7:57 AM Vicky Android <vickyy...@gmail.com> wrote:
Hi John Budorick,

      Great, this solution worked for me. Thank you very much John.
 I have two questions to clarify
1) will this change the Chromium developer build version in settings -> About page ?

I would guess not but haven't checked.
 
2) Will this Chromium improve the speed ? because debug build is not responsive/faster

A release build should be faster than a debug build. I'm not sure if a local release build will be faster than Chrome Stable.

Vicky Android

unread,
Jan 13, 2017, 11:18:38 AM1/13/17
to Chromium-dev, vickyy...@gmail.com, prim...@chromium.org, josan...@gmail.com, bra...@opera.com
Thanks for your reply, Let me check and post it here. So that It may help someone in future.

Thanks,
Message has been deleted
Message has been deleted

Vicky Android

unread,
Feb 17, 2017, 5:38:30 AM2/17/17
to Chromium-dev, vickyy...@gmail.com, prim...@chromium.org, josan...@gmail.com, bra...@opera.com
Hi John Budorick,
   
After changing enable_incremental_javac = false. in args.gn file the Chromium app works much faster than before and equals the Stable Chrome app speed.
Thank you very much.

Thanks,
Vigneshwaran

鄒曉穎

unread,
Feb 17, 2017, 6:01:42 AM2/17/17
to vickyy...@gmail.com, josan...@gmail.com, bra...@opera.com, prim...@chromium.org, Chromium-dev


a0981...@gmail.com ~穎ㄟ~。◕‿◕。..ღ.ღ.ღ.ღ..~最愛~

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+unsubscribe@chromium.org.

Reply all
Reply to author
Forward
0 new messages