Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6860] Tooling: Android build process requires "Google APIs" even if "Ti.Map.createView" only occurs in comments

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2013-10-19T01:18:47.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/s2013 Sprint 21, 2013 Sprint 21 Core, Release 3.2.0
ComponentsAndroid, Tooling
Labelsandroidbuild, ay-verified, cb-verified
ReporterShawn Lipscomb
AssigneeChris Barber
Created2011-11-14T11:46:53.000+0000
Updated2013-11-12T12:33:19.000+0000

Description

Problem

For a Titanium mobile project on Android, if Titanium sees that you're using a Ti.Map.createView in your project, running on the emulator will fail unless your run configuration indicates use of one of the "Google APIs" Android API. I assume it is scanning the source js files for this. That's fine. The problem is that if the only place you have the text "Ti.Map.createView" is in a comment (// comment), Titanium does the same thing, and fails to install with the message, Package com.testing.testing9 requires unavailable shared library com.google.android.maps; failing!. I have to think that there are other things like that too. Titanium's build process should not detect things like this that are in comments, thus triggering the "Google APIs" requirement. I do not know if this affects iOS as well.

Test case

var win = Ti.UI.createWindow({
  layout:'vertical',
  exitOnClose:true,
  navBarHidden:true
});
var label = Ti.UI.createLabel({
  color:'white',
  text:'Hello World',
  width:'auto'
});
win.add(label);

// some day add a Ti.Map.createView to this

win.open();

Logs

  403          AndroidRuntime  D  >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
  403          AndroidRuntime  D  CheckJNI is ON
  403          AndroidRuntime  D  --- registering native functions ---
   87           PackageParser  D  Scanning package: /data/app/vmdl28961.tmp
   87          PackageManager  D  Scanning package com.testing.testing9
   87          PackageManager  E  Package com.testing.testing9 requires unavailable shared library com.google.android.maps; failing!
   87          PackageManager  W  Package couldn't be installed in /data/app/com.testing.testing9-1.apk
  403          AndroidRuntime  D  Shutting down VM
  403          AndroidRuntime  I  NOTE: attach of thread 'Binder Thread #3' failed

Comments

  1. Paul Dowsett 2011-12-23

    Shawn - thanks for raising this ticket. Good find! ;) Please note the changes I had to make in order to bring it in line with [JIRA Ticket Checklist](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist) so that I may escalate it to our engineering team. I will move it across now.
  2. Shawn Lipscomb 2012-07-24

    I would like to withdraw this ticket. The fact that "Ti.Map.createView" in a comment triggers the need for the Google APIs is actually useful to me now. I don't see that I can resolve or delete a ticket that I created, so can someone at Appcelerator kill this ticket for me? Thanks.
  3. Shawn Lipscomb 2013-08-02

    Chris, please note my comment above about withdrawing/deleting this ticket.
  4. Chris Barber 2013-08-02

    [~bitshftr] I'm not sure why the way things work is useful? The old API usage detector was very naive. iOS and Mobile Web's build scripts use UglifyJS so that we know exactly what Titanium APIs you're using. This will result in smaller apps which is one of the other tickets that I have on my radar. But furthermore, if you're doing an emulator build and I know you're using a MapView, I can make sure that you have the correct Google API for your AVD or create a new AVD. What do you think?
  5. Shawn Lipscomb 2013-08-02

    We have a "library" of JS units that we use in all of our apps. This library lives in a virtual subdirectory under the Resources directory of each app. With the current behavior, I can (somewhat) control what Ti APIs get brought in to any given app by having the Ti.Map.createView only exist within my maps library wrapper, and then only in pieces (tm=Ti.Map; tm.createView), so that Titanium doesn't automatically bring it in. In apps that actually use maps, I have a comment that contains the full Ti.Map.createView, to force the map API to be linked in. Now, I understand this is a kludge. If you can give us build configurations with an "exclude these JS files from this build configuration" feature, then I wouldn't need this kludge. There's another JIRA ticket for that somewhere.
  6. Chris Barber 2013-08-02

    [~bitshftr] Working on it. :) Just for reference: TIMOB-12025 CLI: Support build profiles to allow multiple build outputs TIMOB-11120 Android: Expose a way for users to exclude js files from being encrypted. TIMOB-3797 Tooling: Ignore files listed in tiapp.xml TIMOB-2478 Tooling: Allow Excluding JS files from Compilation
  7. Shawn Lipscomb 2013-08-02

    Chris, good stuff...all of them.
  8. Allen Yeung 2013-10-19

    PR: https://github.com/appcelerator/titanium_mobile/pull/4781
  9. Paras Mishra 2013-11-12

    Android build process runs fine when "Ti.Map.createView" occurs in comments. No error occurs. Verified fixed on: Appcelerator Studio, build: 3.2.0.201311112306 SDK:3.2.0.v20131111174605 alloy: 1.3.0 CLI : 3.2.0 Xcode:5.0.1 Device: Google nexus 7(v4.3) OS: Mac OSX 10.9

JSON Source