我在使用 gradle 构建多项目时遇到了一些问题。我阅读了所有类似的问题,但没有任何帮助。我的项目结构如下:
App/
settings.gradle
app/
build.gradle
libraries/
Core(git submodule)/
Core/
build.gradle
libraries/
ZBarLibrary/
build.gradle
settings.gradle
应用程序/settings.gradle
include ':App', ':libraries:Core', ':libraries:ZBarLibrary'
project(':libraries:Core').projectDir = new File(settingsDir, 'libraries/Core/Core')
project(':libraries:ZBarLibrary').projectDir = new File(settingsDir, 'libraries/Core/libraries/ZBarLibrary')
应用程序/应用程序/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile project(':libraries:Core')
}
应用程序/库/核心/核心/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
instrumentTestCompile "junit:junit:4.5+"
compile project(':libraries:ZBarLibrary')
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
应用程序/库/Core/libraries/ZBarLibrary/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
App目录中的命令“gradle build”产生错误:“package com...不存在”。这个包在 app 模块中使用,但它在 App/libraries/Core/Core/src/main/java 中找到。你可以帮帮我吗?