diff --git a/native/Android.mk b/native/Android.mk
index c221913194ce162d057b4e5e6a12c49510796d47..f8cc45d0a5e2850aa7f65d7fc698695735d0a7a0 100644
--- a/native/Android.mk
+++ b/native/Android.mk
@@ -31,6 +31,10 @@ ifeq ($(FLAG_DBG), true)
     TARGETING_UNBUNDLED_FROYO := false
 endif
 
+ifeq ($(FLAG_DO_PROFILE), true)
+    TARGETING_UNBUNDLED_FROYO := false
+endif
+
 ifeq ($(TARGETING_UNBUNDLED_FROYO), true)
     LOCAL_NDK_VERSION := 4
     LOCAL_SDK_VERSION := 8
@@ -43,6 +47,7 @@ LOCAL_MODULE_TAGS := user
 ifeq ($(FLAG_DO_PROFILE), true)
     $(warning Making profiling version of native library)
     LOCAL_CFLAGS += -DFLAG_DO_PROFILE
+    LOCAL_SHARED_LIBRARIES := libcutils libutils
 else # FLAG_DO_PROFILE
 ifeq ($(FLAG_DBG), true)
     $(warning Making debug version of native library)
diff --git a/native/src/bigram_dictionary.cpp b/native/src/bigram_dictionary.cpp
index d11aee28eea1e810efb67efa6cbe89036d747e5e..6ed4d09820b50a79b7e9d0e90f40330c87ed8a3d 100644
--- a/native/src/bigram_dictionary.cpp
+++ b/native/src/bigram_dictionary.cpp
@@ -45,8 +45,8 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
 #ifdef FLAG_DBG
         char s[length + 1];
         for (int i = 0; i <= length; i++) s[i] = word[i];
-#endif
         LOGI("Bigram: Found word = %s, freq = %d :", s, frequency);
+#endif
     }
 
     // Find the right insertion point
diff --git a/native/src/defines.h b/native/src/defines.h
index a516190afd896a0563f815060a8020cd4702a8c8..e460f1ef4316fe089787a6e74647a387de9b3727 100644
--- a/native/src/defines.h
+++ b/native/src/defines.h
@@ -20,6 +20,7 @@
 
 #ifdef FLAG_DO_PROFILE
 // Profiler
+#include <cutils/log.h>
 #include <time.h>
 #define PROF_BUF_SIZE 100
 static double profile_buf[PROF_BUF_SIZE];
@@ -92,8 +93,10 @@ static void prof_out(void) {
 #define DEBUG_PROXIMITY_INFO true
 
 #else // FLAG_DBG
+#ifndef FLAG_DO_PROFILE
 #define LOGE(fmt, ...)
 #define LOGI(fmt, ...)
+#endif // FLAG_DO_PROFILE
 #define DEBUG_DICT false
 #define DEBUG_DICT_FULL false
 #define DEBUG_SHOW_FOUND_WORD false
diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp
index 698584e54fff6ec6618a3a3b3289234b484445e7..5e72c764f563bd7c0a1be7eb3f49d5f2651d5aa2 100644
--- a/native/src/unigram_dictionary.cpp
+++ b/native/src/unigram_dictionary.cpp
@@ -172,8 +172,8 @@ int UnigramDictionary::getSuggestions(const ProximityInfo *proximityInfo, const
             short unsigned int* w = mOutputChars + j * MAX_WORD_LENGTH;
             char s[MAX_WORD_LENGTH];
             for (int i = 0; i <= MAX_WORD_LENGTH; i++) s[i] = w[i];
-#endif
             LOGI("%s %i", s, mFrequencies[j]);
+#endif
         }
         LOGI("Next letters: ");
         for (int k = 0; k < NEXT_LETTERS_SIZE; k++) {
@@ -301,8 +301,8 @@ bool UnigramDictionary::addWord(unsigned short *word, int length, int frequency)
 #ifdef FLAG_DBG
         char s[length + 1];
         for (int i = 0; i <= length; i++) s[i] = word[i];
-#endif
         LOGI("Found word = %s, freq = %d", s, frequency);
+#endif
     }
     if (length > MAX_WORD_LENGTH) {
         if (DEBUG_DICT) {
@@ -325,8 +325,8 @@ bool UnigramDictionary::addWord(unsigned short *word, int length, int frequency)
 #ifdef FLAG_DBG
             char s[length + 1];
             for (int i = 0; i <= length; i++) s[i] = word[i];
-#endif
             LOGI("Added word = %s, freq = %d, %d", s, frequency, S_INT_MAX);
+#endif
         }
         memmove((char*) mFrequencies + (insertAt + 1) * sizeof(mFrequencies[0]),
                (char*) mFrequencies + insertAt * sizeof(mFrequencies[0]),
@@ -809,9 +809,9 @@ inline int UnigramDictionary::getMostFrequentWordLike(const int startInputIndex,
                             char s[inputLength + 1];
                             for (int i = 0; i < inputLength; ++i) s[i] = word[i];
                             s[inputLength] = 0;
-#endif
                             LOGI("New missing space word found: %d > %d (%s), %d, %d",
                                     newFreq, maxFreq, s, inputLength, depth);
+#endif
                         }
                         maxFreq = newFreq;
                     }