GitHub Issue | n/a |
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-01-17T01:07:22.000+0000 |
Affected Version/s | Release 3.2.0 |
Fix Version/s | 2014 Sprint 01, 2014 Sprint 01 Core, Release 3.2.3, Release 3.3.0 |
Components | CLI |
Labels | alloy, andoid, bug, compile, localization, module_cli, qe-closed-3.2.3, qe-testadded |
Reporter | Eli Mor |
Assignee | Chris Barber |
Created | 2013-12-27T04:15:33.000+0000 |
Updated | 2014-08-01T07:45:41.000+0000 |
When trying to compile a ally android project, the compiler fail with the following error:
[ERROR] : Failed to compile Java source files:
[ERROR] :
[ERROR] : /Users/mor_eli/Development/Titanium_Workspace/android_alloy/build/android/gen/com/android/alloy/R.java:32: ';' expected
[ERROR] : public static final int space test=0x7f040001;
[ERROR] : ^
[ERROR] : /Users/mor_eli/Development/Titanium_Workspace/android_alloy/build/android/gen/com/android/alloy/R.java:32: <identifier> expected
[ERROR] : public static final int space test=0x7f040001;
[ERROR] : ^
[ERROR] : 2 errors
[ERROR] Application Installer abnormal process termination. Process exit value was 1
The issue seemed to be linked to having a localization string file in project root/i18n/en/strings.xml
If the first string line has a space as follows:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="space test">should not work with space/string>
</resources>
The compilation fails.
If the space is removed:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="test">should work no space/string>
</resources>
The compilation works.
Kind of works as I'd expect it to. http://developer.android.com/guide/topics/resources/string-resource.html
Stephen, do you ever sleep? :) Thanks for the link. Clearly it shows that no spaces are allowed. Maybe there's a way to handle it more gracefully, or to match the compilation between iOS and android. The same code ran without a problem on iOS, but when going to run it on android the problem popped up.
Took a look and the problem is originating in the Android platform code. It can't find the resource and returns the default value. I tried replacing the spaces with &\#160; at build time, but that didn't help. I imagine this is a step in the right direction, though the resource loader would have to be looked at and thus I've assigned this to one of the Android devs, namely Ping.
After doing some testing, iOS does support spaces in the name.
This isn't supported in native Android because the string names are being imported directly to R.java as variables, so you can't have a space in the name.
Decided to display an error message with the offending string names. It's not perfect, but such is life. Master pull request: https://github.com/appcelerator/titanium_mobile/pull/5232 3.2.x pull request: https://github.com/appcelerator/titanium_mobile/pull/5233 To test: 1. create an android app 2. create the file i18n/en/strings.xml 3. add a few strings with spaces like this:
4. build the app and witness the awesome error handling 5. set: ti config android.excludeInvalidI18nStrings true 6. build the app again and see that the errors are printed, but the build proceeds
Verified fix using below environment: Appc Studio: 3.2.3.201403250634 SDK build: 3.2.3.v20140325145222 acs: 1.0.14 npm: 1.3.2 alloy:1.3.1 CLI: titanium@3.2.3-dev titanium-code-processor:1.1.0 Xcode: 5.1 Osx: Maverick(10.9.2) Device: Nexus 7 (V 4.4.2) Tested with above steps provided in the comments and after setting ti config android.excludeInvalidI18nStrings true, errors are printed but the build proceeds as expected. Hence closing the issue.