{ "id": "93536", "key": "AC-3086", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2012-07-17T09:07:35.000+0000", "created": "2012-06-20T08:44:21.000+0000", "labels": [ "android", "jni", "module", "ndk" ], "versions": [], "issuelinks": [ { "id": "34046", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "94505", "key": "AC-2803", "fields": { "summary": "Android module with JNI won't build", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "updated": "2016-03-08T07:48:08.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14550", "name": "Appcelerator Modules", "description": "Please enter tickets related to Modules here." }, { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "How to reproduce:\r\n\r\n- Create a Titanium Module Project in Titanium Studio:\r\n* project name: headphones\r\n* module id: be.tulipemoutarde.headphones\r\n* deployment target: 'Android' / SDK: 2.0.2GA\r\n\r\n- Edit the build.properties file to match your setup.\r\n- Create a JNI folder and create an Android.mk, a headphones.c file.\r\n- Edit the HeadphonesModule.java to load the native library and create a method that will call a C function.\r\n- Edit the app.js to call the java method.\r\n- plug an android phone (or if you are brave enough, launch an emulator)\r\n- Get a logcat (e.g., with DDMS)\r\n- run the app on your phone with 'ant install'\r\n\r\n\r\nYou will see \"java.lang.unsatisfiedLinkError: Couldn't load headphones: findLibrary returned null\"\r\nand \"Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lbe/tulipemoutarde/headphones/HeadphonesModule;\"\r\n\r\nI don't have any errors in the output when it compiles. I guess there's a problem somewhere in the build process (does the libheadphones.so copied in the right directory?), but my knowledge of Ant and the java tools is too limited :/\r\n\r\nYou can have a look/clone the project. Don't forget to adapt the paths in build.properties ;)\r\n\r\nhttps://github.com/fstephany/Titanium-JNI-demo", "attachment": [], "flagged": false, "summary": "Cannot use JNI for a native Android Module", "creator": { "name": "fstephany", "key": "fstephany", "displayName": "Francois Stephany", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "fstephany", "key": "fstephany", "displayName": "Francois Stephany", "active": true, "timeZone": "Europe/Berlin" }, "environment": "- MacOS X\r\n- NDK r8\r\n- Titanium Mobile 2.0.2GA \r\n- Titanium Studio build: 2.0.2.201205311912\r\n", "comment": { "comments": [ { "id": "202453", "author": { "name": "fstephany", "key": "fstephany", "displayName": "Francois Stephany", "active": true, "timeZone": "Europe/Berlin" }, "body": "I've managed to make it work. The process is a bit long but I guess it could be automated in the build.xml?\r\n\r\nHere's how to proceed:\r\n\r\n* ant clean\r\n* ndk-build\r\n* create the directory libs/armeabi-v7a and copy libs/armeabi/libheadphones.so into it.\r\n* ant dist\r\n* titanium install\r\n\r\nThe step where I copy the libheadpones.so in the armeabi-v7a is a bit weird but it works with my Samsung Galaxy S2.\r\n\r\nIs there an easiest way to make this work or should I write a script to perform all those operations? ", "updateAuthor": { "name": "fstephany", "key": "fstephany", "displayName": "Francois Stephany", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-07-10T16:14:01.000+0000", "updated": "2012-07-10T16:14:01.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }