[TIMOB-13696] Android: duplicate entry in signed APK for libstlport_shared.so
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-10-19T01:23:13.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2013 Sprint 21, 2013 Sprint 21 Core, Release 3.2.0 |
Components | Android, Tooling |
Labels | androidbuild, cb-verified |
Reporter | Paul Mietz Egli |
Assignee | Chris Barber |
Created | 2013-01-29T18:57:58.000+0000 |
Updated | 2013-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')
Still an issue in 3.1.0.GA.
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!
Here's the end of the build log for
ant run
The change in builder.py is at lines 1705-1706. Currently, the file reads:
If I replace those two lines with the following code, I no longer see the build error:
Please let me know if you need any additional information.
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:
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:
to this:
and changed line 1687 from this:
to this:
This appears to have fixed the problem. My module's example project now runs on both an armeabi and an x86 emulator image.
Yeah, I'm experiencing the same problem. And thanks to Paul for the resolution. I owe you man ;)
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!
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).
PR: https://github.com/appcelerator/titanium_mobile/pull/4781
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