您的位置:首页 > 移动开发 > Android开发

Android Studio导入开源Library错误以及解决方案

2016-01-04 22:40 501 查看
            随着时间的流逝,Android Studio也变的越来越稳定,Google终于按耐不住,终于在2014年底发布了Android Studio 1.0正式版。开发者们,也开始跃跃欲试,体验新版本。果不其然,它也的确给了开发者不小惊喜,比如,随时布局,随时看效果,这种Eclipse就做不到,反正还有很多很多,反正我用了它之后,我就不想再回到卡慢丑的Eclipse了。还有很多功能,前段时间,爆出Android studio 2.0版,不过这是公开预览版,听说2.0速度快的惊人,特别是在android
虚拟设备上的体现,Google官方说,打开虚拟设备在越来的基础上提升了60倍,这个数字真是吓到我了,我们知道,android 模拟器打开速度慢,历来就被许多开发者所吐槽,为了解决打开虚拟设备过慢的问题,Genymotion出现了,它的虚拟设备打开真的很快。Android Studio的正式发布,新的起来,那么,作为一个外来者,Google自然是极力推行自家的IDE,就在Android Studio的正式发布后,Google也同时宣布不再对ADT进行维护,这也是我们意料之中的事情。

            上面说了那么多,那么我今天要说的是什么问题呢?这个问题就是:我们在导入开源Library时,发现总是会出这样那样的问题,问题如下: 



                 

好,首先我们看到的是Error:Plugin with id 'com.github.dcendents.android-maven' not found.问题,这个问题先不急着解决,你一看就是知道,没有在github创库找到这个,那么接下来,我们去看看这个Library中gradle文件,发现有这么一堆配置:

apply plugin: 'com.android.library'

ext {
bintrayRepo = 'maven'
bintrayName = 'swipedeck'

publishedGroupId = 'com.daprlabs.aaron'
libraryName = 'swipedeck'
artifact = 'cardstack'

libraryDescription = 'A Tinder Style card deck view for Android'

siteUrl = 'https://github.com/aaronbond/Swipe-Deck'
gitUrl = 'https://github.com/aaronbond/Swipe-Deck.git'

libraryVersion = '0.0.6'

developerId = 'aaronbond'
developerName = 'Aaron Bond'
developerEmail = 'aaron.r.bond@gmail.com'

licenseName = 'The MIT License'
licenseUrl = 'https://opensource.org/licenses/MIT'
allLicenses = ["MIT"]
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 6
versionName "0.0.6"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
首先我们去掉,apply from这两个,因为我不知道这个是什么东西,其实你了解gradle的话,你就知道是什么了?我们就先暂时不知道吧,好吗?去掉以上我说的哪两个,我们重新rebuild一下,发现了这个问题:


Gradle
syn error: configuration with name 'default' not found

这时,你可以将上面gradle文件中ext里面的内容统统删除,再重新rebuild,就解决这个问题,然而某一天,我发现去掉aplly from这个两个,在编译,发现也正常不报错了,我纳闷了,最后我就猜想,应该是国内防火墙在作祟,所以呢,如果你在导入开源项目的时候,你就可以那些访问网络库的,统统删掉,一个不留,在rebuild一下就能成功。成功之后的Library是这样的,如下图:



                                     

结束语:
我希望大家,再看的时候,如果解决了你的问题,希望您捧个场,留个脚印,谢谢!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息