Issue
Hello,
I'm using the Android Studio with NDK and JNI in a project with a large amount of C++ files. When I make changes in a single C++ file it won't apply in the code unless I rebuild the whole project and refresh the entire C++ files so they have to recompile. The compilation process takes more than 3 minutes for every small change, make it 20 times a day and you have lost an hour.
According to today, after I make a change to a file I go to
Build >> Refresh Linked C++ Projects,
and then run the project, resulting in a full, redundant compilation of all files.
I'm looking for way for the compiler to refresh only the changed file, and as a result shorten the build process.
NOTE: This problem only occurs in windows, when I run Android Studio on a Mac, the compiler recompiles only the relevant files.
This is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.4.1)
FILE(GLOB CPP_SRC
"src/main/cpp/*.c"
"src/main/cpp/*.h"
"src/main/cpp/*.cpp"
"src/main/cpp/*.hpp"
)
add_library(MyLib
SHARED
${CPP_SRC} )
find_library(
log-lib
log )
target_link_libraries(
MyLib
${log-lib} )
target_link_libraries(MyLib
android
log
EGL
GLESv2)
And my gradle.build file:
apply plugin: 'com.android.library'
android {
signingConfigs {
config {
keyAlias '*****'
keyPassword '*****'
storeFile file(*****)
storePassword '*****'
}
}
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
arguments "-DANDROID_ARM_NEON=TRUE", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_shared", "-DCMAKE_BUILD_TYPE=Release", "-DANDROID_CPP_FEATURES=rtti exceptions"
cppFlags "-D__STDC_FORMAT_MACROS", '-Ofast', '-fsigned-char', "-std=c++14", "-frtti", "-fexceptions", "-mtune=arm7", "-mfpu=vfpv3-d16", "-mfloat-abi=softfp", "-Wall",
"-DCOMPILE_EUROPE_ID_AND_FACE_OCR_MANAGER",
"-DCOMPILE_FRENCH_PASSPORT_SIGNATURE",
"-DCOMPILE_FRENCH_ID_BACK_OCR",
"-DCOMPILE_FRENCH_PASSPORT_SIGNATURE_MANAGER",
"-DCOMPILE_PASSPORT_AND_FACE_OCR_MANAGER",
"-DCOMPILE_MRZ_OCR",
"-DCOMPILE_FRENCH_ID_BACK_OCR_MANAGER"
}
ndk {
abiFilters 'x86', 'armeabi-v7a'
}
}
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a'
universalApk true
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
libraryVariants.all { variant -> variant.outputs.all { output ->
outputFileName = "${"libScanovateImaging"}.aar" }
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
dependencies {
implementation 'com.google.android.gms:play-services-vision:15.0.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta6'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
}
Thanks in advance!
Solution
Finally I have found the cause to the problem.
In my project I have worked with symlink C++ files. The NDK cannot immediately apply the changes made in these files and they won't be expressed in your app unless you rebuild the whole project.
The solution is to work with hard copy files.
If I find some way to work correctly with symlink files it would be better for my needs. Until then I can at least edit single or multiple files without recompiling the whole project.
This is a relatively esoteric situation but might be helpful for someone in the future.
Answered By - Ariel Mann
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.