使用库项目shinobicharts找不到名为“default”的Android Studio Gradle配置

时间:2015-03-11 22:30:46

标签: android gradle android-gradle build.gradle

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')
}

我正在尝试添加库项目,这是shinobicharts-android-library,它位于库文件夹中。请帮助我。

1 个答案:

答案 0 :(得分:1)

您必须为项目中的每个模块定义build.gradle。

在另一个模块中定义模块也不是一个好主意。

你应该有这样的结构:

root
  app
    build.gradle
  libraries
    shinobicharts-android-library
       build.gradle
  build.gradle   //top level
  settings.gradle

settings.gradle更改:

include ':app'
include ':libraries:shinobicharts-android-library'

app/build.gradle更改

compile project(':libraries:shinobicharts-android-library')

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
}