Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13696] Android: duplicate entry in signed APK for libstlport_shared.so

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-10-19T01:23:13.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 21, 2013 Sprint 21 Core, Release 3.2.0
ComponentsAndroid, Tooling
Labelsandroidbuild, cb-verified
ReporterPaul Mietz Egli
AssigneeChris Barber
Created2013-01-29T18:57:58.000+0000
Updated2013-11-19T01:18:12.000+0000

Description

*Problem description* When building a module example app with the above environment, I see that libstlport_shared.so is copied to my libs/\[armeabi|armeabi-v7a|x86\] directory. The android/builder.py script adds another copy of this library to the unsigned APK file (see line 1638-1640) which causes the jarsigner step to fail with the following error:
[exec] [DEBUG] installing native lib: /var/folders/3s/15_hswz52w1b42_wmj_f57c40000gq/T/mvmPeWYti/titouchdb/modules/android/com.obscure.titouchdb/0.5/libs/x86/libstlport_shared.so
[exec] [DEBUG] installing native SDK libs
[exec] [DEBUG] keytool -v -list -keystore "/Users/paul/Library/Application Support/Titanium/mobilesdk/osx/3.1.0.GA/android/dev_keystore" -storepass ******* -alias tidev
[exec] [DEBUG] jarsigner -sigalg MD5withRSA -digestalg SHA1 -storepass ******* -keystore "/Users/paul/Library/Application Support/Titanium/mobilesdk/osx/3.1.0.GA/android/dev_keystore" -signedjar /var/folders/3s/15_hswz52w1b42_wmj_f57c40000gq/T/mvmPeWYti/titouchdb/build/android/bin/app.apk /var/folders/3s/15_hswz52w1b42_wmj_f57c40000gq/T/mvmPeWYti/titouchdb/build/android/bin/app-unsigned.apk tidev
[exec] [ERROR] unable to sign jar: java.util.zip.ZipException: duplicate entry: lib/armeabi/libstlport_shared.so
[exec] [ERROR] Build Failed.
*Workaround* Change android/builder.py so it doesn't add libstlport_shared.so to the APK. Currently, at lines 1705-1706, the file reads:
for fname in ('libkroll-v8.so', 'libstlport_shared.so'):
    apk_zip.write(os.path.join(lib_source_dir, fname), lib_dest_dir + fname)
If I replace those two lines with the following code, I no longer see the build error:
apk_zip.write(os.path.join(lib_source_dir, 'libkroll-v8.so'), lib_dest_dir + 'libkroll-v8.so')

Comments

  1. Paul Mietz Egli 2013-04-26

    Still an issue in 3.1.0.GA.
  2. Daniel Sefton 2013-04-26

    Hi Paul, It would help our engineering team to resolve the issue faster if you could provide the error message of "causes the jarsigner step to fail", and also a "before and after" code extract from builder.py. Thanks!
  3. Paul Mietz Egli 2013-04-26

    Here's the end of the build log for ant run
       
            [exec] [DEBUG] installing native lib: /var/folders/3s/15_hswz52w1b42_wmj_f57c40000gq/T/mvmPeWYti/titouchdb/modules/android/com.obscure.titouchdb/0.5/libs/x86/libstlport_shared.so
            [exec] [DEBUG] installing native SDK libs
            [exec] [DEBUG] keytool -v -list -keystore "/Users/paul/Library/Application Support/Titanium/mobilesdk/osx/3.1.0.GA/android/dev_keystore" -storepass ******* -alias tidev
            [exec] [DEBUG] jarsigner -sigalg MD5withRSA -digestalg SHA1 -storepass ******* -keystore "/Users/paul/Library/Application Support/Titanium/mobilesdk/osx/3.1.0.GA/android/dev_keystore" -signedjar /var/folders/3s/15_hswz52w1b42_wmj_f57c40000gq/T/mvmPeWYti/titouchdb/build/android/bin/app.apk /var/folders/3s/15_hswz52w1b42_wmj_f57c40000gq/T/mvmPeWYti/titouchdb/build/android/bin/app-unsigned.apk tidev
            [exec] [ERROR] unable to sign jar: java.util.zip.ZipException: duplicate entry: lib/armeabi/libstlport_shared.so
            [exec] [ERROR] Build Failed.
       
    The change in builder.py is at lines 1705-1706. Currently, the file reads:
       for fname in ('libkroll-v8.so', 'libstlport_shared.so'):
           apk_zip.write(os.path.join(lib_source_dir, fname), lib_dest_dir + fname)
       
    If I replace those two lines with the following code, I no longer see the build error:
       apk_zip.write(os.path.join(lib_source_dir, 'libkroll-v8.so'), lib_dest_dir + 'libkroll-v8.so')
       
    Please let me know if you need any additional information.
  4. Paul Mietz Egli 2013-05-01

    I've gotten a little farther along on this bug. My module contains a C++ native library. During the build process, the NDK is copying a version of libstlport_shared.so from the NDK directory into my libs/{ARCH} folder, which is then being included in the APK zip by builder.py line 1684 and/or 1687. When I modified builder.py as shown above, I no longer got the build error due to multiple copies of the libstlport_shared.so file in the APK, but I saw linker errors when deploying to the emulator:
       I/dalvikvm(  291): Unable to dlopen(/data/data/com.obscure.titouchdb/lib/libkroll-v8.so): Cannot load library: 
       link_image[1995]: failed to link libkroll-v8.so
       
    This made me suspect that the problem is an incompatibility between libkroll-v8 and the version of libstlport_shared that came from the NDK. I changed line 1682-84 from this:
       for module in self.modules:
       	exclude_libs = []
       	add_native_libs(module.get_resource('libs'), exclude_libs)
       
    to this:
       for module in self.modules:
       	exclude_libs = ['libstlport_shared.so']
       	add_native_libs(module.get_resource('libs'), exclude_libs)
       
    and changed line 1687 from this:
       add_native_libs(os.path.join(self.project_dir, 'libs'))
       
    to this:
       add_native_libs(os.path.join(self.project_dir, 'libs'), ['libstlport_shared.so'])
       
    This appears to have fixed the problem. My module's example project now runs on both an armeabi and an x86 emulator image.
  5. Martino Harjono 2013-05-26

    Yeah, I'm experiencing the same problem. And thanks to Paul for the resolution. I owe you man ;)
  6. Chris Barber 2013-07-18

    We are trying to reproduce this issue. Could someone please create a test project that demonstrates the issue including any native modules needed? Thank you!
  7. Charlie Brensinger 2013-07-20

    I'm running into this issue with a fresh project. I've uploaded a zip of the project here: http://db.tt/7HngLsJu and the only modules I'm loading in are titouchdb (https://pegli.github.s3.amazonaws.com/com.obscure.titouchdb-android-0.9.zip and https://pegli.github.s3.amazonaws.com/com.obscure.titouchdb-iphone-0.9.zip). I've loaded those directly into Titanium and included them (should be reflected in tiapp.xml).
  8. Allen Yeung 2013-10-19

    PR: https://github.com/appcelerator/titanium_mobile/pull/4781
  9. Lokesh Choudhary 2013-11-19

    Verified the fix with the attached app & modules.The "libstplport_shared.so" file is only copied one time & the packaging is successfull. Closing. Environment: Appcel Studio : 3.2.0.201311161724 Ti SDK : 3.2.0.v20131117001643 Mac OSX : 10.8.5 Alloy : 1.3.0 CLI - 3.2.0-alpha Device: Samsung Galaxy S4 running android 4.2.2

JSON Source