android - Beginner help with NDK, java.lang.UnsatisfiedLinkError -


i trying create first android app uses ndk. trying use live555.com sources build app streams mp4 file phone somewhere else.

i using windows 7 32 bit jdk 1.6.0_24, motodev 2.1 , latest android sdk , ndk toolkits.

so far have setup new project , created jni directory. inside jni have placed source files , android.mk files. if execute ndk-build see:

$ $ndk/ndk-build sharedlibrary  : libtestprogs.so install        : libtestprogs.so => libs/armeabi/libtestprogs.so 

so seems native library being built.

when run app crashes lava.lang.unsatisfiedlinkerror: startstream.

startstream() method trying call in libtestprogs.so library.

things have checked: libtestprogs.so built , in proper place under libs/armeabi system.loadlibrary("testprogs"); called before attempt native call run javah -o jni.h com.streamtest.mainactivity , include .h .cpp file.

here mainactivity.java file:

 package com.streamtest;  import android.app.activity; import android.os.bundle; import android.util.log;  public class mainactivity extends activity {     public static final string log_tag = "streamtest";     static     {         try         {             //system.loadlibrary("jnix");             system.loadlibrary("testprogs");         }         catch(throwable e)         {             log.e(log_tag, e.tostring());             throw new runtimeexception(e);         }     }      /** called when activity first created. */     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);          // call our native code         log.e(log_tag, "about call native code!");         startstream();      }      private native void startstream(); }  

the native c++ file testondemandrtspserver.cpp file live555.com. changed main() method java native method. here is:

  #include "com_streamtest_mainactivity.h" #include "livemedia.hh" #include "basicusageenvironment.hh"   void java_com_streamtest_mainactivity_startstream(jnienv *env) {   // begin setting our usage environment:   taskscheduler* scheduler = basictaskscheduler::createnew();   uenv = basicusageenvironment::createnew(*scheduler);  

here logcat output:

  04-12 08:40:27.934: error/streamtest(17130): call native code! 04-12 08:40:27.965: error/androidruntime(17130): fatal exception: main 04-12 08:40:27.965: error/androidruntime(17130): java.lang.unsatisfiedlinkerror: startstream 04-12 08:40:27.965: error/androidruntime(17130):     @ com.streamtest.mainactivity.startstream(native method) 04-12 08:40:27.965: error/androidruntime(17130):     @ com.streamtest.mainactivity.oncreate(mainactivity.java:31) 04-12 08:40:27.965: error/androidruntime(17130):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 04-12 08:40:27.965: error/androidruntime(17130):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2627) 04-12 08:40:27.965: error/androidruntime(17130):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2679) 04-12 08:40:27.965: error/androidruntime(17130):     @ android.app.activitythread.access$2300(activitythread.java:125) 04-12 08:40:27.965: error/androidruntime(17130):     @ android.app.activitythread$h.handlemessage(activitythread.java:2033) 04-12 08:40:27.965: error/androidruntime(17130):     @ android.os.handler.dispatchmessage(handler.java:99) 04-12 08:40:27.965: error/androidruntime(17130):     @ android.os.looper.loop(looper.java:123) 04-12 08:40:27.965: error/androidruntime(17130):     @ android.app.activitythread.main(activitythread.java:4627) 04-12 08:40:27.965: error/androidruntime(17130):     @ java.lang.reflect.method.invokenative(native method) 04-12 08:40:27.965: error/androidruntime(17130):     @ java.lang.reflect.method.invoke(method.java:521) 04-12 08:40:27.965: error/androidruntime(17130):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:868) 04-12 08:40:27.965: error/androidruntime(17130):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:626) 04-12 08:40:27.965: error/androidruntime(17130):     @ dalvik.system.nativestart.main(native method)  

i wondering fatal exception: main line. in original .cpp file main() method. in new file there no main(). cause of problem? if is, how use .cpp file library? need main() method?

any appreciated try first ndk app running.

thanks, james

did include testondemandrtspserver.cpp in local_src_files variable in android.mk file?

when executed ndk-build, should have seen each of c/c++ files included in local_src_files being compiled. should have seen line (among several others if there multiple c/c++ files):

compile arm : libtestprogs <= testondemandrtspserver.cpp

in fact, based on output included execution of ndk-build, looks didn't included in local_src_files, , you're creating libtestprogs.so file nothing compiled it.

from docs:

"the local_src_files variables must contain list of c and/or c++ source files built , assembled module. note should not list header , included files here, because build system compute dependencies automatically you; list source files passed directly compiler, , should good."

see android-mk.html in docs folder of android jni downloaded details.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -