Uploaded image for project: 'Appcelerator - INBOX'
  1. Appcelerator - INBOX
  2. AC-3086

Cannot use JNI for a native Android Module

    Details

      Description

      How to reproduce:

      • Create a Titanium Module Project in Titanium Studio:
      • project name: headphones
      • module id: be.tulipemoutarde.headphones
      • deployment target: 'Android' / SDK: 2.0.2GA
      • Edit the build.properties file to match your setup.
      • Create a JNI folder and create an Android.mk, a headphones.c file.
      • Edit the HeadphonesModule.java to load the native library and create a method that will call a C function.
      • Edit the app.js to call the java method.
      • plug an android phone (or if you are brave enough, launch an emulator)
      • Get a logcat (e.g., with DDMS)
      • run the app on your phone with 'ant install'

      You will see "java.lang.unsatisfiedLinkError: Couldn't load headphones: findLibrary returned null"
      and "Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lbe/tulipemoutarde/headphones/HeadphonesModule;"

      I 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 :/

      You can have a look/clone the project. Don't forget to adapt the paths in build.properties

      https://github.com/fstephany/Titanium-JNI-demo

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mpmiranda Mauro Parra-Miranda
                Reporter:
                fstephany Francois Stephany
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code