Android Gradle-Can';t使用模块'的查找类;s包括lib
本项目由3个模块组成(应用程序、datecs e截击)。Android Gradle-Can';t使用模块'的查找类;s包括lib,android,gradle,Android,Gradle,本项目由3个模块组成(应用程序、datecs e截击)。datecs模块是库libs/com.datecs.api.jar之间的接口。问题是库类/包在应用程序模块中不可见 以下是gradle文件: project.gradle // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories {
datecs
模块是库libs/com.datecs.api.jar
之间的接口。问题是库类/包在应用程序模块中不可见
以下是gradle文件:
project.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
allprojects {
repositories {
google()
jcenter()
}
}
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
dependencies {
implementation files('libs/gson-2.3.1.jar')
implementation project(':volley')
implementation 'com.android.support:support-v4:21.0.3'
implementation 'com.android.support:appcompat-v7:21.0.3'
implementation project(':datecs')
}
apply plugin: 'com.android.library'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
android {
compileSdkVersion 21
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:support-v4:21.0.3'
implementation 'com.android.support:appcompat-v7:21.0.3'
testImplementation 'junit:junit:4.12'
implementation files('libs/com.datecs.api.jar')
}
allprojects {
repositories {
google()
jcenter()
}
}
app.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
allprojects {
repositories {
google()
jcenter()
}
}
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
dependencies {
implementation files('libs/gson-2.3.1.jar')
implementation project(':volley')
implementation 'com.android.support:support-v4:21.0.3'
implementation 'com.android.support:appcompat-v7:21.0.3'
implementation project(':datecs')
}
apply plugin: 'com.android.library'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
android {
compileSdkVersion 21
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:support-v4:21.0.3'
implementation 'com.android.support:appcompat-v7:21.0.3'
testImplementation 'junit:junit:4.12'
implementation files('libs/com.datecs.api.jar')
}
allprojects {
repositories {
google()
jcenter()
}
}
datecs.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
allprojects {
repositories {
google()
jcenter()
}
}
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
dependencies {
implementation files('libs/gson-2.3.1.jar')
implementation project(':volley')
implementation 'com.android.support:support-v4:21.0.3'
implementation 'com.android.support:appcompat-v7:21.0.3'
implementation project(':datecs')
}
apply plugin: 'com.android.library'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
android {
compileSdkVersion 21
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:support-v4:21.0.3'
implementation 'com.android.support:appcompat-v7:21.0.3'
testImplementation 'junit:junit:4.12'
implementation files('libs/com.datecs.api.jar')
}
allprojects {
repositories {
google()
jcenter()
}
}
如何使库类在应用程序模块中可访问?由于我无法访问您的特定库(datecs),因此我使用应用程序模块和库模块进行了测试,其中应用程序模块需要“导入”com.android中的
。支持:appcompat-v7:28.0.0'
依赖项
使用api
而不是implementation
对我来说很管用
应用程序模块的build.gradle中的依赖项关闭:
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation project(':mytestlibrary')
}
库模块的build.gradle中的依赖项关闭:
dependencies {
api 'com.android.support:appcompat-v7:28.0.0'
}
另请参见关于api的文档:
Gradle将依赖项添加到编译类路径和生成输出中。当一个模块包含一个api依赖项时,它会让Gradle知道该模块想要将该依赖项以传递方式导出到其他模块,以便它们在运行时和编译时都可以使用该依赖项