如何在安卓工作室中访问带有等级的依赖项的依赖项?

我在这里错过了什么吗?我正在使用安卓工作室。我将使用共享代码库开发两个应用程序,因此我在我的Android工作室项目中制作了三个模块。一个模块是具有共享代码的库项目,另外两个是应用程序。这是一个应用程序build.gradle


apply plugin: 'com.android.application'


android {

    compileSdkVersion 26

    defaultConfig {

        applicationId "omitted"

        minSdkVersion 15

        targetSdkVersion 26

        versionCode 1

        versionName "1.0"

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

    }

    buildTypes {

        release {

            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }

    }

}


dependencies {

    implementation project(':lib')

    implementation fileTree(dir: 'libs', include: ['*.jar'])

}

这是共享模块的build.gradle


apply plugin: 'com.android.library'


android {

    compileSdkVersion 26

    defaultConfig {

        minSdkVersion 15

        targetSdkVersion 26

        versionCode 1

        versionName "1.0"

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

    }

    buildTypes {

        release {

            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }

    }

}


dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])


    implementation 'com.android.support:appcompat-v7:26.1.0'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'com.android.support.test:runner:1.0.2'

    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

我的期望是,我的应用应该有权访问共享代码模块的依赖项(例如 )。这是错的吗?我找不到任何将这些依赖项传递给依赖应用的方法。'com.android.support:appcompat-v7:26.1.0'


鸿蒙传说
浏览 138回答 1
1回答

HUWWW

答案是使用而不是在我的共享模块的依赖项中使用。apiimplementation'build.gradle即。我想要而不是api 'com.android.support:appcompat-v7:26.1.0'implementation 'com.android.support:appcompat-v7:26.1.0'得益于杰迪普·卡拉尼的评论以及如何在Android模块之间共享依赖关系但是,据我所知,没有这样的东西可以取代.testApitestImplementation
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java