0

I am trying to learn Android-NDK, so i am trying to modify existing examples so I am trying to build apk from Android-PCAP but unable to do so, and getting this error message

    Information:Gradle tasks [:app:assembleDebug]
    WARNING [Project: :app] Current NDK support is deprecated.  Alternative will be provided in the future.
    :app:preBuild UP-TO-DATE
    :app:preDebugBuild UP-TO-DATE
    :app:checkDebugManifest
    :app:preReleaseBuild UP-TO-DATE
    :app:prepareComAndroidSupportGridlayoutV71800Library UP-TO-DATE
    :app:prepareDebugDependencies
    :app:compileDebugAidl UP-TO-DATE
    :app:compileDebugRenderscript UP-TO-DATE
    :app:generateDebugBuildConfig UP-TO-DATE
    :app:generateDebugAssets UP-TO-DATE
    :app:mergeDebugAssets UP-TO-DATE
    :app:generateDebugResValues UP-TO-DATE
    :app:generateDebugResources UP-TO-DATE
    :app:mergeDebugResources UP-TO-DATE
    :app:processDebugManifest UP-TO-DATE
    :app:processDebugResources UP-TO-DATE
    :app:generateDebugSources UP-TO-DATE
    :app:processDebugJavaRes UP-TO-DATE
    :app:compileDebugJava UP-TO-DATE
    :app:compileDebugNdk
    /home/nika/workspace/android-pcap/app/src/main/jni/libpcap/pcap-snoop.cpp:36:21: fatal error: net/raw.h: No such file or directory
     #include <net/raw.h>
               ^
    compilation terminated.
    make: *** [/home/nika/workspace/android-        pcap/app/build/intermediates/ndk/debug/obj/local/arm64-        v8a/objs/pcap//home/nika/workspace/android-pcap/app/src/main/jni/libpcap/pcap-snoop.o] Error 1
    Error:Execution failed for task ':app:compileDebugNdk'.
    > com.android.ide.common.process.ProcessException:         org.gradle.process.internal.ExecException: Process 'command '/opt/android-ndk/ndk-build'' finished with non-zero exit value 2
    Information:BUILD FAILED
    Information:Total time: 8.645 secs
    Information:1 error
    Information:0 warnings
    Information:See complete output in console

Is there anyway i can solve this error ?? Any help will be appreciated.

Before this i was getting error mentioned in this question. But then i renamed the files from c to cpp, that solved the problem.

I am using Android Studio 1.2.2 with Android NDK r10e on Linuxmint 17.1. :)

DeepSidhu1313
  • 805
  • 15
  • 31

1 Answers1

0

Is there anyway i can solve this error ??

Don't try to compile pcap-snoop.c - and don't rename it to pcap-snoop.cpp and try to compile that, either.

Libpcap is a multi-platform library, supporting a number of different operating systems. The mechanisms provided by individual UN*Xes to capture packets are different for different UN*Xes. *BSD, OS X/iOS, AIX, and Solaris 11 and later have BPF; Linux has SOCK_PACKET and PF_PACKET sockets; other UN*Xes have other mechanisms.

Libpcap provides an API that tries to hide those differences from applications. The "pcap-*.c" files are modules for particular capture mechanisms and, when compiling libpcap to run on a particular OS, only the appropriate "pcap-*.c" file for that OS should be compiled.

Android is Linux-based, and the appropriate "pcap-*.c" file for Linux is, not surprisingly, "pcap-linux.c". "pcap-snoop.c" is the appropriate "pcap-*.c" file for SGI's IRIX; one should never try to compile it unless one is compiling on IRIX or, if that's possible, cross-compiling for IRIX.