我在这里错过了什么吗?我正在使用安卓工作室。我将使用共享代码库开发两个应用程序,因此我在我的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个赞
答案是使用而不是在我的共享模块的依赖项中使用。api
implementation
'build.gradle
即。我想要而不是api 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
得益于杰迪普·卡拉尼的评论以及如何在Android模块之间共享依赖关系
但是,据我所知,没有这样的东西可以取代.testApi
testImplementation
添加回答
举报
0/150
提交
取消