0

我目前正在尝试使用 openimaj Java 库中的依赖项构建一个 android studio 项目。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.mapinguari.myapplication"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'org.openimaj:openimaj:1.3.1'
}

是我的模块构建文件。同步到 IDE 时不会报告错误。

但是,当我尝试在其中一个源文件中构造任何类时,Android Studio 无法识别 openimaj 依赖项中的任何类。

非常感谢任何帮助。

谢谢!

4

1 回答 1

2

我认为这可能是因为您指定了一个非 jar OpenIMAJ 依赖项(特别是您告诉它链接到 OpenIMAJ 主 pom 文件,该文件仅包含对不同子模块的引用)。您可能需要实际选择所需的特定模块 - 例如,如果您的应用程序正在进行图像处理,则添加依赖项org.openimaj:image-processing:1.3.1

编辑: 似乎 batik svg 库在某个地方有一个循环依赖,这会破坏 Gradle(请参阅https://issues.apache.org/jira/browse/BATIK-1098)。这就是导致最终StackOverflowError. 此外,xml-apis 中的某些东西会与 Android 发生冲突。假设您不介意没有 SVG 图像支持,那么以下应该可以工作:

repositories {
    mavenCentral()
    maven {
        url "http://maven.openimaj.org"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:18.+'
    compile('org.openimaj:image-processing:1.3.1') {
        exclude group: 'org.apache.xmlgraphics'
        exclude group: 'xml-apis'
    }
}

您可能还想为您的应用程序中不需要的依赖项添加额外的排除项 - 似乎只包含org.openimaj:image-processing许多几乎可以肯定不需要的东西(我在这里创建了一个问题:https: //github.com/openimaj/openimaj/issues/97)。

于 2015-11-02T16:54:11.427 回答