Did anyone successfully build FastCV examples with Android Studio? I am having trouble with the compile.
I already put fastcv.h into ~/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm64/usr/include and libfastcv.a into ~/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm64/usr/lib. But still get the error below when I try to compile the sample code.
Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar, :app:generateDebugAndroidTestSources, :app:assembleDebug]
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:mockableAndroidJar UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:mergeDebugAndroidTestShaders
:app:compileDebugAndroidTestShaders
:app:generateDebugAndroidTestAssets
:app:mergeDebugAndroidTestAssets
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileDebugNdk
/Users/Airmada_Ian/AndroidStudioProjects/loadjpeg/app/build/intermediates/ndk/debug/obj/local/arm64-v8a/objs-debug/app//Users/Airmada_Ian/AndroidStudioProjects/loadjpeg/app/src/main/jni/loadjpeg.o: In function `Java_com_qualcomm_loadjpeg_LoadJpeg_convertToLum':
/Users/Airmada_Ian/AndroidStudioProjects/loadjpeg/app/src/main/jni/loadjpeg.cpp
Error:(133) undefined reference to `fcvMemAlloc'
Error:(139) undefined reference to `fcvMemFree'
Error:error: ld returned 1 exit status
make: *** [/Users/Airmada_Ian/AndroidStudioProjects/loadjpeg/app/build/intermediates/ndk/debug/obj/local/arm64-v8a/libapp.so] Error 1
Error:Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/Airmada_Ian/Library/Android/sdk/ndk-bundle/ndk-build'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 1.573 secs
Information:4 errors
Information:0 warnings
Information:See complete output in console
Hi,
For the compilation are you using eclipse+android studio or Gradle+android studio?
Hi,
For the compilation are you using eclipse+android studio or Gradle+android studio?
Hi Himanshu,
I am using Gradle+android studio.
Thanks
Hi Himanshu,
I am using Gradle+android studio.
Thanks
Fellows,
at the end, was it possible to use FastCV with AndroidStudio ?
thks in advance
[]s
Piaia
no I could not get it to work. I put it aside for now.
I am too trying to run the fastCV examples in Android Studio+gradle.
This is the relevant NDK build.gradle I use:
ndk {
moduleName "libfastcvsample"
def OPENGLES_DEF = "-DUSE_OPENGL_ES_2_0"
cFlags "-I\$(TARGET_OUT_HEADERS)/fastcv -I/home/frisacher/dev/android/ndk/platforms/android-21/arch-arm64/usr/include -L/home/frisacher/dev/android/ndk/platforms/android-21/arch-arm64/usr/lib \$(OPENGLES_DEF) -Wl,--no-fix-cortex-a8 -Wno-write-strings"
ldLibs "log", "GLESv2"
stl "fastcv"
abiFilter "armeabi"
}
I think that I was able to solve the static library dependency adding stl "fastcv" but build still failed
/home/frisacher/dev/android/ndk/build/core/add-application.mk
Error:(287) *** Android NDK: Aborting . Stop.
Error:Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/frisacher/dev/android/ndk/ndk-build'' finished with non-zero exit value 2
Information:BUILD FAILED
Android Studio does not import correctly the JNI part and most of the changes need to be ported from the jni/Android.mk to build.gradle
It would be good to have a fastCV example running on Android Studio as this is the only official tool chain supported by Google for a while now.
I was able to compile the fastCV demo and run it on my Android device. The app build.gradle file is below.
The key point is to disable the automatic call to ndk-build using "jni.srcDirs = []"
Some tweaks still need to be done in the Android.mk file(s) to point to your header and library file of the fastCV SDK and to get rid of some old flags not supported anymore by the latest NDK (e.g. -Wl,--no-fix-cortex-a8)
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.qualcomm.fastcorner"
minSdkVersion 22
targetSdkVersion 23
ndk {
moduleName "libfastcvsample"
abiFilter "armeabi"
}
}
sourceSets.main {
jni.srcDirs = [] //disable automatic ndk-build call
jniLibs.srcDir 'src/main/libs'
}
// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
workingDir file('src/main')
commandLine getNdkBuildCmd(), 'APP_PLATFORM=android-23'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
task cleanNative(type: Exec) {
workingDir file('src/main')
commandLine getNdkBuildCmd(), 'clean'
}
clean.dependsOn cleanNative
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
compile fileTree( dir: 'libs')
}
}
def getNdkDir() {
if (System.env.ANDROID_NDK_ROOT != null)
return System.env.ANDROID_NDK_ROOT
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkdir = properties.getProperty('ndk.dir', null)
if (ndkdir == null)
throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.")
return ndkdir
}
def getNdkBuildCmd() {
def ndkbuild = getNdkDir() + "/ndk-build"
if (Os.isFamily(Os.FAMILY_WINDOWS))
ndkbuild += ".cmd"
return ndkbuild
}
Hi All,
Steps that I took for successfully porting FastCV example to Android Studion
Hope this helps those trying to get this to work in Android Studio (I couldn't find much out there on it)
- George
I followed George's steps but I'm still having trouble getting it to work. Where are the fastcv.h and the two fastcv.a files supposed to be placed?
I've figured it out now.
I added fastcv.h to src/main/jni/fastcv/fastcv.h and put the 2 libfastcv.a files in src/main/libs/armeabi and src/main/libs/arm64-v8a.
Then I added the following to the ndk section of build.gradle file
Finally, I added this after the first line of the android.mk file:
I was also not able to use it. Needs to be debugged.
https://droidfirmware.com
I am having trouble with compilation of FastCV example with android studio.Im getting below error
Build command failed.
Error while executing process /home/usr/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/home/usr/Samplefast/app/src/main/jniLibs -B/home/usr/Samplefast/app/.externalNativeBuild/cmake/debug/armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-19 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/usr/Samplefast/app/build/intermediates/cmake/debug/obj/armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=/home/usr/Android/Sdk/ndk-bundle -DCMAKE_TOOLCHAIN_FILE=/home/usr/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/home/usr/Android/Sdk/cmake/3.6.4111459/bin/ninja -GAndroid Gradle - Ninja}
-- Check for working C compiler: /home/usr/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/usr/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/usr/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/usr/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error at CMakeLists.txt:13 (add_library):
Corner.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error: CMake can not determine linker language for target: About.cpp
-- Generating done
-- Build files have been written to: /home/usr/Samplefast/app/.externalNativeBuild/cmake/debug/armeabi-v7a
Build command failed.
Error while executing process /home/usr/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/home/usr/Samplefast/app/src/main/jniLibs -B/home/usr/Samplefast/app/.externalNativeBuild/cmake/release/armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-19 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/usr/Samplefast/app/build/intermediates/cmake/release/obj/armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=/home/usr/Android/Sdk/ndk-bundle -DCMAKE_TOOLCHAIN_FILE=/home/usr/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/home/usr/Android/Sdk/cmake/3.6.4111459/bin/ninja -GAndroid Gradle - Ninja}
-- Check for working C compiler: /home/usr/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/usr/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/usr/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/usr/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error at CMakeLists.txt:13 (add_library):
Corner.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error: CMake can not determine linker language for target: About.cpp
-- Generating done
-- Build files have been written to: /home/usr/Samplefast/app/.externalNativeBuild/cmake/release/armeabi-v7a
Hello,
I am getting below error during compilation of fastcv example with android studio.Please can anyone help me out.
Error:Execution failed for task ':app:ndkBuild'.
> Process 'command '/home/akshata/Android/Sdk/ndk-bundle/ndk-build'' finished with non-zero exit value 2
Thanks
Hi rchanda,
I'm getting same error, did you find out the problem??
C:/Dev/AndroidStudioProjects/fastcorner/app/src/main/jni/FastCVSample.cpp:494: error: undefined reference to 'fcvGetVersion'
Best Regards,