Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23945] Hyperloop does not extract /jni/<abi>/*.so files from an aar

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-09-26T14:22:54.000+0000
Affected Version/sRelease 5.5.0
Fix Version/sRelease 6.0.0, Hyperloop 2.0.0
ComponentsAndroid, Hyperloop, Tooling
Labelsn/a
ReporterBrian Knorr
AssigneeHans Knöchel
Created2016-09-22T21:16:08.000+0000
Updated2016-11-27T19:49:41.000+0000

Description

It's very easy to reproduce. Just add an aar file to your hyperloop enabled Titanium project. Here is the one we are using: https://github.com/card-io/card.io-Android-SDK/tree/master/aars Then build for android. Find the apk and unpack it. You will not see any of the aar's .so files in the lib folder, only the Titanium specific ones. This causes the use of this aar libray to fail with: [ERROR] : E/card.io : Failed to load native library: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.jasonsdeli.mobile-2/base.apk"],nativeLibraryDirectories=[/data/app/com.jasonsdeli.mobile-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libcardioDecider.so"

Comments

  1. Brian Knorr 2016-09-22

    Also the AppC documentation states that extracting *.so files from an aar is supported. But this seems to be wrong, because it doesn't work. Here is the documentation http://docs.appcelerator.com/platform/latest/#!/guide/Android_Hyperloop_Programming_Guide-section-46253495_AndroidHyperloopProgrammingGuide-UsingThird-partylibraries
  2. Hans Knöchel 2016-09-24

    [~cwilliams] I see that we do handle .so files in .aar files, but only if they are in the jni directory, is that correct? I looked at [this](https://github.com/appcelerator/hyperloop.next/blob/master/android/plugins/hyperloop/hooks/android/hyperloop.js#L403) piece of code. *EDIT*: I could happen because the provided .aar has it's .so files in /jni/<api>/*.so, so they are not "flat" inside there.
  3. Brian Knorr 2016-09-24

    The spec for AAR format doesn't allow for *.so to be "flat" inside the jni folder. See http://tools.android.com/tech-docs/new-build-system/aar-format This means that AARs with *.so files are not supported by hyperloop until this is fixed. We need this working for a big client of yours - we are the firm building the Titanium app. Please let us know what the ETA is on this. Thanks, Brian
  4. Hans Knöchel 2016-09-24

    Actually I think the issue is something else. Because we search recursively for the files and copy them over afterwards. So maybe a duplicate file-name (if a file is found in both x86 and x86_64) might cause problems. This is just some troubleshooting for now.
  5. Hans Knöchel 2016-09-24

    *PR*: https://github.com/appcelerator/hyperloop.next/pull/77 *Steps to test:* 1. Create a new Hyperloop-based Titanium project: appc new -p android 2. Download [card.io-5.4.1.aar](https://github.com/card-io/card.io-Android-SDK/raw/master/aars/card.io-5.4.1.aar) and copy it to /app/platform/android 3. In the index.js, copy the following line to access the library:
       var CardIOActivity = require("io.card.payment.CardIOActivity");
       
    *Expected behavior:* The build does not fail, the app does not crash after requiring the class. [~btknorr] You can test the patch even before we release the next version by going to ~/Library/Application Support/Titanium/plugins/hyperloop/<version>/hooks/android/hyperloop.js, and replacing the following line (around 369):
       buildLibs = path.join(cli.argv['project-dir'], 'build', 'libs');
       
    with
       buildLibs = path.join(cli.argv['project-dir'], 'build', 'android', 'libs');
       
    The generated project looks good: !https://abload.de/img/bildschirmfoto2016-09hps6z.png!
  6. Brian Knorr 2016-09-24

    Hans - I made the code modification like you suggested and everything works great now :) Thanks!
  7. Lokesh Choudhary 2016-10-05

    Verified the fix. Hyperloop now successfully extracts /jni/<abi>/*.so files from an aar file. Closing. Environment: Appc Studio : 4.8.0.201609292239 Ti SDK : 6.0.0.v20161005072811 Ti CLI : 5.0.10 Alloy : 1.9.2 MAC El Capitan : 10.11.6 Appc NPM : 4.2.8-7 Appc CLI : 6.0.0-56 Node: 4.4.4 Nexus 5 - Android 6.0.1 Hyperloop plugin & module : 2.0.0

JSON Source