在Android Studio中添加Caldroid库

Olk*_*afa 1 android android-studio caldroid

在Android Studio上添加Caldroid库时遇到问题.我尝试了许多不同的添加方法,但它不起作用.我使用的是Android Studio 0.8.2.

  • 首先,我创建了一个名为的根文件夹libraries.
  • 我创建了一个新的文件夹caldroid/libraries.
  • 然后,我将下载的文件粘贴到文件/libraries夹中.
  • 然后,我更改了以下文件.

settings.gradle

include ':app'
include 'libraries:caldroid:library'
Run Code Online (Sandbox Code Playgroud)

的build.gradle

dependencies {
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.google.android.gms:play-services:4.0.30'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':libraries:caldroid:library')
}
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误:

Error:Configuration with name 'default' not found.
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题?

Rav*_*ran 5

我迟到但我遇到了类似的问题,所以我想我会分享我是如何解决它的.

要将外部库导入Android Studio,我遵循以下约定:

  1. libsapp目录中创建文件夹.然后将所需的库文件复制到该libs文件夹.例如,我的文件夹包含actionbarsherlockcaldroid文件夹.
  2. Caldroid有一个可以在这里下载的库依赖项,你可以在build.gradle文件中看到它(另外,确保gradle文件具有正确的SDK版本).下载hirondelle-date4j-1.5.1-sources.jar.
  3. 在中创建libs文件夹app/libs/caldroid/.复制hirondelle-date4j-1.5.1-sources.jarapp/libs/caldroid/libs/.您可能还需要复制android-support-v4.jar-User_Home-/Android/Sdk/extras/android/support/v4/app/libs/caldroid/libs/.
  4. 打开app/libs/caldroid/build.gradle并替换compile 'com.darwinsys:hirondelle-date4j:1.5.1'compile files('libs/hirondelle-date4j-1.5.1-sources.jar').
  5. 在Android Studio中,打开settings.gradle并添加此行include ':app:libs:caldroid'.接下来,打开" build.gradle(模块:应用程序)",并加入这一行compile project(':app:libs:caldroid')dependencies.

就是这样,现在让gradle"同步"或清理并构建你的项目.