depending_imported_app2声明了从配置“ releaseCompile”到配置“ release”的依赖关系,该依赖关系未在描述符中声明

时间:2018-12-28 17:06:55

标签: android tensorflow gradle module

我已经克隆了https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android Tensorflow示例应用程序,并通过导入两个模块集成了其中两个模块(其中imported_app2对imported_app1有一些依赖性)。我的settings.gradle如下所示:

包括':imported-app1',':depending_imported_app2'

我的问题是Android Studio声称

无法解决':depending_imported_app2 @ debug / compileClasspath'的依赖项:无法解决项目:imported_app1。

如果我再次构建,则会收到错误消息: 项目:depending_imported_app2声明了从配置'releaseCompile'到配置'release'的依赖关系,该依赖关系未在项目:imported_app1的描述符中声明。

以下是imported_app1的build.gradle:

/*
 * Copyright 2017, Pavel Kryl
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'

android {
    compileSdkVersion Integer.parseInt(project.SDK_VERSION_TARGET)
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
    publishNonDefault true

    defaultConfig {
        minSdkVersion Integer.parseInt(project.SDK_VERSION_MIN)
        targetSdkVersion Integer.parseInt(project.SDK_VERSION_TARGET)
        // we will keep this the same regardless of the app version code/name
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
        }
    }
    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:25.1.0'
    testCompile 'junit:junit:4.12'
    // guava
    compile 'com.google.guava:guava:19.0'
    // intellij annotations
    compile 'com.intellij:annotations:12.0'


}

这是取决于_imported_app2的build.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion Integer.parseInt(project.SDK_VERSION_TARGET)
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
    publishNonDefault true

    defaultConfig {
        minSdkVersion Integer.parseInt(project.SDK_VERSION_MIN)
        targetSdkVersion Integer.parseInt(project.SDK_VERSION_TARGET)
        versionCode 1
        versionName "1.0"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        debug {
            minifyEnabled false
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    // uses LayoutDirectionUtil
    releaseCompile project(path: ':imported_app1', configuration: 'release')
    debugCompile project(path: ':imported_app1', configuration: 'debug')

这是周围的tensorflow项目的常规和软件包范围的build.gradle:

// This file provides basic support for building the TensorFlow demo
// in Android Studio with Gradle.
//
// Note that Bazel is still used by default to compile the native libs,
// and should be installed at the location noted below. This build file
// automates the process of calling out to it and copying the compiled
// libraries back into the appropriate directory.
//
// Alternatively, experimental support for Makefile builds is provided by
// setting nativeBuildSystem below to 'makefile'. This will allow building the demo
// on Windows machines, but note that full equivalence with the Bazel
// build is not yet guaranteed. See comments below for caveats and tips
// for speeding up the build, such as enabling ccache.
// NOTE: Running a make build will cause subsequent Bazel builds to *fail*
// unless the contrib/makefile/downloads/ and gen/ dirs are deleted afterwards.

// The cmake build only creates libtensorflow_demo.so. In this situation,
// libtensorflow_inference.so will be acquired via the tensorflow.aar dependency.

// It is necessary to customize Gradle's build directory, as otherwise
// it will conflict with the BUILD file used by Bazel on case-insensitive OSs.
project.buildDir = 'gradleBuild'
getProject().setBuildDir('gradleBuild')

buildscript {
    repositories {
        jcenter()
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'org.apache.httpcomponents:httpclient:4.5.4'

        classpath 'me.tatarka:gradle-retrolambda:3.6.1'
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
    }
}

allprojects {

    repositories {
        jcenter()
        google()
        maven { url 'https://maven.google.com' }
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
    }
}




// set to 'bazel', 'cmake', 'makefile', 'none'
def nativeBuildSystem = 'none'

// Controls output directory in APK and CPU type for Bazel builds.
// NOTE: Does not affect the Makefile build target API (yet), which currently
// assumes armeabi-v7a. If building with make, changing this will require
// editing the Makefile as well.
// The CMake build has only been tested with armeabi-v7a; others may not work.
def cpuType = 'armeabi-v7a'

// Output directory in the local directory for packaging into the APK.
def nativeOutDir = 'libs/' + cpuType

// Default to building with Bazel and override with make if requested.
def nativeBuildRule = 'buildNativeBazel'
def demoLibPath = '../../../bazel-bin/tensorflow/examples/android/libtensorflow_demo.so'
def inferenceLibPath = '../../../bazel-bin/tensorflow/contrib/android/libtensorflow_inference.so'

// Override for Makefile builds.
if (nativeBuildSystem == 'makefile') {
    nativeBuildRule = 'buildNativeMake'
    demoLibPath = '../../../tensorflow/contrib/makefile/gen/lib/android_' + cpuType + '/libtensorflow_demo.so'
    inferenceLibPath = '../../../tensorflow/contrib/makefile/gen/lib/android_' + cpuType + '/libtensorflow_inference.so'
}

// If building with Bazel, this is the location of the bazel binary.
// NOTE: Bazel does not yet support building for Android on Windows,
// so in this case the Makefile build must be used as described above.
def bazelLocation = '/usr/local/bin/bazel'

// import DownloadModels task
project.ext.ASSET_DIR = projectDir.toString() + '/assets'
project.ext.TMP_DIR   = project.buildDir.toString() + '/downloads'

apply plugin: 'com.android.application'

android {

    lintOptions {
        disable 'ValidFragment'
        checkReleaseBuilds false
    }
    compileSdkVersion 23
    buildToolsVersion '26.0.2'

    if (nativeBuildSystem == 'cmake') {
        defaultConfig {
            applicationId = 'org.tensorflow.demo'
            minSdkVersion 21
            targetSdkVersion 23
            ndk {
                abiFilters "${cpuType}"
            }
            externalNativeBuild {
                cmake {
                    arguments '-DANDROID_TOOLCHAIN=gcc', '-DANDROID_STL=gnustl_static'
                }
            }
        }
        externalNativeBuild {
            cmake {
                path './jni/CMakeLists.txt'
            }
        }
    }

    lintOptions {
        abortOnError false
    }

    sourceSets {
        main {
            if (nativeBuildSystem == 'bazel' || nativeBuildSystem == 'makefile') {
                // TensorFlow Java API sources.
                java {
                    srcDir '../../java/src/main/java'
                    exclude '**/examples/**'
                }

                // Android TensorFlow wrappers, etc.
                java {
                    srcDir '../../contrib/android/java'
                }
            }
            // Android demo app sources.
            java {
                srcDir 'src'
            }

            manifest.srcFile 'AndroidManifest.xml'
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = [project.ext.ASSET_DIR]
            jniLibs.srcDirs = ['libs']
        }

        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

task buildNativeBazel(type: Exec) {
    workingDir '../../..'
    commandLine bazelLocation, 'build', '-c', 'opt',  \
         'tensorflow/examples/android:tensorflow_native_libs',  \
         '--crosstool_top=//external:android/crosstool',  \
         '--cpu=' + cpuType,  \
         '--host_crosstool_top=@bazel_tools//tools/cpp:toolchain'
}

task buildNativeMake(type: Exec) {
    environment "NDK_ROOT", android.ndkDirectory
    // Tip: install ccache and uncomment the following to speed up
    // builds significantly.
    // environment "CC_PREFIX", 'ccache'
    workingDir '../../..'
    commandLine 'tensorflow/contrib/makefile/build_all_android.sh',  \
         '-s',  \
         'tensorflow/contrib/makefile/sub_makefiles/android/Makefile.in',  \
         '-t',  \
         'libtensorflow_inference.so libtensorflow_demo.so all'  \
         , '-a', cpuType  \
         //, '-T'  // Uncomment to skip protobuf and speed up subsequent builds.
}


task copyNativeLibs(type: Copy) {
    from demoLibPath
    from inferenceLibPath
    into nativeOutDir
    duplicatesStrategy = 'include'
    dependsOn nativeBuildRule
    fileMode 0644
}

tasks.whenTaskAdded { task ->
    if (nativeBuildSystem == 'bazel' || nativeBuildSystem == 'makefile') {
        if (task.name == 'assembleDebug') {
            task.dependsOn 'copyNativeLibs'
        }
        if (task.name == 'assembleRelease') {
            task.dependsOn 'copyNativeLibs'
        }
    }
}

// Download default models; if you wish to use your own models then
// place them in the "assets" directory and comment out this line.
apply from: "download-models.gradle"


dependencies {
    if (nativeBuildSystem == 'cmake' || nativeBuildSystem == 'none') {
        compile 'org.tensorflow:tensorflow-android:+'
    }
}



buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'me.tatarka:gradle-retrolambda:3.6.1'
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
    }
}



task appGdriveDebugUpload(type: Exec, dependsOn: ':app:assembleDebug') {
    File file = new File("./app/build/outputs/apk/app-debug.apk")

    commandLine 'gdrive', 'upload', '-p', '0B5vy2-8fNTkpRkV6ZlpwamtQNFU',
            '--name', "ArgoManager-${file.lastModified()}-${rootProject.APP_VERSION_NAME}-v${rootProject.APP_VERSION_CODE}-debug.apk", "./app/build/outputs/apk/app-debug.apk"

}

task appGdriveReleaseUpload(type: Exec, dependsOn: ':app:assembleRelease') {
    File file = new File("./app/build/outputs/apk/app-release.apk")

    commandLine 'gdrive', 'upload', '-p', '0B5vy2-8fNTkpRkV6ZlpwamtQNFU',
            '--name', "ArgoManager-${file.lastModified()}-${rootProject.APP_VERSION_NAME}-v${rootProject.APP_VERSION_CODE}-release.apk", "./app/build/outputs/apk/app-release.apk"

}

我完全不知道为什么我不能访问其他模块。

0 个答案:

没有答案