Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2115] Android SDK build errors under win32

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:58:08.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0 M01
ComponentsAndroid
Labelsandroid, build, defect, win32
ReporterRobby
AssigneeMarshall Culpepper
Created2011-04-15T03:10:49.000+0000
Updated2011-04-17T01:58:08.000+0000

Description

Just a few bugs I've noticed while trying to get 1.5.x's Android SDK modules to work under windows.

#0. exception is generated in a fork() call when trying to create a new module template using titanium.py ...you have to call module.py with the args directly instead

#1. you have a bug with manifest.py (line 18) under windows...you're splitting on ":"...breaks on android.sdk, as under windows mine is C:\progra~1\android-sdk Obvious fix: change to:

key,value = line.split(':', 1)

#2. for some reason I have my module being added to self.module_jars in builder.py twice (looks like detector.find_app_modules() is finding it twice... same exact path, just in the list twice, which causes the build command to fail). I monkeyhacked this to just get around it by doing:

        for module in modules:
            if module.path not in self.module_jars:
                self.module_jars.append(module.path)
            classpath = os.pathsep.join([classpath, module.path])

#3. After this, using require() still fails for me (I'm missing something obvious I bet). However, using Ti.moduleName works. So, I'll go with that for now! :)

#4. my module requires some 3rd party libs (jars), such as google-api-client-1.1.1-alpha.jar. Placing them in /lib allows them to be resolved at compile time and my module to build successfully. However, I get a NoClassDefFoundError at runtime when anything from any of the modules are hit in the code. I've tried placing the jars in my app's build/android/lib and in /android to no avail.

Comments

  1. Don Thorp 2011-04-15

    Robby. When entering tags, make sure to use commas between them. I've corrected the tags.

  2. Robby 2011-04-15

    Sorry about that Don. I've updated the ticket with one more potential bug I ran into on advice from Marshall.

  3. Don Thorp 2011-04-15

    Robby, no worries. But if I don't mention it, it never changes :)

  4. Marshall Culpepper 2011-04-15

    (from [49f154a370ef55ba293d2d8d547eb5c79fe57626]) a new batch script frontend for titanium.py in windows, make sure to pass on the sys.executable when calling other python scripts, and only split manifest entries on the first colon [#2115] http://github.com/appcelerator/titanium_mobile/commit/49f154a370ef55ba293d2d8d547eb5c79fe57626"> http://github.com/appcelerator/titanium_mobile/commit/49f154a370ef5...

  5. Marshall Culpepper 2011-04-15

    (from [19571872de8164acdcb364fb4dbba0b53f110682]) more win32 fixes: use new manifest module in titanium.py, call python from the module builder, use titanium.bat in the project build.xml, and ant.bat from the module builder. give an error if the platform/google apis aren't found [#2115] http://github.com/appcelerator/titanium_mobile/commit/19571872de8164acdcb364fb4dbba0b53f110682"> http://github.com/appcelerator/titanium_mobile/commit/19571872de816...

  6. Marshall Culpepper 2011-04-15

    (from [05fcb7c95be28861649eea68c9eb674bd542a4c1]) yet more win32 fixes: chop off the file:\ prefix in the annotation generator so binding JSON data gets reloaded on subsequent annotation rounds. any jar files in lib are now expanded into the top level module jar in the dist target so they are always distributed with the module jar. changed ant script to use build/classes for building to not conflict with JDT's bin folder, and made sure the run and run.emulator targets depend on the dist target [#2115] http://github.com/appcelerator/titanium_mobile/commit/05fcb7c95be28861649eea68c9eb674bd542a4c1"> http://github.com/appcelerator/titanium_mobile/commit/05fcb7c95be28...

  7. Marshall Culpepper 2011-04-15

    OK, at this point #0, #1, and #4 look to be solved from my testing in XP. Some follow up questions:

    #2: Did you accidentally copy your module into the system folder as well as the application folder? If so the detector will pick it up twice. Would you mind posting the full trace log so I can try to reproduce the error?

    #3: require() works like a charm for me in both XP and OSX.. Some things to check: - Is the ID in require() the same as the ID in your @Kroll.module declaration? - Did the 3rd party JAR error from #4 cause your module class to fail loading?

    Have you tried taking a look at the "example" folder that gets generated? You can run that app.js by calling ant run.emulator / ant run to test it out.

  8. Don Thorp 2011-04-15

    Marshall,

    Not strictly related to this ticket but looks like there is a scons problem too. See http://developer.appcelerator.com/helpdesk/view/50451">Helpdesk 50451

  9. Robby 2011-04-15

    Hey Marshall,

    This is great. Regarding #2...I did check for extra copies of my jar...there don't seem to be any. The build trace is at http://pastebin.com/U5qB0jhp">http://pastebin.com/U5qB0jhp . You'll notice at line 564, it's finding the jar in the same place twice (with the same name). This is unmodified from I think the 10/19 build, grabbed after you made the comitt that fixed 0, 1, and 4.

    I'll try this (and using require()) in the newest build, as I see you've made even more android module changes.

  10. Marshall Culpepper 2011-04-15

    Cool thanks for the info. You'll probably want to recreate your project after updating, I've made a number of build and distribution changes that are incompatible with projects from a few days ago, FYI

  11. Robby 2011-04-15

    Marshall,

    Recreated the project as you said. That all goes well. With the new build.xml, there is one minor regression upon building:

    My {build} path has a space in it (sits in My Documents), which ant doesn't seem to like:

        O:\robbyd\My Documents\workspace\sportschedules\titaniumlibs\android\CalendarLib>ant
        Buildfile: O:\robbyd\My Documents\workspace\sportschedules\titaniumlibs\android\CalendarLib\build.xml
        
        init:
        
        process.annotations:
            [javac] Compiling 18 source files to O:\robbyd\My Documents\workspace\sportschedules\titaniumlibs\android\CalendarLib\build\classes
            [javac] javac: invalid flag: Documents\workspace\sportschedules\titaniumlibs\android\CalendarLib\build\.apt_generated
            [javac] Usage: javac <options> <source files>
            [javac] use -help for a list of possible options
        
        BUILD FAILED
        C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\module\android\build.xml:43: Compile failed; see the compiler error output for details.
        
        Total time: 0 seconds
        

    As a temp workaround (and because I know very little about how ant works), I placed the following in my build.properties:

        build=O:\robbyd\mydocu~1\workspace\sportschedules\titaniumlibs\android\CalendarLib\build
        

    Which fixes the problem.

  12. Robby 2011-04-15

    Another bug:

    from one of the 20101025 daily builds, in module\module.py, around line 184:

                for platform in os.listdir(modules_dir):

                platform_dir = os.path.join(modules_dir, platform)
                if not os.path.isdir(platform_dir): continue
                if platform_dir in ['osx', 'win32', 'linux']: continue # skip desktop modules
        
                # recursive once in the platform directory so we can get versioned modules too</code>
        
        
        
        

    "if platform_dir in ['osx', 'win32', 'linux']:" should be "if platform in ['osx', 'win32', 'linux']:" instead.

    With the current code, the module searcher is looking into desktop platform module dirs (e.g. 'win32') in my case.

  13. Robby 2011-04-15

    And it still appears that for me at least it's finding modules twice:

        [INFO] Compiling Android Resources... This could take some time
        [DEBUG] C:\Progra~2\Java\jdk1.6.0_21\bin\java.exe -Xmx1024M -Djava.ext.dirs=C:\Progra~1\android-sdk-windows\platforms\android-4\tools -jar C:\Progra~1\android-sdk-windows\platforms\android-4\tools\lib\dx.jar --dex --output=O:\robbyd\My Documents\workspace\sportschedules\Sportschedule\build\android\bin\classes.dex O:\robbyd\My Documents\workspace\sportschedules\Sportschedule\build\android\bin\classes C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-analytics.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-android.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\titanium.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\commons-codec-1.3.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\js.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\jaxen-1.1.1.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-ui.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-app.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-api.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-filesystem.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-media.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-json.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-locale.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-platform.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-network.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-xml.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.0-20101024\android\modules\titanium-utils.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\calendarlib.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\lib\google-api-client-1.1.1-alpha.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\lib\jackson-core-asl-1.5.3.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\calendarlib.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\lib\google-api-client-1.1.1-alpha.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\lib\jackson-core-asl-1.5.3.jar
        

    (see the end of that string...my custom modules it finds twice, at the same exact directories.) Looking there everything looks fine at least to me...the files are only there once.

  14. Marshall Culpepper 2011-04-15

    (from [27039690045edf352854e05b2dd06beb03551185]) use compilerarg "value" so the .apt_generated path gets properly escaped, check platform instead of platform_dir when looking at module directories [#2115] http://github.com/appcelerator/titanium_mobile/commit/27039690045edf352854e05b2dd06beb03551185"> http://github.com/appcelerator/titanium_mobile/commit/27039690045ed...

  15. Marshall Culpepper 2011-04-15

    Robby, would you be able to spend some time with me on IRC today to see if we can make sure all these are fixed?

  16. Matt Schmulen 2011-04-15

    Thanks Opie! verified Windows

  17. Robby 2011-04-15

    This is broken again in 1.5.1 final: The build process with a custom module fails for me because it is finding the modules twice.

        [INFO] Compiling Android Resources... This could take some time
        [DEBUG] C:\Progra~2\Java\jdk1.6.0_21\bin\java.exe -Xmx1024M -Djava.ext.dirs=C:\Progra~1\android-sdk-windows\platforms\android-4\tools -jar C:\Progra~1\android-sdk-windows\platforms\android-4\tools\lib\dx.jar --dex "--output=O:\robbyd\My Documents\workspace\sportschedules\Sportschedule\build\android\bin\classes.dex" "O:\robbyd\My Documents\workspace\sportschedules\Sportschedule\build\android\bin\classes" C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\ti-commons-codec-1.3.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-app.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-json.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-android.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-api.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-utils.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-xml.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-platform.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-media.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-filesystem.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\jaxen-1.1.1.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\smalljs.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-ui.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-locale.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\titanium.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-network.jar C:\ProgramData\Titanium\mobilesdk\win32\1.5.1\android\modules\titanium-analytics.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\calendarlib.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\lib\google-api-client-1.2.0-alpha.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\lib\jackson-core-asl-1.5.7.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\calendarlib.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\lib\google-api-client-1.2.0-alpha.jar C:\ProgramData\Titanium\modules\android\com.slamstreet.sportschedule.android.calendarlib\0.1\lib\jackson-core-asl-1.5.7.jar
        

    (You'll notice that the calendarlib.jar, google-api-client and jackson-core jars are included twice...from the same exact dir.)

    This causes build errors like:

        [ERROR] UNEXPECTED TOP-LEVEL EXCEPTION:
        [ERROR] java.lang.IllegalArgumentException: already added: Lcom/slamstreet/sportschedule/android/calendarlib/CalendarlibModule;
        [ERROR] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
        [ERROR] at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
        

    Fixed it by monkeypatching android/builder.py:

                for module in self.modules:

                if module.jar == None: continue
                ##PATCH1
                if module.jar not in self.module_jars:
                    self.module_jars.append(module.jar)
                ##  
                classpath = os.pathsep.join([classpath, module.jar])
                module_lib = module.get_resource('lib')
                for jar in glob.glob(os.path.join(module_lib, '*.jar')):
                    ##PATCH2
                    if jar not in self.module_jars:
                        self.module_jars.append(jar)
                    ##    
                    classpath = os.pathsep.join([classpath, jar])</code>
        
        
        
        
  18. Don Thorp 2011-04-15

    @Robby would you mind opening a different ticket for this new problem? Assign it to me and I'll get it scheduled in. Also if you'd like to contribute an actual patch we just need you to sign the CLA.

JSON Source