Reputation: 11
I'm using android studio version 3.3 and openCV version 4.0.1
After setting up openCV in android studio, when I run the app to check if the openCV loaded successfully, an error occurred saying 'Compilation Failed'. I checked the problem and I saw an error 'Cannot resolve symbol 'styleable'.
I already tried cleaning and rebuilding project. I also updated the sdk version of the gradle scripts.
This is my app gradle script:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.homesafe.test"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jniLibs/'] } }
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':openCVLibrary401')
}
this is my openCV gradle scripts:
android {
compileSdkVersion 28
//buildToolsVersion "x.y.z" // not needed since com.android.tools.build:gradle:3.0.0
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
sourceSets {
main {
jniLibs.srcDirs = ['../../jni']
java.srcDirs = ['src'] // TODO Use original files instead of copied into build directory
aidl.srcDirs = ['src']
res.srcDirs = ['/build/master_pack-android/opencv/modules/java/android_sdk/android_gradle_lib/res']
manifest.srcFile 'AndroidManifest.xml'
}
}
}
dependencies {
}
i don't know what's the problem here. any help? thank you so much!
Upvotes: 1
Views: 1222
Reputation: 1339
You need to replace the following line:
res.srcDirs = ['/build/master_pack-android/opencv/modules/java/android_sdk/android_gradle_lib/res']
with this:
res.srcDirs = ['res']
Upvotes: 6