Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7825121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:50:25+00:00 2026-06-02T08:50:25+00:00

if i am defining such function in java file /** * Adds two integers,

  • 0

if i am defining such function in java file

  /** 
   * Adds two integers, returning their sum
   */
  public native int add( int v1, int v2 );

so i need to code in c file

JNIEXPORT jint JNICALL Java_com_marakana_NativeLib_add
  (JNIEnv * env, jobject obj, jint value1, jint value2) {

  printf("\n this is log messge \n");

        return (value1 + value2);
}

then from where this printf will print it message ?
In logcate i dont get it?

How can i debug any NDK application by putting log messages?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:50:28+00:00Added an answer on June 2, 2026 at 8:50 am

    use __android_log_print() instead. You have to include header <android/log.h>

    Sample Example. __android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "\n this is log messge \n");

    You can also use format specifier like printf –

    __android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "Need to print : %d %s",int_var, str_var);
    

    Make sure you also link against the logging library, in your Android.mk file:

      LOCAL_LDLIBS := -llog
    

    Ohh.. forgot .. The output will be shown in Logcat with tag LOG_TAG

    Easy Approach

    Add the following lines to your common header file.

    #include <android/log.h>
    
    #define  LOG_TAG    "your-log-tag"
    
    #define  LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
    #define  LOGE(...)  __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
    // If you want you can add other log definition for info, warning etc
    

    Now just call LOGD("Hello world") or LOGE("Number = %d", any_int) like printf in c.

    Don’t forget to include the common header file.

    Remove the logging

    If you define LOGD(...) empty, all logs will be gone. Just comment after LOGD(...).

    #define LOGD(...) // __android_log..... rest of the code

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does defining functions inside a loop affect performance? Like var doSomething = function(element){ $(element).whatever();
In C#, it is possible to define a readonly getter function by not defining
I want a function f such that (outer(X, Y, f))[i, j] is a side-by-side
php file to be available sitewide such that without require or include i simply
I am defining the following class: public class Foo<T> { T _value; public T
I remember somewhere seeing such a notation for formally defining a variable: variable_name: type
Is there an advantage to defining a function like (defun hi () Hi!) and
I have the following simple function: public class BaseEntityRepository<TEntity, TId> : IBaseEntityRepository<TEntity, TId> where
If I have a C++ struct, defining a 64bit data word such as.. struct
Defining custom components in Facelets is easy and quick but there's one thing I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.