问题
settings.gradle:
include ':app'
include ':app:libraries:shinobicharts-android-library'
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.rohit2906.myhistogram"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project('libraries:shinobicharts-android-library')
}
I am trying to add library project which is shinobicharts-android-library and it is in libraries folder.Please help me with this.
回答1:
You have to define a build.gradle for each module in your project.
Also it is not a good idea to define a module inside another module.
You should have this structure:
root
app
build.gradle
libraries
shinobicharts-android-library
build.gradle
build.gradle //top level
settings.gradle
In your settings.gradle
change in:
include ':app'
include ':libraries:shinobicharts-android-library'
In your app/build.gradle
change
compile project(':libraries:shinobicharts-android-library')
In shinobicharts-android-library/build.gradle
:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 11
targetSdkVersion 21
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//...other
}
来源:https://stackoverflow.com/questions/28998627/android-studio-gradle-configuration-with-name-default-not-found-using-library