C++로 OpenCV 프로젝트를 만들고 Android 기기에서 실행하려고합니다. 내 안드로이드 프로젝트를 설정하여 원시 코드를 성공 시키려고 시도했다.Android Studio에서 OpenCV 네이티브 코드 사용
오류 : (23,0) Gradle을의 DSL 방법을 찾을 수 없습니다 : 나는 현재이 오류에 직면하고있다 '(컴파일)을'
나는 기초로 OpenCV의 네이티브 안드로이드 개발을위한 다음 github의 샘플을 사용 : https://github.com/jlhonora/opencv-android-sampleupdated project properties to look like this:
ndk.dir=C\:\\Android\\sdk\\ndk-bundle
sdk.dir=C\:\\Android\\sdk
opencv.dir=C\:\\Android\\OpenCV-android-sdk
0,123,516 :Imported {OpenCV_DIR}\sdk\java as a module and added it as a module dependency in the project structure settings
지금까지 나는 시도하고 제대로의 SyncE하는 Gradle을 얻기 위해 다음과 같은 짓을
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "org.honorato.opencvsample"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}
ndk {
moduleName = "native"
cppFlags.add("-I${file(getOpenCVDir())}".toString())
cppFlags.add("-frtti")
cppFlags.add("-fexceptions")
ldLibs.addAll(["log", "opencv_java3"])
stl = "gnustl_static"
}
}
android.buildTypes {
release {
// minifyEnabled = false
// proguardFiles = getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
android.productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" @
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters.add("armeabi")
ndk.ldFlags.add("-L${file('src/main/jniLibs/armeabi')}".toString())
}
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
ndk.ldFlags.add("-L${file('src/main/jniLibs/armeabi-v7a')}".toString())
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
ndk.ldFlags.add("-L${file('src/main/jniLibs/arm64-v8a')}".toString())
}
}
}
def getOpenCVDir() {
Properties properties = new Properties()
properties.load(new File(rootDir.absolutePath + "/local.properties").newDataInputStream())
def externalModuleDir = properties.getProperty('opencv.dir', null)
if (externalModuleDir == null) {
throw new GradleException(
"OpenCV location not found. Define location with opencv.dir in the local.properties file!")
}
return externalModuleDir
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':openCVLibrary300')
}
그리고 마지막으로, OpenCV의 라이브러리의 build.gradle :
다음buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.7.0-beta1'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
dependencies {
compile project(':OpenCVLib')
}
프로젝트의 build.gradle입니다 :
이것은 OpenCV의 샘플 마스터 \의 build.gradle입니다
apply plugin: 'com.android.library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':{DIR}:workspace:appcompat_v7')
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
누군가가이 문제에 대해 도움을 줄 수 있고 opencv로 원시 안드로이드 개발을 시작하는 방법을 알고 있으면 매우 감사하겠습니다!
나는 안드로이드 프로그래밍에 상당히 익숙하다. 내 gradle 파일을 0.7.0으로 어떻게 바꿀 수 있는지 말해 줄 수 있습니까? "classpath 'com.android.tools.build : gradle-experimental:07.0-beta1'"줄은 프로젝트 및 모든 모듈을 컴파일하는 데 gradle 버전 0.7.0이 사용되었다고 가정했습니다. –