Problem description
In the Dynamic Styling Alloy sample
https://github.com/appcelerator/alloy/tree/master/test/apps/advanced/dynamic_styling , in the 'rawStyle' window, there is a webView whose html content is rendered using the Underscore.js '_.template' utility:
$.styleArray.html = _.template(Alloy.Globals.htmlTemplate, {
CODE: JSON.stringify(require('alloy/styles/features/rawStyle'), null, ' '),
BRUSH: 'js'
});
Alloy.Globals.htmlTemplate (in app/alloy.js):
Alloy.Globals.htmlTemplate = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><script type="text/javascript" src="web/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="web/syntaxhighlighter/scripts/shBrushJScript.js"></script><link type="text/css" rel="stylesheet" href="web/syntaxhighlighter/styles/shCoreDefault.css"/><script type="text/javascript">SyntaxHighlighter.all();</script></head><body style="background: white; font-family: Helvetica; "><pre class="brush: <%= BRUSH %>; gutter: false;"><%= CODE %></pre></html>';
If no targetSdkVersion is specified or if a targetSdkVersion specified is greater than 13, running the sample on Android using the latest SDK (3.2.3.v20140403105720), the Webview is not visible.
Is correctly visible using 3.2.2.GA on both iOS and Android.
Steps to reproduce
1. Create a new Alloy project and import the Alloy sample code
https://github.com/appcelerator/alloy/tree/master/test/apps/advanced/dynamic_styling (or get the attached project)
2. Run on Android and click on 'Raw Style Modules'
Result: second webView (
) is not visible.
3. Edit tiapp.xml, add the following and run on Android:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<uses-sdk android:targetSdkVersion="11"/>
</manifest>
</android>
Result: the webView is now correctly displayed
4. Edit tiapp.xml, add the following and run on Android:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<uses-sdk android:targetSdkVersion="19"/>
</manifest>
</android>
Result: Webview is no longer displayed.
5. Edit tiapp.xml, switch to SDK 3.2.2.GA, use any targetSdkVersion (from 11 to 19) and run on device:
Result: webview is always correctly displayed. It seems to be a regression on the SDK (also no changes made on Alloy).
Attached screenshots for comparison between a displayed and not-displayed webview.
Note
If using Jake to import the Alloy sample project, it works fine as in this case an Harness template with targetSdkVersion='11' is being used.
If using the default new app tiapp.xml file (with no targetSdkVersion being specified in the manifest), the sample webview is not visible.
I don't believe this to be an Alloy bug. It is related to the Android SDK version used to build the app. Anything newer than API version 13 exhibits the problem; older Android API levels don't have this issue. My test: 1. Create a new project with the CLI 2. Edit tiapp.xml to set Ti SDK to 3.2.3.Alpha 3. Build via command line to Genymotion emulator (Galaxy Nexus, Android 4.2.2). App exhibits the behavior as described (second webview isn't visible) 4. Modify tiapp.xml, adding the code below. Rinse and repeat using targetSdkVersions from 11 (which is what is set by the Harness Template) through 19. Android SDK versions 11, 12, and 13 -- the app works properly. Any SDK version higher than 13 exhibits the behavior described in the ticket. 5. Modify tiapp.xml setting TiSDK to 3.2.2.GA and targetSdkVersion to 19. The app runs properly.
master PR: https://github.com/appcelerator/titanium_mobile/pull/5592 3.2.x PR: https://github.com/appcelerator/titanium_mobile/pull/5593
Verified as fixed. TiSDK 3.2.3.v20140411160129 Alloy 1.3.1 Appcelerator Studio 3.2.3.201404111117 Mac OS X and Windows 7 x64 Google Nexus Galaxy 4.3 Closing.
Closing ticket as per Federico's comment.