我试图用Android中的JNI调用C源代码中的函数,但它崩溃了。
Android项目如下图所示。
JAVA中的代码如下:
public static native void startRTSPserver();
static {
Log.i(TAG, "Load Libraries...");
System.loadLibrary("live555");
}
当我在 startRTSPserver();
(SoftAP.java:302)
时,Android崩溃了
C源代码中的 live555MediaServer.cpp
代码如下:
#include <BasicUsageEnvironment.hh>
#include "DynamicRTSPServer.hh"
#include "version.hh"
JNIEXPORT void JNICALL Java_com_softap_SoftAP_startRTSPserver(JNIEnv *env , jobject thiz){
//int main(int argc, char** argv) {
__android_log_print(ANDROID_LOG_INFO, "JNIMsg", "RTSP Start---live555MediaServer");
// Begin by setting up our usage environment:
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
UserAuthenticationDatabase* authDB = NULL;
.
.
.
}
错误日志如下所示:
W/dalvikvm(13181): No implementation found for native Lcom/softap/SoftAP;.startRTSPserver:()V
D/AndroidRuntime(13181): Shutting down VM
W/dalvikvm(13181): threadid=1: thread exiting with uncaught exception (group=0x40db2450)
--------- beginning of /dev/log/system
E/AndroidRuntime(13181): FATAL EXCEPTION: main
E/AndroidRuntime(13181): java.lang.UnsatisfiedLinkError: Native method not found: com.softap.SoftAP.startRTSPserver:()V
E/AndroidRuntime(13181): at com.softap.SoftAP.startRTSPserver(Native Method)
E/AndroidRuntime(13181): at com.softap.SoftAP$6.onClick(SoftAP.java:302)
E/AndroidRuntime(13181): at android.view.View.performClick(View.java:4147)
E/AndroidRuntime(13181): at android.view.View$PerformClick.run(View.java:17161)
E/AndroidRuntime(13181): at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime(13181): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(13181): at android.os.Looper.loop(Looper.java:213)
E/AndroidRuntime(13181): at android.app.ActivityThread.main(ActivityThread.java:4786)
E/AndroidRuntime(13181): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(13181): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(13181): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
E/AndroidRuntime(13181): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
E/AndroidRuntime(13181): at dalvik.system.NativeStart.main(Native Method)
------------------------------------ EDIT ---------- ------------------------
Android.mk的代码如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := live555
LOCAL_ARM_MODE := arm
LOCAL_PRELINK_MODULE := false
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog
LOCAL_CPPFLAGS := \
-DNULL=0 -DSOCKLEN_T=socklen_t -DNO_SSTREAM -DBSD=1 -DNO_SSTREAM -fexceptions -DANDROID -DXLOCALE_NOT_USED
LOCAL_C_INCLUDES := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/BasicUsageEnvironment/include \
$(LOCAL_PATH)/BasicUsageEnvironment \
$(LOCAL_PATH)/UsageEnvironment/include \
$(LOCAL_PATH)/UsageEnvironment \
$(LOCAL_PATH)/groupsock/include \
$(LOCAL_PATH)/groupsock \
$(LOCAL_PATH)/liveMedia/include \
$(LOCAL_PATH)/liveMedia \
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := \
live555.cpp \
mediaServer/live555MediaServer.cpp \
mediaServer/DynamicRTSPServer.cpp \
liveMedia/Media.cpp \
liveMedia/MediaSource.cpp \
liveMedia/FramedSource.cpp \
liveMedia/FramedFileSource.cpp \
liveMedia/FramedFilter.cpp \
liveMedia/ByteStreamFileSource.cpp \
liveMedia/ByteStreamMultiFileSource.cpp \
liveMedia/ByteStreamMemoryBufferSource.cpp \
liveMedia/BasicUDPSource.cpp \
liveMedia/DeviceSource.cpp \
liveMedia/AudioInputDevice.cpp \
liveMedia/WAVAudioFileSource.cpp \
liveMedia/MPEG1or2Demux.cpp \
liveMedia/MPEG1or2DemuxedElementaryStream.cpp \
liveMedia/MPEGVideoStreamFramer.cpp \
liveMedia/MPEG1or2VideoStreamFramer.cpp \
liveMedia/MPEG1or2VideoStreamDiscreteFramer.cpp \
liveMedia/MPEG4VideoStreamFramer.cpp \
liveMedia/MPEG4VideoStreamDiscreteFramer.cpp \
liveMedia/H264VideoStreamFramer.cpp \
liveMedia/H264VideoStreamDiscreteFramer.cpp \
liveMedia/MPEGVideoStreamParser.cpp \
liveMedia/MPEG1or2AudioStreamFramer.cpp \
liveMedia/MPEG1or2AudioRTPSource.cpp \
liveMedia/MPEG4LATMAudioRTPSource.cpp \
liveMedia/MPEG4ESVideoRTPSource.cpp \
liveMedia/MPEG4GenericRTPSource.cpp \
liveMedia/MP3FileSource.cpp \
liveMedia/MP3Transcoder.cpp \
liveMedia/MP3ADU.cpp \
liveMedia/MP3ADUdescriptor.cpp \
liveMedia/MP3ADUinterleaving.cpp \
liveMedia/MP3ADUTranscoder.cpp \
liveMedia/MP3StreamState.cpp \
liveMedia/MP3Internals.cpp \
liveMedia/MP3InternalsHuffman.cpp \
liveMedia/MP3InternalsHuffmanTable.cpp \
liveMedia/MP3ADURTPSource.cpp \
liveMedia/MPEG1or2VideoRTPSource.cpp \
liveMedia/MPEG2TransportStreamMultiplexor.cpp \
liveMedia/MPEG2TransportStreamFromPESSource.cpp \
liveMedia/MPEG2TransportStreamFromESSource.cpp \
liveMedia/MPEG2TransportStreamFramer.cpp \
liveMedia/ADTSAudioFileSource.cpp \
liveMedia/H263plusVideoRTPSource.cpp \
liveMedia/H263plusVideoStreamFramer.cpp \
liveMedia/H263plusVideoStreamParser.cpp \
liveMedia/AC3AudioStreamFramer.cpp \
liveMedia/AC3AudioRTPSource.cpp \
liveMedia/DVVideoStreamFramer.cpp \
liveMedia/DVVideoRTPSource.cpp \
liveMedia/JPEGVideoSource.cpp \
liveMedia/AMRAudioSource.cpp \
liveMedia/AMRAudioFileSource.cpp \
liveMedia/InputFile.cpp \
liveMedia/StreamReplicator.cpp \
liveMedia/MediaSink.cpp \
liveMedia/FileSink.cpp \
liveMedia/BasicUDPSink.cpp \
liveMedia/AMRAudioFileSink.cpp \
liveMedia/H264VideoFileSink.cpp \
liveMedia/MPEG1or2AudioRTPSink.cpp \
liveMedia/MP3ADURTPSink.cpp \
liveMedia/MPEG1or2VideoRTPSink.cpp \
liveMedia/MPEG4LATMAudioRTPSink.cpp \
liveMedia/MPEG4GenericRTPSink.cpp \
liveMedia/MPEG4ESVideoRTPSink.cpp \
liveMedia/H263plusVideoRTPSink.cpp \
liveMedia/H264VideoRTPSink.cpp \
liveMedia/DVVideoRTPSink.cpp \
liveMedia/AC3AudioRTPSink.cpp \
liveMedia/VorbisAudioRTPSink.cpp \
liveMedia/VP8VideoRTPSink.cpp \
liveMedia/GSMAudioRTPSink.cpp \
liveMedia/JPEGVideoRTPSink.cpp \
liveMedia/SimpleRTPSink.cpp \
liveMedia/AMRAudioRTPSink.cpp \
liveMedia/T140TextRTPSink.cpp \
liveMedia/TCPStreamSink.cpp \
liveMedia/OutputFile.cpp \
liveMedia/uLawAudioFilter.cpp \
liveMedia/RTPSource.cpp \
liveMedia/MultiFramedRTPSource.cpp \
liveMedia/SimpleRTPSource.cpp \
liveMedia/H261VideoRTPSource.cpp \
liveMedia/H264VideoRTPSource.cpp \
liveMedia/QCELPAudioRTPSource.cpp \
liveMedia/AMRAudioRTPSource.cpp \
liveMedia/JPEGVideoRTPSource.cpp \
liveMedia/VorbisAudioRTPSource.cpp \
liveMedia/VP8VideoRTPSource.cpp \
liveMedia/RTPSink.cpp \
liveMedia/MultiFramedRTPSink.cpp \
liveMedia/AudioRTPSink.cpp \
liveMedia/VideoRTPSink.cpp \
liveMedia/TextRTPSink.cpp \
liveMedia/RTPInterface.cpp \
liveMedia/RTCP.cpp \
liveMedia/rtcp_from_spec.c \
liveMedia/RTSPServer.cpp \
liveMedia/RTSPClient.cpp \
liveMedia/RTSPCommon.cpp \
liveMedia/RTSPServerSupportingHTTPStreaming.cpp \
liveMedia/SIPClient.cpp \
liveMedia/MediaSession.cpp \
liveMedia/ServerMediaSession.cpp \
liveMedia/PassiveServerMediaSubsession.cpp \
liveMedia/OnDemandServerMediaSubsession.cpp \
liveMedia/FileServerMediaSubsession.cpp \
liveMedia/MPEG4VideoFileServerMediaSubsession.cpp \
liveMedia/H264VideoFileServerMediaSubsession.cpp \
liveMedia/H263plusVideoFileServerMediaSubsession.cpp \
liveMedia/WAVAudioFileServerMediaSubsession.cpp \
liveMedia/AMRAudioFileServerMediaSubsession.cpp \
liveMedia/MP3AudioFileServerMediaSubsession.cpp \
liveMedia/MPEG1or2VideoFileServerMediaSubsession.cpp \
liveMedia/MPEG1or2FileServerDemux.cpp \
liveMedia/MPEG1or2DemuxedServerMediaSubsession.cpp \
liveMedia/MPEG2TransportFileServerMediaSubsession.cpp \
liveMedia/ADTSAudioFileServerMediaSubsession.cpp \
liveMedia/DVVideoFileServerMediaSubsession.cpp \
liveMedia/AC3AudioFileServerMediaSubsession.cpp \
liveMedia/MPEG2TransportUDPServerMediaSubsession.cpp \
liveMedia/ProxyServerMediaSession.cpp \
liveMedia/QuickTimeFileSink.cpp \
liveMedia/QuickTimeGenericRTPSource.cpp \
liveMedia/AVIFileSink.cpp \
liveMedia/MPEG2IndexFromTransportStream.cpp \
liveMedia/MPEG2TransportStreamIndexFile.cpp \
liveMedia/MPEG2TransportStreamTrickModeFilter.cpp \
liveMedia/MatroskaFile.cpp \
liveMedia/MatroskaFileParser.cpp \
liveMedia/EBMLNumber.cpp \
liveMedia/MatroskaDemuxedTrack.cpp \
liveMedia/MatroskaFileServerDemux.cpp \
liveMedia/H264VideoMatroskaFileServerMediaSubsession.cpp \
liveMedia/VP8VideoMatroskaFileServerMediaSubsession.cpp \
liveMedia/AACAudioMatroskaFileServerMediaSubsession.cpp \
liveMedia/AC3AudioMatroskaFileServerMediaSubsession.cpp \
liveMedia/MP3AudioMatroskaFileServerMediaSubsession.cpp \
liveMedia/VorbisAudioMatroskaFileServerMediaSubsession.cpp \
liveMedia/T140TextMatroskaFileServerMediaSubsession.cpp \
liveMedia/DarwinInjector.cpp \
liveMedia/BitVector.cpp \
liveMedia/StreamParser.cpp \
liveMedia/DigestAuthentication.cpp \
liveMedia/our_md5.c \
liveMedia/our_md5hl.c \
liveMedia/Base64.cpp \
liveMedia/Locale.cpp \
groupsock/GroupsockHelper.cpp \
groupsock/GroupEId.cpp \
groupsock/inet.c \
groupsock/Groupsock.cpp \
groupsock/NetInterface.cpp \
groupsock/NetAddress.cpp \
groupsock/IOHandlers.cpp \
UsageEnvironment/UsageEnvironment.cpp \
UsageEnvironment/HashTable.cpp \
UsageEnvironment/strDup.cpp \
BasicUsageEnvironment/BasicUsageEnvironment0.cpp \
BasicUsageEnvironment/BasicUsageEnvironment.cpp \
BasicUsageEnvironment/BasicTaskScheduler0.cpp \
BasicUsageEnvironment/BasicTaskScheduler.cpp \
BasicUsageEnvironment/DelayQueue.cpp \
BasicUsageEnvironment/BasicHashTable.cpp \
include $(BUILD_SHARED_LIBRARY)
有人知道它崩溃的原因吗?我错过了什么吗?