Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have started to fix the problem of the camera not working. In brief I moved to latest OpenCV code, installed Android 4.1.1 on my tablet, moved to the latest Android development environment. Then I built OpenCV Manager and the camera wrapper (http://code.opencv.org/projects/opencv/wiki/Building_OpenCV4Android_from_trunk is a guide but not complete). I changed the default path in camera_activity.cpp:
#define DEFAULT_WRAPPER_PACKAGE_NAME "org.opencv.lib_v24_armv7a_neon"
After the build I installed my version of the OpenCV binary_pack_armv7a_neon-release.apk and now at least some of examples work.
Details
details of the build and the issues to follow

click to hide/show revision 2
added build issues and fixes

I have started to fix the problem of the camera not working. In brief I moved to latest OpenCV code, installed Android 4.1.1 on my tablet, moved to the latest Android development environment. Then I built OpenCV Manager and the camera wrapper (http://code.opencv.org/projects/opencv/wiki/Building_OpenCV4Android_from_trunk is a guide but not complete). I changed the default path in camera_activity.cpp:
#define DEFAULT_WRAPPER_PACKAGE_NAME "org.opencv.lib_v24_armv7a_neon"
After the build I installed my version of the OpenCV binary_pack_armv7a_neon-release.apk and now at least some of examples work.
Details
details As you will know from reading http://code.opencv.org/projects/opencv/wiki/Building_OpenCV4Android_from_trunk to build modules/androidcamera/camera_wrapper and the binary pack OpenCV binary_pack_armv7a_neon-release.apk you need to have a working build of the android source for your platform. Building on 64bit Linux requires the latest Android source, plus a lot of 32bit libraries as detailed at http://source.android.com/source/initializing.html, then follow the instructions at http://source.android.com/source/building.html (I configured and built full-eng that builds the generic/system/lib libraries referenced by camera_wrapper/CMakeLists.txt).
Now the fun started for me because OpenCV does not seem to have been built as a package so here are the fixes that I have used. First I set my path up and ANDROID_NDK
export ANDROID_NDK=~/InstallPackages/android-ndk-r8b
export ANDROID_SDK=~/InstallPackages/android-sdk-linux
export ANDROID_SRC=~/Projects/Android411
export PATH=${PATH}:${ANDROID_SDK}/platform-tools:${ANDROID_SDK}/tools:${ANDROID_SDK}:${ANDROID_NDK}
then in the
build folder (android/build) I ran cmake

cmake -DBUILD_ANDROID_PACKAGE=ON -DBUILD_ANDROID_SERVICE=ON -DANDROID_USE_STLPORT=OFF -DBUILD_EXAMPLES=ON -DANDROID_NATIVE_API_LEVEL=14 -DANDROID_EXECUTABLE=${ANDROID_SDK}/tools/android -DANDROID_SOURCE_TREE=${ANDROID_SRC} -DANDROID_ABI="armeabi-v7a with NEON" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../..

and the issues to followbuilt the code

make -j8
make install

I use ANDROID_USE_STLPORT=OFF because various parts of OpenCV include android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/include/ext/atomicity.h that does not exist in the stlport libraries that are described as "experimental" by the Android team. The side effect of this is that rtti is switched on so linking fails. So one of either include atomicity.h or linking have to be fixed. It also has the side effect that the OpenCV Manager is not built, but I have a simple fix for this. The result is that the entire OpenCV code is built and all the .apk files are produced (although OpenCV binary_pack_armv7a_neon-release-unsigned.apk has to be signed (see http://developer.android.com/tools/publishing/app-signing.html)
Troubleshooting
Ok so here are my patches:
ERROR from the logcat output "CameraWrapperConnector::connectToLib: folderPath=/data/data/com.NativeCamera/lib/
CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library E/CV_CAP ( 1796): Native_camera returned opening error: 4 E/Sample::SurfaceView( 1796): Failed to open native camera
FIX this is the error that started it all.. fix is to build android and opencv but with the default path set to "/data/data/org.opencv.lib_v24_armv7a_neon/lib" in modules/androidcamera/src/camera_activity.cpp
#define DEFAULT_WRAPPER_PACKAGE_NAME "org.opencv.lib_v24_armv7a_neon"
Once built and signed you can load the new OpenCV Manager and binary pack by hand rather than from the Android store:
adb install android/build/bin/opencv_engine.apk
adb install android/build/install/apk/OpenCV_2.4.9_binary_pack_armv7a_neon-release.apk
ERROR in build logs modules/core/include/opencv2/core/operations.hpp:65:33: fatal error: ext/atomicity.h: No such file or directory
FIX build with -DANDROID_USE_STLPORT=OFF because android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/include/ext has the missing header file
ERROR undefined reference to typeinfo for android::RefBase' in modules/androidcamera/camera_wrapper/CMakeFiles
FIX this is caused because -DANDROID_USE_STLPORT=ON switches off rtti, we removed this above so now the linker fails so lets switch off rtti for camera_wrapper: Add the following to modules/androidcamera/camera_wrapper/CMakeLists.txt

function(replace_compiler_option var old new)
  # Replaces a compiler option or switch old in var by new.
  # If old is not in var, appends new to var.
  # Example: replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
  # If the option already is on the variable, don't add it:
  if( "${${var}}" MATCHES "(^| )${new}($| )" )
    set(n "")
  else()
    set(n "${new}")
  endif()
  if( "${${var}}" MATCHES "(^| )${old}($| )" )
    string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
  else()
    set( ${var} "${${var}} ${n}" )
  endif()
  set( ${var} "${${var}}" PARENT_SCOPE )
endfunction(replace_compiler_option)

replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
status("camera_wrapper C++ flags):" ${CMAKE_CXX_FLAGS})

ERROR service is not built
FIX because -DANDROID_USE_STLPORT=ON also is an apparent requirement for building the service code we have to fix up CMakeLists.txt and remove this dependency
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_SOURCE_TREE )
ERROR android/service/engine/jni/include/IOpenCVEngine.h:4:31: fatal error: binder/IInterface.h: No such file or directory
FIX add "${ANDROID_SOURCE_TREE}/frameworks/native/include" to android/service/engine/CMakeLists.txt
include_directories(SYSTEM "${ANDROID_SOURCE_TREE}/frameworks/base/include" "${ANDROID_SOURCE_TREE}/frameworks/native/include" "${ANDROID_SOURCE_TREE}/system/core/include")
ERROR android/service/engine/jni/BinderComponent/BnOpenCVEngine.cpp:20:56: error: 'LOGD' was not declared in this scope
FIX add following to android/service/engine/jni/BinderComponent/BnOpenCVEngine.cpp
android/service/engine/jni/BinderComponent/HardwareDetector.cpp
android/service/engine/jni/NativeService/PackageInfo.cpp
android/service/engine/jni/BinderComponent/OpenCVEngine.cpp
android/service/engine/jni/JNIWrapper/OpenCVEngine_jni.cpp

//undef logging macro from /system/core/libcutils/loghack.h
#ifdef LOGD
# undef LOGD
#endif
#ifdef LOGI
# undef LOGI
#endif
#ifdef LOGW
# undef LOGW
#endif
#ifdef LOGE
# undef LOGE
#endif
// LOGGING
#include <android log.h="">
#define ENGINE_LOG_TAG "OpenCV_Engine"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, ENGINE_LOG_TAG, __VA_ARGS__))

ERROR arm-linux-androideabi-g++: error: SONAME_FLAGlibOpenCVEngine.so: No such file or directory
FIX build with -DBUILD_ANDROID_SERVICE=ON and then you get the linker error so add the following to android/service/engine/CMakeLists.txt

function(replace_compiler_option var old new)
  # Replaces a compiler option or switch `old' in `var' by `new'.
  # If `old' is not in `var', appends `new' to `var'.
  # Example: llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
  # If the option already is on the variable, don't add it:
  if( "${${var}}" MATCHES "(^| )${new}($| )" )
    set(n "")
  else()
    set(n "${new}")
  endif()
  if( "${${var}}" MATCHES "(^| )${old}($| )" )
    string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
  else()
    set( ${var} "${${var}} ${n}" )
  endif()
  set( ${var} "${${var}}" PARENT_SCOPE )
endfunction(replace_compiler_option)

replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
status("Service Engine C++ flags:" ${CMAKE_CXX_FLAGS})
click to hide/show revision 3
added a couple more comments

I have started to fix the problem of the camera not working. In brief I moved to latest OpenCV code, installed Android 4.1.1 on my tablet, moved to the latest Android development environment. Then I built OpenCV Manager and the camera wrapper (http://code.opencv.org/projects/opencv/wiki/Building_OpenCV4Android_from_trunk is a guide but not complete). I changed the default path in camera_activity.cpp:
#define DEFAULT_WRAPPER_PACKAGE_NAME "org.opencv.lib_v24_armv7a_neon"
After the build I installed my version of the OpenCV binary_pack_armv7a_neon-release.apk and now at least some of examples work.

Details
As you will know from reading http://code.opencv.org/projects/opencv/wiki/Building_OpenCV4Android_from_trunk to build modules/androidcamera/camera_wrapper and the binary pack OpenCV binary_pack_armv7a_neon-release.apk you need to have a working build of the android source for your platform. Building on 64bit Linux requires the latest Android source, plus a lot of 32bit libraries as detailed at http://source.android.com/source/initializing.html, then follow the instructions at http://source.android.com/source/building.html (I configured and built full-eng that builds the generic/system/lib libraries referenced by camera_wrapper/CMakeLists.txt).
Now the fun started for me because OpenCV does not seem to have been built as a package so here are the fixes that I have used. First I set my path up and ANDROID_NDK
export ANDROID_NDK=~/InstallPackages/android-ndk-r8b
export ANDROID_SDK=~/InstallPackages/android-sdk-linux
export ANDROID_SRC=~/Projects/Android411
export PATH=${PATH}:${ANDROID_SDK}/platform-tools:${ANDROID_SDK}/tools:${ANDROID_SDK}:${ANDROID_NDK}
then in the build folder (android/build) I ran cmake

cmake -DBUILD_ANDROID_PACKAGE=ON -DBUILD_ANDROID_SERVICE=ON -DANDROID_USE_STLPORT=OFF -DBUILD_EXAMPLES=ON -DANDROID_NATIVE_API_LEVEL=14 -DANDROID_EXECUTABLE=${ANDROID_SDK}/tools/android -DANDROID_SOURCE_TREE=${ANDROID_SRC} -DANDROID_ABI="armeabi-v7a with NEON" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../..

and built the code

make -j8
make install

I use ANDROID_USE_STLPORT=OFF because various parts of OpenCV include android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/include/ext/atomicity.h that does not exist in the stlport libraries that are described as "experimental" by the Android team. The side effect of this is that rtti is switched on so linking fails. So one of either include atomicity.h or linking have to be fixed. It also has the side effect that the OpenCV Manager is not built, but I have a simple fix for this. The result is that the entire OpenCV code is built and all the .apk files are produced (although OpenCV binary_pack_armv7a_neon-release-unsigned.apk has to be signed (see http://developer.android.com/tools/publishing/app-signing.html)

Troubleshooting
Ok so here are my patches:
ERROR from the logcat output "CameraWrapperConnector::connectToLib: folderPath=/data/data/com.NativeCamera/lib/
CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library E/CV_CAP ( 1796): Native_camera returned opening error: 4 E/Sample::SurfaceView( 1796): Failed to open native camera
FIX this is the error that started it all.. fix is to build android and opencv but with the default path set to "/data/data/org.opencv.lib_v24_armv7a_neon/lib" in modules/androidcamera/src/camera_activity.cpp
#define DEFAULT_WRAPPER_PACKAGE_NAME "org.opencv.lib_v24_armv7a_neon"
Once built and signed you can load the new OpenCV Manager and binary pack by hand rather than from the Android store:
adb install android/build/bin/opencv_engine.apk
adb install android/build/install/apk/OpenCV_2.4.9_binary_pack_armv7a_neon-release.apk
ERROR in build logs modules/core/include/opencv2/core/operations.hpp:65:33: fatal error: ext/atomicity.h: No such file or directory
FIX build with -DANDROID_USE_STLPORT=OFF because android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/include/ext has the missing header file
ERROR undefined reference to typeinfo for android::RefBase' in modules/androidcamera/camera_wrapper/CMakeFiles
FIX this is caused because -DANDROID_USE_STLPORT=ON switches off rtti, we removed this above so now the linker fails so lets switch off rtti for camera_wrapper: Add the following to modules/androidcamera/camera_wrapper/CMakeLists.txt

function(replace_compiler_option var old new)
  # Replaces a compiler option or switch old in var by new.
  # If old is not in var, appends new to var.
  # Example: replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
  # If the option already is on the variable, don't add it:
  if( "${${var}}" MATCHES "(^| )${new}($| )" )
    set(n "")
  else()
    set(n "${new}")
  endif()
  if( "${${var}}" MATCHES "(^| )${old}($| )" )
    string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
  else()
    set( ${var} "${${var}} ${n}" )
  endif()
  set( ${var} "${${var}}" PARENT_SCOPE )
endfunction(replace_compiler_option)

replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
status("camera_wrapper C++ flags):" ${CMAKE_CXX_FLAGS})

ERROR service is not built
FIX because -DANDROID_USE_STLPORT=ON also is an apparent requirement for building the service code we have to fix up CMakeLists.txt and remove this dependency
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_SOURCE_TREE )
ERROR android/service/engine/jni/include/IOpenCVEngine.h:4:31: fatal error: binder/IInterface.h: No such file or directory
FIX add "${ANDROID_SOURCE_TREE}/frameworks/native/include" to android/service/engine/CMakeLists.txt
include_directories(SYSTEM "${ANDROID_SOURCE_TREE}/frameworks/base/include" "${ANDROID_SOURCE_TREE}/frameworks/native/include" "${ANDROID_SOURCE_TREE}/system/core/include")
ERROR android/service/engine/jni/BinderComponent/BnOpenCVEngine.cpp:20:56: error: 'LOGD' was not declared in this scope
FIX add following to android/service/engine/jni/BinderComponent/BnOpenCVEngine.cpp
android/service/engine/jni/BinderComponent/HardwareDetector.cpp
android/service/engine/jni/NativeService/PackageInfo.cpp
android/service/engine/jni/BinderComponent/OpenCVEngine.cpp
android/service/engine/jni/JNIWrapper/OpenCVEngine_jni.cpp
android/service/engine/jni/JNIWrapper/JavaBasedPackageManager.cpp

//undef logging macro from /system/core/libcutils/loghack.h
#ifdef LOGD
# undef LOGD
#endif
#ifdef LOGI
# undef LOGI
#endif
#ifdef LOGW
# undef LOGW
#endif
#ifdef LOGE
# undef LOGE
#endif
// LOGGING
#include <android log.h="">
#define ENGINE_LOG_TAG "OpenCV_Engine"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, ENGINE_LOG_TAG, __VA_ARGS__))

ERROR arm-linux-androideabi-g++: error: SONAME_FLAGlibOpenCVEngine.so: No such file or directory
FIX build with -DBUILD_ANDROID_SERVICE=ON and then you get the linker error so add the following to android/service/engine/CMakeLists.txt

function(replace_compiler_option var old new)
  # Replaces a compiler option or switch `old' in `var' by `new'.
  # If `old' is not in `var', appends `new' to `var'.
  # Example: llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
  # If the option already is on the variable, don't add it:
  if( "${${var}}" MATCHES "(^| )${new}($| )" )
    set(n "")
  else()
    set(n "${new}")
  endif()
  if( "${${var}}" MATCHES "(^| )${old}($| )" )
    string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
  else()
    set( ${var} "${${var}} ${n}" )
  endif()
  set( ${var} "${${var}}" PARENT_SCOPE )
endfunction(replace_compiler_option)

replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
status("Service Engine C++ flags:" ${CMAKE_CXX_FLAGS})
click to hide/show revision 4
finished bug description

I have started to fix the problem of the camera not working. In brief I moved to latest OpenCV code, installed Android 4.1.1 on my tablet, moved to the latest Android development environment. Then I built OpenCV Manager and the camera wrapper (http://code.opencv.org/projects/opencv/wiki/Building_OpenCV4Android_from_trunk is a guide but not complete). I changed the default path in camera_activity.cpp:
#define DEFAULT_WRAPPER_PACKAGE_NAME "org.opencv.lib_v24_armv7a_neon"
After the build I installed my version of the OpenCV binary_pack_armv7a_neon-release.apk and now at least some of examples work.

Details
As you will know from reading http://code.opencv.org/projects/opencv/wiki/Building_OpenCV4Android_from_trunk to build modules/androidcamera/camera_wrapper and the binary pack OpenCV binary_pack_armv7a_neon-release.apk you need to have a working build of the android source for your platform. Building on 64bit Linux requires the latest Android source, plus a lot of 32bit libraries as detailed at http://source.android.com/source/initializing.html, then follow the instructions at http://source.android.com/source/building.html (I configured and built full-eng that builds the generic/system/lib libraries referenced by camera_wrapper/CMakeLists.txt).
Now the fun started for me because OpenCV does not seem to have been built as a package so here are the fixes that I have used. First I set my path up and ANDROID_NDK
export ANDROID_NDK=~/InstallPackages/android-ndk-r8b
export ANDROID_SDK=~/InstallPackages/android-sdk-linux
export ANDROID_SRC=~/Projects/Android411
export PATH=${PATH}:${ANDROID_SDK}/platform-tools:${ANDROID_SDK}/tools:${ANDROID_SDK}:${ANDROID_NDK}
then in the build folder (android/build) I ran cmake

cmake -DBUILD_ANDROID_PACKAGE=ON -DBUILD_ANDROID_SERVICE=ON -DANDROID_USE_STLPORT=OFF -DBUILD_EXAMPLES=ON -DANDROID_NATIVE_API_LEVEL=14 -DANDROID_EXECUTABLE=${ANDROID_SDK}/tools/android -DANDROID_SOURCE_TREE=${ANDROID_SRC} -DANDROID_ABI="armeabi-v7a with NEON" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../..

and built the code

make -j8
make install

I use ANDROID_USE_STLPORT=OFF because various parts of OpenCV include android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/include/ext/atomicity.h that does not exist in the stlport libraries that are described as "experimental" by the Android team. The side effect of this is that rtti is switched on so linking fails. So one of either include atomicity.h or linking have to be fixed. It also has the side effect that the OpenCV Manager is not built, but I have a simple fix for this. The result is that the entire OpenCV code is built and all the .apk files are produced (although OpenCV binary_pack_armv7a_neon-release-unsigned.apk has to be signed (see http://developer.android.com/tools/publishing/app-signing.html)

Troubleshooting
Ok so here are my patches:
ERROR from the logcat output "CameraWrapperConnector::connectToLib: folderPath=/data/data/com.NativeCamera/lib/
CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library E/CV_CAP ( 1796): Native_camera returned opening error: 4 E/Sample::SurfaceView( 1796): Failed to open native camera
FIX this is the error that started it all.. fix is to build android and opencv but with the default path set to "/data/data/org.opencv.lib_v24_armv7a_neon/lib" in modules/androidcamera/src/camera_activity.cpp
#define DEFAULT_WRAPPER_PACKAGE_NAME "org.opencv.lib_v24_armv7a_neon"
Once built and signed you can load the new OpenCV Manager and binary pack by hand rather than from the Android store:
adb install android/build/bin/opencv_engine.apk
adb install android/build/install/apk/OpenCV_2.4.9_binary_pack_armv7a_neon-release.apk
ERROR in build logs modules/core/include/opencv2/core/operations.hpp:65:33: fatal error: ext/atomicity.h: No such file or directory
FIX build with -DANDROID_USE_STLPORT=OFF because android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/include/ext has the missing header file
ERROR undefined reference to typeinfo for android::RefBase' in modules/androidcamera/camera_wrapper/CMakeFiles
FIX this is caused because -DANDROID_USE_STLPORT=ON switches off rtti, we removed this above so now the linker fails so lets switch off rtti for camera_wrapper: Add the following to modules/androidcamera/camera_wrapper/CMakeLists.txt

function(replace_compiler_option var old new)
  # Replaces a compiler option or switch old in var by new.
  # If old is not in var, appends new to var.
  # Example: replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
  # If the option already is on the variable, don't add it:
  if( "${${var}}" MATCHES "(^| )${new}($| )" )
    set(n "")
  else()
    set(n "${new}")
  endif()
  if( "${${var}}" MATCHES "(^| )${old}($| )" )
    string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
  else()
    set( ${var} "${${var}} ${n}" )
  endif()
  set( ${var} "${${var}}" PARENT_SCOPE )
endfunction(replace_compiler_option)

replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
status("camera_wrapper C++ flags):" ${CMAKE_CXX_FLAGS})

ERROR service is not built
FIX because -DANDROID_USE_STLPORT=ON also is an apparent requirement for building the service code we have to fix up CMakeLists.txt and remove this dependency
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_SOURCE_TREE )
ERROR android/service/engine/jni/include/IOpenCVEngine.h:4:31: fatal error: binder/IInterface.h: No such file or directory
FIX add "${ANDROID_SOURCE_TREE}/frameworks/native/include" to android/service/engine/CMakeLists.txt
include_directories(SYSTEM "${ANDROID_SOURCE_TREE}/frameworks/base/include" "${ANDROID_SOURCE_TREE}/frameworks/native/include" "${ANDROID_SOURCE_TREE}/system/core/include")
ERROR android/service/engine/jni/BinderComponent/BnOpenCVEngine.cpp:20:56: error: 'LOGD' was not declared in this scope
FIX add following to android/service/engine/jni/BinderComponent/BnOpenCVEngine.cpp
android/service/engine/jni/BinderComponent/HardwareDetector.cpp
android/service/engine/jni/NativeService/PackageInfo.cpp
android/service/engine/jni/BinderComponent/OpenCVEngine.cpp
android/service/engine/jni/JNIWrapper/OpenCVEngine_jni.cpp
android/service/engine/jni/JNIWrapper/JavaBasedPackageManager.cpp

//undef logging macro from /system/core/libcutils/loghack.h
#ifdef LOGD
# undef LOGD
#endif
#ifdef LOGI
# undef LOGI
#endif
#ifdef LOGW
# undef LOGW
#endif
#ifdef LOGE
# undef LOGE
#endif
// LOGGING
#include <android log.h="">
#define ENGINE_LOG_TAG "OpenCV_Engine"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, ENGINE_LOG_TAG, __VA_ARGS__))

ERROR arm-linux-androideabi-g++: error: SONAME_FLAGlibOpenCVEngine.so: No such file or directory
FIX build with -DBUILD_ANDROID_SERVICE=ON and then you get the linker error so add the following to android/service/engine/CMakeLists.txt

function(replace_compiler_option var old new)
  # Replaces a compiler option or switch `old' in `var' by `new'.
  # If `old' is not in `var', appends `new' to `var'.
  # Example: llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
  # If the option already is on the variable, don't add it:
  if( "${${var}}" MATCHES "(^| )${new}($| )" )
    set(n "")
  else()
    set(n "${new}")
  endif()
  if( "${${var}}" MATCHES "(^| )${old}($| )" )
    string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
  else()
    set( ${var} "${${var}} ${n}" )
  endif()
  set( ${var} "${${var}}" PARENT_SCOPE )
endfunction(replace_compiler_option)

replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
status("Service Engine C++ flags:" ${CMAKE_CXX_FLAGS})

ERROR from the logcat logs -
I/Sample::SurfaceView( 1446): openCamera
I/Sample::SurfaceView( 1446): releaseCamera
E/Sample::SurfaceView( 1446): Can't open camera!
FIX - In Camera.java on android - the API description says - Creates a new Camera object to access the first back-facing camera on the device. If the device does not have a back-facing camera, this returns null.
So as my tablet does not contain a back-facing camera I expect this to return NULL and thus OpenCV cant find the camera!
OpenCV Example code assumes a forward facing camera so test for more than one camera only fail if no cameras

        mNumCameras = Camera.getNumberOfCameras();
        mCamera = Camera.open();
        if ((mCamera == null) && mNumCameras < 1) {
            Log.e(TAG, "ERROR: Can't open camera!");
            return false;
        } else {
            // Try the first camera
                Log.i(TAG, "INFO:  Can't open forward facing camera!");
            mCamera = Camera.open(0);
            if (mCamera == null) {
                Log.e(TAG, "ERROR: Can't open any camera!");
                return false;
            }
        }

API required is 11 so you need to update the AndroidManifest.xml file 8->11 . this fix is applied to tutorial -0- -1- -3- & -4-. Now all the tutorials work!

click to hide/show revision 5
finished description

I have started to fix the problem of the camera not working. In brief I moved to latest OpenCV code, installed Android 4.1.1 on my tablet, moved to the latest Android development environment. Then I built OpenCV Manager and the camera wrapper (http://code.opencv.org/projects/opencv/wiki/Building_OpenCV4Android_from_trunk is a guide but not complete). I changed the default path in camera_activity.cpp:
#define DEFAULT_WRAPPER_PACKAGE_NAME "org.opencv.lib_v24_armv7a_neon"
After the build I installed my version of the OpenCV binary_pack_armv7a_neon-release.apk and the examples began to work. Then I fixed a problem where OpenCV examples assume a backward facing camera. My tablet only has forward facing camera so 4 of the examples failed till I fixed that example code bug and now at least some of all examples work.

Details
As you will know from reading http://code.opencv.org/projects/opencv/wiki/Building_OpenCV4Android_from_trunk to build modules/androidcamera/camera_wrapper and the binary pack OpenCV binary_pack_armv7a_neon-release.apk you need to have a working build of the android source for your platform. Building on 64bit Linux requires the latest Android source, plus a lot of 32bit libraries as detailed at http://source.android.com/source/initializing.html, then follow the instructions at http://source.android.com/source/building.html (I configured and built full-eng that builds the generic/system/lib libraries referenced by camera_wrapper/CMakeLists.txt).
Now the fun started for me because OpenCV does not seem to have been built as a package so here are the fixes that I have used. First I set my path up and ANDROID_NDK
export ANDROID_NDK=~/InstallPackages/android-ndk-r8b
export ANDROID_SDK=~/InstallPackages/android-sdk-linux
export ANDROID_SRC=~/Projects/Android411
export PATH=${PATH}:${ANDROID_SDK}/platform-tools:${ANDROID_SDK}/tools:${ANDROID_SDK}:${ANDROID_NDK}
then in the build folder (android/build) I ran cmake

cmake -DBUILD_ANDROID_PACKAGE=ON -DBUILD_ANDROID_SERVICE=ON -DANDROID_USE_STLPORT=OFF -DBUILD_EXAMPLES=ON -DANDROID_NATIVE_API_LEVEL=14 -DANDROID_EXECUTABLE=${ANDROID_SDK}/tools/android -DANDROID_SOURCE_TREE=${ANDROID_SRC} -DANDROID_ABI="armeabi-v7a with NEON" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../..

and built the code

make -j8
make install

I use ANDROID_USE_STLPORT=OFF because various parts of OpenCV include android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/include/ext/atomicity.h that does not exist in the stlport libraries that are described as "experimental" by the Android team. The side effect of this is that rtti is switched on so linking fails. So one of either include atomicity.h or linking have to be fixed. It also has the side effect that the OpenCV Manager is not built, but I have a simple fix for this. The result is that the entire OpenCV code is built and all the .apk files are produced (although OpenCV binary_pack_armv7a_neon-release-unsigned.apk has to be signed (see http://developer.android.com/tools/publishing/app-signing.html)

Troubleshooting
Ok so here are my patches:
ERROR from the logcat output "CameraWrapperConnector::connectToLib: folderPath=/data/data/com.NativeCamera/lib/
CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library E/CV_CAP ( 1796): Native_camera returned opening error: 4 E/Sample::SurfaceView( 1796): Failed to open native camera
FIX this is the error that started it all.. fix is to build android and opencv but with the default path set to "/data/data/org.opencv.lib_v24_armv7a_neon/lib" in modules/androidcamera/src/camera_activity.cpp
#define DEFAULT_WRAPPER_PACKAGE_NAME "org.opencv.lib_v24_armv7a_neon"
Once built and signed you can load the new OpenCV Manager and binary pack by hand rather than from the Android store:
adb install android/build/bin/opencv_engine.apk
adb install android/build/install/apk/OpenCV_2.4.9_binary_pack_armv7a_neon-release.apk
ERROR in build logs modules/core/include/opencv2/core/operations.hpp:65:33: fatal error: ext/atomicity.h: No such file or directory
FIX build with -DANDROID_USE_STLPORT=OFF because android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/include/ext has the missing header file
ERROR undefined reference to typeinfo for android::RefBase' in modules/androidcamera/camera_wrapper/CMakeFiles
FIX this is caused because -DANDROID_USE_STLPORT=ON switches off rtti, we removed this above so now the linker fails so lets switch off rtti for camera_wrapper: Add the following to modules/androidcamera/camera_wrapper/CMakeLists.txt

function(replace_compiler_option var old new)
  # Replaces a compiler option or switch old in var by new.
  # If old is not in var, appends new to var.
  # Example: replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
  # If the option already is on the variable, don't add it:
  if( "${${var}}" MATCHES "(^| )${new}($| )" )
    set(n "")
  else()
    set(n "${new}")
  endif()
  if( "${${var}}" MATCHES "(^| )${old}($| )" )
    string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
  else()
    set( ${var} "${${var}} ${n}" )
  endif()
  set( ${var} "${${var}}" PARENT_SCOPE )
endfunction(replace_compiler_option)

replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
status("camera_wrapper C++ flags):" ${CMAKE_CXX_FLAGS})

ERROR service is not built
FIX because -DANDROID_USE_STLPORT=ON also is an apparent requirement for building the service code we have to fix up CMakeLists.txt and remove this dependency
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_SOURCE_TREE )
ERROR android/service/engine/jni/include/IOpenCVEngine.h:4:31: fatal error: binder/IInterface.h: No such file or directory
FIX add "${ANDROID_SOURCE_TREE}/frameworks/native/include" to android/service/engine/CMakeLists.txt
include_directories(SYSTEM "${ANDROID_SOURCE_TREE}/frameworks/base/include" "${ANDROID_SOURCE_TREE}/frameworks/native/include" "${ANDROID_SOURCE_TREE}/system/core/include")
ERROR android/service/engine/jni/BinderComponent/BnOpenCVEngine.cpp:20:56: error: 'LOGD' was not declared in this scope
FIX add following to android/service/engine/jni/BinderComponent/BnOpenCVEngine.cpp
android/service/engine/jni/BinderComponent/HardwareDetector.cpp
android/service/engine/jni/NativeService/PackageInfo.cpp
android/service/engine/jni/BinderComponent/OpenCVEngine.cpp
android/service/engine/jni/JNIWrapper/OpenCVEngine_jni.cpp
android/service/engine/jni/JNIWrapper/JavaBasedPackageManager.cpp

//undef logging macro from /system/core/libcutils/loghack.h
#ifdef LOGD
# undef LOGD
#endif
#ifdef LOGI
# undef LOGI
#endif
#ifdef LOGW
# undef LOGW
#endif
#ifdef LOGE
# undef LOGE
#endif
// LOGGING
#include <android log.h="">
#define ENGINE_LOG_TAG "OpenCV_Engine"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, ENGINE_LOG_TAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, ENGINE_LOG_TAG, __VA_ARGS__))

ERROR arm-linux-androideabi-g++: error: SONAME_FLAGlibOpenCVEngine.so: No such file or directory
FIX build with -DBUILD_ANDROID_SERVICE=ON and then you get the linker error so add the following to android/service/engine/CMakeLists.txt

function(replace_compiler_option var old new)
  # Replaces a compiler option or switch `old' in `var' by `new'.
  # If `old' is not in `var', appends `new' to `var'.
  # Example: llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
  # If the option already is on the variable, don't add it:
  if( "${${var}}" MATCHES "(^| )${new}($| )" )
    set(n "")
  else()
    set(n "${new}")
  endif()
  if( "${${var}}" MATCHES "(^| )${old}($| )" )
    string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
  else()
    set( ${var} "${${var}} ${n}" )
  endif()
  set( ${var} "${${var}}" PARENT_SCOPE )
endfunction(replace_compiler_option)

replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
status("Service Engine C++ flags:" ${CMAKE_CXX_FLAGS})

ERROR from the logcat logs -
I/Sample::SurfaceView( 1446): openCamera
I/Sample::SurfaceView( 1446): releaseCamera
E/Sample::SurfaceView( 1446): Can't open camera!
FIX - In Camera.java on android - the API description says - Creates a new Camera object to access the first back-facing camera on the device. If the device does not have a back-facing camera, this returns null.
So as my tablet does not contain a back-facing camera I expect this to return NULL and thus OpenCV cant find the camera!
OpenCV Example code assumes a forward facing camera so test for more than one camera only fail if no cameras

        mNumCameras = Camera.getNumberOfCameras();
        mCamera = Camera.open();
        if ((mCamera == null) && mNumCameras < 1) {
            Log.e(TAG, "ERROR: Can't open camera!");
            return false;
        } else {
            // Try the first camera
                Log.i(TAG, "INFO:  Can't open forward facing camera!");
            mCamera = Camera.open(0);
            if (mCamera == null) {
                Log.e(TAG, "ERROR: Can't open any camera!");
                return false;
            }
        }

API required is 11 so you need to update the AndroidManifest.xml file 8->11 . this fix is applied to tutorial -0- -1- -3- & -4-. Now all the tutorials work!