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
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.
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.
Chris, please note my comment above about withdrawing/deleting this ticket.
[~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?
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.
[~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
Chris, good stuff...all of them.
PR: https://github.com/appcelerator/titanium_mobile/pull/4781
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