3

I am developing a Firefox addon and would like to test it on Android. I have downloaded Nightly on the phone and have root access.

Inside of the addon's directory, I run the following command:

cfx run -a fennec-on-device -b /bin/adb --mobile-app fennec --force-mobile

as according to the documentation.

Nightly is then opened up on my phone and I get the following output at the terminal:

Launching mobile application with intent name org.mozilla.fennec
Pushing the addon to your device
Starting: Intent { act=android.activity.MAIN cmp=org.mozilla.fennec/.App (has extras) }

But there is no debug output whatsoever. I have tried putting console.log statements at the top of my main.js and the first content script that is supposed to load.

Is this a common problem? What else can I check? If more specific information is necessary, please post a comment.

Filipe Silva
  • 21,189
  • 5
  • 53
  • 68
DJG
  • 6,413
  • 4
  • 30
  • 51
  • 2
    Does it work if you run it with `--mobile-app firefox` instead? What about doing an `adb logcat`? Anything suspicious there? – nmaier Sep 14 '13 at 18:13
  • @nmaier I tried `adb logcat` and I got a lot of `D/ConnectivityService( 1327): getMobileDataEnabled returning false`. I don't know what to look for as I am new to android development. – DJG Sep 15 '13 at 20:02
  • Okay, finally got `--mobile-app firefox` to work and got this output: `error: my_project: An exception occurred.` I guess that counts as debug output, although it leaves much to be desired :) – DJG Sep 15 '13 at 20:47
  • My guess is that the SDK is not compatible with Firefox Android anymore. You could ask at their [IRC channel](https://wiki.mozilla.org/Jetpack) or [file a bug](https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK&component=Documentation) – nmaier Sep 15 '13 at 20:55

2 Answers2

3

I realise this question is almost a year old but I was having similar issues until I found a Mozilla Bugzilla issue reporting that cfx test wasn't showing results without "-v" (https://bugzilla.mozilla.org/show_bug.cgi?id=773028)

I added "-v" to my "cfx run", making it:

cfx run -v -a fennec-on-device -b "C:\Users\Ben\AppData\Local\Android\android-sdk\platform-tools\adb.exe" --mobile-app fennec --force-mobile

..and suddenly I actually get some info beyond "Starting: Intent"...

Running cfx for attached Android device... Launching mobile application with intent name org.mozilla.fennec Pushing the addon to your device Starting: Intent { act=android.activity.MAIN cmp=org.mozilla.fennec/.App (has extras) } --------- beginning of /dev/log/main --------- beginning of /dev/log/system Could not read chrome manifest 'file:///data/data/org.mozilla.fennec/chrome.manifest'. OpenGL compositor Initialized Succesfully. Version: OpenGL ES 2.0 Vendor: ARM Renderer: Mali-400 MP FBO Texture Target: TEXTURE_2D Adding HealthReport:RequestSnapshot observer. Sending snapshot message. main.js starting console.log: tldr: main.js starting ....

BenKennish
  • 176
  • 1
  • 4
1

I found a workaround to get debug output by wrapping my entire main.js in a try/catch block like so:

try {
  var pageMod = require("sdk/page-mod");

  pageMod.PageMod({/* etc */});

  // etc.

}
catch (e) {
  console.log(e);
}

I then test my app using --mobile-app firefox instead of --mobile-app fennec as @nmaier suggested in a comment.

DJG
  • 6,413
  • 4
  • 30
  • 51