Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16093] Android: Failed to encrypt JavaScript files (OS X)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusReopened
ResolutionUnresolved
Affected Version/sn/a
Fix Version/s2014 Sprint 01, 2014 Sprint 01 Core, Release 3.3.0
ComponentsAndroid
Labelscb-tooling
ReporterKeylo E.
AssigneeChris Barber
Created2013-12-23T22:41:31.000+0000
Updated2016-08-19T04:28:52.000+0000

Description

Attachments

FileDateSize
.log2013-12-23T22:41:32.000+00000
diagnostic8251845148288191520.log2013-12-23T22:41:35.000+000015329
problemfile.js2014-01-16T02:45:24.000+0000141895

Comments

  1. Ritu Agrawal 2013-12-23

    Thanks for reporting this issue. Engineering is actively looking into this. please watch TIMOB-16073 for more updates.
  2. Ingo Muschenetz 2013-12-24

    To confirm, this is for OS X + Android, yes? All other reports have been on Windows so far.
  3. Ingo Muschenetz 2013-12-24

    Note to developers: Host OS: Mac OS X OS Version: 10.9 OS Arch: x86 JRE Version: 1.6.0_65 JRE Vendor: Apple Inc. JRE Home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
  4. Ingo Muschenetz 2013-12-24

    [~keylo] Can you please try an experiment? Can you try building your project, but remove 50% of the ui/common/* files? We have an issue with the amount of data the encryption process will encrypt at once. This _should_ not have changed between 3.1.3 and 3.2.0, but just to eliminate the issue, I'd like to try this out. Another way to test is just to build a brand new Android project, and see if it fails there.
  5. Keylo E. 2013-12-24

  6. Ritu Agrawal 2013-12-25

    [~keylo] Would it be possible for you to attach a complete project that reproduces this issue? You can either attach it to this ticket or send me by direct email at ragrawal@appcelerator.com? We have been trying to reproduce this issue with no success so far.
  7. Keylo E. 2013-12-25

    Cannot. Client privacy forbids. Stab in the dark but could you take a look at the tiapp.xml since error contains "build-manifest.json does not exist" and adjusting it fixed for iOS. from
           <android xmlns:android="http://schemas.android.com/apk/res/android">
               <manifest>
                   <uses-sdk android:maxSdkVersion="19"
                       android:minSdkVersion="10" android:targetSdkVersion="10"/>
                   <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
                   <application android:debuggable="false"
                       android:icon="@drawable/appicon" android:label="Sets" android:name="SetsApplication">
                       <!-- TI_APPLICATION -->
                       <activity android:configChanges="keyboardHidden"
                           android:label="Sets" android:name=".SetsActivity" android:theme="@style/Theme.Titanium">
                           <intent-filter>
                               <action android:name="android.intent.action.MAIN"/>
                               <category android:name="android.intent.category.LAUNCHER"/>
                           </intent-filter>
                       </activity>
                       <activity android:configChanges="keyboardHidden"
                           android:launchMode="singleTask"
                           android:name="ti.modules.titanium.media.TiVideoActivity"
                           android:screenOrientation="fullSensor" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
                       <activity android:configChanges="keyboardHidden"
                           android:name="org.appcelerator.titanium.TiActivity" android:screenOrientation="portrait"/>
                       <activity android:configChanges="keyboardHidden"
                           android:name="org.appcelerator.titanium.TiTranslucentActivity"
                           android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent"/>
                       <activity
                           android:name="ti.modules.titanium.ui.android.TiPreferencesActivity" android:screenOrientation="portrait"/>
                       <service android:exported="false" android:name="org.appcelerator.titanium.analytics.TiAnalyticsService"/>
                   </application>
               </manifest>
               <services>
                   <service type="interval" url="Myservice.js"/>
               </services>
           </android>
           <mobileweb>
               <precache/>
               <splash>
                   <enabled>true</enabled>
                   <inline-css-images>true</inline-css-images>
               </splash>
               <theme>default</theme>
           </mobileweb>
           <modules>
               <module platform="commonjs">ti.cloud</module>
               <module platform="iphone">facebook</module>
               <module platform="android">facebook</module>
           </modules>
           <deployment-targets>
               <target device="android">true</target>
               <target device="blackberry">false</target>
               <target device="ipad">true</target>
               <target device="iphone">true</target>
               <target device="mobileweb">true</target>
               <target device="tizen">false</target>
           </deployment-targets>
           <sdk-version>3.1.3.GA</sdk-version>
       </ti:app>
       
  8. Keylo E. 2013-12-25

    classic, not alloy
  9. Keylo E. 2013-12-25

    .. and 3.2.0.GA
  10. Ingo Muschenetz 2013-12-27

    Keylo, could you clarify "adjusting it [build-manifest.json] fixed for iOS"? My current hunch is this is a duplicate of TIMOB-16077, but we really need some project to duplicate the issue. We know there is a problem with the amount of JavaScript, but we expected the limits to be identical to 3.1.3.
  11. Keylo E. 2013-12-27

    Referring to my original report. After update, iOS suggested removing the android:largeHeap ='true' from tiapp.xml, which worked for latest build, then moved on to Android and..
  12. Ingo Muschenetz 2013-12-30

    Keylo, We have been unable to reproduce this issue., and yours so far is the only report. Can you please provide some project that reproduces the issue for you?
  13. Ingo Muschenetz 2014-01-02

    Deferring to 3.2.2 until we get more information.
  14. Keylo E. 2014-01-12

    got around to stripping the project down. Found that the culprit was this export: The prob object had 1000 lines, each with a string, some fairly long. Works for iOS, not android. in ProblemFile.js.. function ProblemFile() { var prob = { "title 1" : "Name, Name, Name, Name, Name, Name, Name, Name, Name", ... "title 1000" : "Name, Name, Name, Name, Name, Name, Name, Name, Name, Name, Name, Name, Name" }; return data; } module.exports = ProblemFile;
  15. Chris Barber 2014-01-16

    I tried to reproduce this by replicating the ProblemFile.js, but it built successfully for Android device on Mac OS X 10.8.5 (Mountain Lion). I don't have Mavericks to test with at this moment. I doubled the amount of lines from 1000 to 2000 and it still worked. I then copied the file 10 times and it still worked. I copied the file 100 times and it still worked. I tried 200 copies, but titanium_prep ran out of memory and caused a completely different error. In any case, I'm resolving as cannot reproduce. I have attached my version of the ProblemFile.js for anyone who's bored.
  16. Leonardo Amigoni 2014-02-02

    I am having the same issue on OSX 10.9.1. Has there been any resolution? Let me know if you need the project.
  17. Ingo Muschenetz 2014-02-03

    Leonardo, yes, please attach your project.
  18. Jeff Bzdawka 2014-02-04

    Chris, we are having this exact same issue. Our build process combines all of our JS into a single app.js. This app.js ends up being 43k lines and 1.2MB of code - we do this because we've found the app is significantly quicker to launch if we can skip include calls. I noticed via browsing various github repos that the build process was recently rewritten for android. We are on Mavericks, trying to use TiSDK 3.2.0GA.
  19. Ingo Muschenetz 2014-02-04

    [~jbzdawka] To confirm, it used to work for you in 3.1.3 and no longer works in 3.2.0? Any way you can attach (or email us privately) your application code as a test file?
  20. Jeff Bzdawka 2014-02-04

    Correct, 3.1.3 is fine and 3.2.0 throws the encryption error. I am unable to share the code - even privately. We do have a custom manifest file - but I am not sure if that could cause this problem. I've also tried on multiple computers (all Mavericks) and the problem is present on all.
  21. Dan Tamas 2014-08-18

    [~cbarber] here is a way to replicate the issue. (just having it now :( ) Go to http://www.json-generator.com/, set the repeat to something like 9999 (though 500 will do it)
        'repeat(9999)',
        
    generate, copy to clipboard and put in a single js file in Resources. Then try to compile with
        ti build -p android -T device -C YOUR_DEVICE --skip-js-minify
        
  22. Chris Barber 2014-08-18

    Reopening because titanium_prep needs to be fixed to handle large JavaScript files.
  23. Raymond Verbruggen 2014-09-10

    What is the fix to come around this? THIS IS URGENT!! Made a big update for iOS and now I cannot continue for Android. No problem on iOS, big troubles on Android. This is again a discrepancy between the two major platforms Appcelerator derives its existance from.
  24. Chris Barber 2014-09-10

    [~ray@raymondverbruggen.nl] I assume it's breaking during the call to titanium_prep and resulting in the "Failed to encrypt JavaScript files" message, correct? What operating system are you on? Is it possible to try building your app on a different operating system? Does your app have a lot of JavaScript code? Do you know how many JS files? How big are they?
  25. Raymond Verbruggen 2014-09-10

    OSX Mavericks is my operating system, it is not possible to build for another OS. I have chosen Appcelerator because of the multi-platform, Android and iOS and so OSX. "app.js" "alloy/backbone.js" "alloy/constants.js" "alloy/controllers/BaseController.js" "alloy/controllers/facebook.js" "alloy/controllers/help.js" "alloy/controllers/home.js" "alloy/controllers/index.js" "alloy/controllers/mainview.js" "alloy/controllers/mapView.js" "alloy/controllers/menuview.js" "alloy/controllers/settings.js" "alloy/controllers/twitter.js" "alloy/models/Partners.js" "alloy/styles/facebook.js" "alloy/styles/help.js" "alloy/styles/home.js" "alloy/styles/index.js" "alloy/styles/mainview.js" "alloy/styles/mapView.js" "alloy/styles/menuview.js" "alloy/styles/settings.js" "alloy/styles/twitter.js" "alloy/sync/localStorage.js" "alloy/sync/properties.js" "alloy/sync/sql.js" "alloy/underscore.js" "alloy/widget.js" "alloy/widgets/com.imagitechdj.slideMenu/controllers/widget.js" "alloy/widgets/com.imagitechdj.slideMenu/styles/widget.js" "alloy.js" "lib/httpClient.js" "lib/shadow.js" "lib/utils.js" "openlayers/OpenLayers.js" "openlayers/mobile.js" "openlayers/proj4.js" "slideMenu/slideMenu.js" "_app_props_.json" The largest is Openlayers.js, 770kb
  26. Chris Barber 2014-09-10

    [~ray@raymondverbruggen.nl] OK, so you don't have that many files. Titanium_prep is sensitive to the total size of all JS files combined. Perhaps the files combined are large? Another thing you can try is right after it fails, locate the text in the output "Encrypting JavaScript files:" and copy everything afterwards and run titanium_prep manually. What does it output? Does it display any errors? What is the exit code? (echo $?)
  27. Juan Pablo Romero 2014-09-15

    I had the same issue and it was solved exporting this environment variable: export JAVA_TOOL_OPTIONS="-XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -XX:MaxPermSize=256m" The main problem is related with use of memory
  28. Chris Barber 2014-09-15

    [~juanblo] Brilliant! Thanks for this tip. I'll test it and if it solves the problem, I'll add it to Android's build so that you don't have to worry about it.
  29. Jeff Bzdawka 2014-09-16

    Unfortunately, the export JAVA_TOOL_OPTIONS did not work for me. I get a file is too big error regardless of the max memory setting for java, etc. The command I run is: ~/Library/Application\ Support/Titanium/mobilesdk/osx/3.3.0.GA/android/titanium_prep.macos "com.movatohealth.phoenix" "/Users/Jeff/Desktop/Projects/TiWorkspace/Phoenix/build/android/assets" "app.js" The output is: Picked up JAVA_TOOL_OPTIONS: -XX:+HeapDumpOnOutOfMemoryError -Xmx2048m -Xms2048m -XX:MaxPermSize=1024m File is too big. You can see I was increasing the numbers as I fiddled with it to try to get it to work. That app.js is 839kb, we have a build process that creates a single app.js from ~400 javascript files via a plugin and pre compile hook. Through trial and error I think I stumbled on a max file size of 500kb for a single file for titanium_prep.macos for android. We're working on a build script that tries to stay under 500kb per file and splits it in an intelligent spot so that we stay under that cap that is currently a theory on our part - will report back on if staying under that theorized cap works for us.
  30. Jeff Bzdawka 2014-09-17

    Aiming for around 512kb in breaking down our files worked. This is purely anecdotal, but the sum of files can be far in excess of 512kb but for us an individual file could not be greater than 512kb otherwise we got a "file is too big" error.
  31. Chris Barber 2014-09-17

    [~jbzdawka] I don't have a magic workaround right this minute. titanium_prep takes a bunch of input .js files and encrypts them and that output is injected into the a .java file. I have managed to generate a 20MB .java file that fails to compile because 256MB of memory is not enough. I did make it so you can override the javac max memory (ti config android.javac.maxmemory 1G). But you are hung up on titanium_prep and unfortunately I don't know a way of boosting the number of files or size of files that are to be encrypted. If I was able to generate a 20MB .java file, I can guarantee you that I had way more than 512KB of .js files. When I tested it, I think I was testing using a TON of jquery.js files.
  32. Raymond Verbruggen 2014-09-23

    Dear Appcelerator developers! Any news on this issue?? This is really a big problem!
  33. Ben 2014-10-03

    After wrestling with this issue all week I was able to work around it by creating a link to the library as described here: http://stackoverflow.com/a/23696459/2272365 In Terminal.app:
        cd /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/
        sudo mkdir bundle
        cd bundle
        sudo mkdir Libraries
        cd Libraries
        sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre/lib/server/libjvm.dylib libserver.dylib
        
    You'll have to change the jdk1.x.x_xx.jdk directory to match whatever you have installed. Another option is to modify the Titanium SDK "_build.js" file and set encryptJS to false (around line 934). I wouldn't recommend that method for anything important though. This file should be located somewhere like "/Users/ben/Library/Application Support/Titanium/mobilesdk/osx/3.4.0.GA/android/cli/commands/_build.js"
  34. Raymond Verbruggen 2014-10-20

    Any progress on this one???? When is a solution provided?
  35. Raymond Verbruggen 2014-10-24

    Does anybody have a workaround for this? This one is putting my project on a hold!
  36. Joseph Sachs 2015-03-13

    thanks [~ben0] I've modified /Library/Application Support/Titanium/mobilesdk/osx/3.4.0.GA/android/cli/commands/_build.js (just the test environment) will deal with it when I go to production.
  37. Dan Wilson 2015-08-03

    This bug is now exacerbated by El Capitan's lack of Java 6 support. The workaround from Ben fixed it for me, but it's still a problem in SDK 4.0.0.GA and 4.1.0.GA.
  38. Steve Rogers 2015-09-11

    Is it possible to have selective encryption? For example in a project select which js file get encrypted or even just have a master file that gets encrypted ( alloy.js ) so that data in there is 'secure' - I use the term loosely. Even prefix or suffix files that need to be included in the encryption process enc_xxx.js or xxx_enc.js or xxxx.enjs

JSON Source