无法从AAR中解决传递性Gradle缺陷

时间:2019-04-04 05:49:09

标签: android android-gradle android-library android-module

我制作了一个自定义模块,并使用“ api”配置在其中包含了tensorflow-lite依赖项。我建立它的aar。现在,我创建一个新项目并将aar放在libs文件夹中。但是我只能访问我创建的类,而不能访问tensorflow api。如何在不再次包含传递依赖的情况下使用传递依赖?

我在博客(https://medium.com/mindorks/implementation-vs-api-in-gradle-3-0-494c817a6fa)中读到时,已经用“ api”代替了“实现”。

build.gradle(Module:mylib)

apply plugin: 'com.android.library'
android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 24
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    aaptOptions{
        noCompress "tflite"
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    api 'androidx.appcompat:appcompat:1.1.0-alpha04'
    api 'org.tensorflow:tensorflow-lite:0.0.0-gpu-experimental'
}

build.gradle(模块:新项目中的两个):

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 24
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static'
                cppFlags "-std=c++11", "-frtti", "-fexceptions"
            }
        }
        ndk {
            abiFilters 'armeabi-v7a'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    aaptOptions {
        noCompress "tflite"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
}

repositories {
    maven { url 'https://google.bintray.com/tensorflow' }
    flatDir {
        dirs 'libs'
    }
    mavenCentral()
}

dependencies {
    api fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
    api project(':openCVLibrary341')
    api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

0 个答案:

没有答案