为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

鸿蒙传说 2022-09-28 16:17:46
我在这里错过了什么吗?我正在使用安卓工作室。我将使用共享代码库开发两个应用程序,因此我在我的Android工作室项目中制作了三个模块。一个模块是具有共享代码的库项目,另外两个是应用程序。这是一个应用程序build.gradleapply 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.gradleapply 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'
查看完整描述

1 回答

?
HUWWW

TA贡献1874条经验 获得超12个赞

答案是使用而不是在我的共享模块的依赖项中使用。apiimplementation'build.gradle

即。我想要而不是api 'com.android.support:appcompat-v7:26.1.0'implementation 'com.android.support:appcompat-v7:26.1.0'

得益于杰迪普·卡拉尼的评论以及如何在Android模块之间共享依赖关系

但是,据我所知,没有这样的东西可以取代.testApitestImplementation


查看完整回答
反对 回复 2022-09-28
  • 1 回答
  • 0 关注
  • 137 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号