[英]Android Java: BoofCV Integration Problems
我知道這些問題在這里被問了很多次,但提供的解決方案都沒有幫助。
我最近嘗試使用 Gradle 將 BoofCV 添加到我的 Android Studio 項目中:
apply plugin: 'com.android.application'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.as.recognize2"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.1.1'
compile group: "org.boofcv", name: "all", version: "0.26"
compile group: "org.boofcv", name: "android", version: "0.26"
testCompile 'junit:junit:4.12'
}
這就是我的 build.gradle (app) 的樣子。
Gradle Sync 成功,但“運行應用程序” - 構建失敗給我這樣的錯誤,我從另一個問題中選擇了這樣的錯誤,因為我在我的項目中進行了很多更改,將其改回將非常困難。
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(org.apache.log4j.chainsaw.ControlPanel$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
我收到了大量這些錯誤而且我不會忽略 proguard 配置中的內部類屬性。 由於這些錯誤,構建需要數小時。
然后我從 Boof-CV-Site 下載了所有 Jar - 文件並將它們嵌入到 libs 文件夾中,並注釋掉了使用 maven 下載 boofcv 的編譯命令。 結果:
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
正如您在頁面頂部看到的,我已經實現了它。 但是我不能使用 java 插件,因為我已經在使用 Android.Application 插件了。 並且切換回 Java 7 將不起作用,因為新的 Android Studio 2.2.3 不支持它。
現在我下載了源代碼並通過使用 File->New->New Module->Import Gradle 並導航到源代碼build.gradle
來嵌入它們。 但是它包含很多構建 gradle,它們都不知道idea命令,並且都不包含apply plugin: "java"命令,因此無法使用 compile 函數。 所以我必須手動編輯每個 build.gradle(許多 build.gradle)。
如何在 Android Studio 2.2.3 或更高版本中清楚地安裝 Boofcv?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.