当前位置: 代码迷 >> Android >> 请问android studio的依赖有关问题
  详细解决方案

请问android studio的依赖有关问题

热度:23   发布时间:2016-04-27 22:31:10.0
请教android studio的依赖问题
本帖最后由 lpw32682770 于 2015-10-26 22:49:13 编辑
在Android Studio中,如果一个project有多个module,其中有两个Module都依赖某个jar包。这样编译的时候会报错。
请问这种情况该怎么处理,难道Android studio不允许两个Module依赖相同的jar包吗。

后来我换了一种做法,就是把这两个Module中的一个编译成aar,然后再添加进Project中,结果编译通过了,但是运行却报错。
以下是错误日志:
10-26 22:49:05.073    8676-8676/sumcoa.med.stu.edu.cn.sumcoa E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: sumcoa.med.stu.edu.cn.sumcoa, PID: 8676
    java.lang.NoClassDefFoundError: com.squareup.picasso.Picasso
            at com.daimajia.slider.library.SliderTypes.BaseSliderView.bindEventAndShow(BaseSliderView.java:210)
            at com.daimajia.slider.library.SliderTypes.TextSliderView.getView(TextSliderView.java:25)
            at com.daimajia.slider.library.SliderAdapter.instantiateItem(SliderAdapter.java:81)
            at com.daimajia.slider.library.Tricks.InfinitePagerAdapter.instantiateItem(InfinitePagerAdapter.java:54)
            at com.daimajia.slider.library.Tricks.ViewPagerEx.addNewItem(ViewPagerEx.java:848)
            at com.daimajia.slider.library.Tricks.ViewPagerEx.populate(ViewPagerEx.java:998)
            at com.daimajia.slider.library.Tricks.ViewPagerEx.populate(ViewPagerEx.java:930)
            at com.daimajia.slider.library.Tricks.ViewPagerEx.onMeasure(ViewPagerEx.java:1453)
            at android.view.View.measure(View.java:16654)
            at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
            at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
            at android.view.View.measure(View.java:16654)
            at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
            at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
            at android.view.View.measure(View.java:16654)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5150)
            at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
            at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
            at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
            at android.view.View.measure(View.java:16654)
            at android.widget.ListView.setupChild(ListView.java:1971)
            at android.widget.ListView.makeAndAddView(ListView.java:1894)
            at android.widget.ListView.fillDown(ListView.java:792)
            at android.widget.ListView.fillFromTop(ListView.java:853)
            at android.widget.ListView.layoutChildren(ListView.java:1731)
            at android.widget.AbsListView.onLayout(AbsListView.java:2275)
            at android.view.View.layout(View.java:14963)
            at android.view.ViewGroup.layout(ViewGroup.java:4656)
            at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
            at android.view.View.layout(View.java:14963)
            at android.view.ViewGroup.layout(ViewGroup.java:4656)
            at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1627)
            at android.view.View.layout(View.java:14963)
            at android.view.ViewGroup.layout(ViewGroup.java:4656)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
            at android.view.View.layout(View.java:14963)
            at android.view.ViewGroup.layout(ViewGroup.java:4656)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14963)
            at android.view.ViewGroup.layout(ViewGroup.java:4656)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
            at android.view.View.layout(View.java:14963)
            at android.view.ViewGroup.layout(ViewGroup.java:4656)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14963)
            at android.view.ViewGroup.layout(ViewGroup.java:4656)
            at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2148)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1860)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1076)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5913)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:807)
            at android.view.Choreographer.doCallbacks(Choreographer.java:601)
            at android.view.Choreographer.doFrame(Choreographer.java:562)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreog
请有经验的朋友指点一下,不胜感激。

最近被android studio搞到头都大了,各种奇奇怪怪的错误层出不穷,而且因为人在墙内,编译经常需要翻墙下载各种东西,就算翻墙,也是速度巨慢。而且anroid studio占用很大的CPU和内存,经常卡机。
人生真是艰难...
------解决思路----------------------
compileSdkVersion和buildToolsVersion 改为如下版本

compileSdkVersion 22
buildToolsVersion "22.0.1"

targetSdkVersion版本改为
targetSdkVersion 22

compile 'com.android.support:appcompat-v7:23.1.0'改为
compile 'com.android.support:appcompat-v7:22.2.1'

修改后重新跑一下
  相关解决方案