Android Studio Gradle Configuration with name 'default' not found using library project shinobicharts

删除回忆录丶 提交于 2019-12-13 08:16:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!