2

我按照此处的分步指南进行操作: https ://www.codeproject.com/Articles/840623/Android-Character-Recognition

在第 2 步,当我将 tess-two 作为模块依赖项添加到应用程序并同步 gradle 时,它​​失败并出现以下错误:

错误:项目:应用程序声明了从配置“编译”到配置“默认”的依赖关系,该依赖关系未在项目的描述符中声明:库:tess-two。

我已经尝试了许多 settings.gradle 的组合并搜索了几个小时,任何帮助将不胜感激,谢谢!

tess-two 下的 build.gradle 文件

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        consumerProguardFiles 'proguard-rules.pro'
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
            jni.srcDirs = []
            jniLibs.srcDirs = ['libs']
        }
    }

    // Call external ndk-build(.cmd) script to build the native code
    task ndkBuild(type: Exec) {
        def ndkDirProperty = properties.getProperty('ndk.dir')
        def ndkDirPrefix = ndkDirProperty != null ? ndkDirProperty + '/' : ''

        def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : ""

        commandLine "${ndkDirPrefix}ndk-build${ndkBuildExt}", '-C', file('.').absolutePath,
                '-j', Runtime.runtime.availableProcessors()
    }

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn ndkBuild
    }

    // Cleanup task to remove previously generated binaries
    task ndkClean(type: Exec) {
        def ndkDirProperty = properties.getProperty('ndk.dir')
        def ndkDirPrefix = ndkDirProperty != null ? ndkDirProperty + '/' : ''

        def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : ""

        commandLine "${ndkDirPrefix}ndk-build${ndkBuildExt}", '-C', file('.').absolutePath, 'clean'
    }

    tasks.withType(Delete) {
        cleanTask -> cleanTask.dependsOn ndkClean
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':libraries:tess-two')
}


// Settings for uploading module AAR to Bintray for library distribution

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    failOnError = false
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    options {
        links "http://docs.oracle.com/javase/7/docs/api/"
        linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference"
    }
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives javadocJar
    archives sourcesJar
}

install {
    repositories.mavenInstaller {
        pom.project {
            name = 'tess-two'

            packaging = 'aar'
            groupId = 'com.rmtheis'
            artifactId = 'tess-two'

            developers {
                developer {
                    id = 'rmtheis'
                    name = 'Robert Theis'
                    email = 'robert.m.theis@gmail.com'
                }
            }
            licenses {
                license {
                    name = 'The Apache Software License, Version 2.0'
                    url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    distribution = 'repo'
                }
            }
            scm {
                url 'https://github.com/rmtheis/tess-two'
            }
        }
    }
}

bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = 'maven'
        name = 'tess-two'
        userOrg = user
        publish = true
    }
}

设置.gradle

include ':app'
include ':libraries:tess-two'
include 'app:libraries:tess-two'
project(':libraries:tess-two').projectDir = new File('libraries/tess-two')
4

0 回答 0