不知为何,或许是umeng开发人员很懒,只提供eclipse下的lib工程 和 库文件,让一些刚用Android studio的童鞋们有点不知所措,首先教大家将lib工程 导入as
在umeng官方网站添加应用,选择要添加的分享渠道后,下载其生成的sdk包,里面有个social_sdk_library_project就是lib工程了。next—————分割
打开as,点击 file—–new —–new module ——–import eclipse ADT Project,选择social_sdk_library_project,完成导入。
在你的项目中添加social_sdk_library_project为你的主module的依赖。
先别着急添加代码,build一下试试,出现下面错误
Error:Execution failed for task ‘:app:transformClassesWithJarMergingForDebug’.
据说是 方法超限,早期android使用DexOpt对Dex进行优化时,使用short类型保存方法id,导致方法id不能超过65536。
搞定它
build.gradle文件的 defaultConfig中添加 multiDexEnabled true
再次build,又出错了
Error:Execution failed for task ‘:app:transformClassesWithJarMergingForDebug’.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/FragmentTransaction.class
一目了然,v4包重复了,删掉social_sdk_library_project工程下 lib文件夹里的v4包
搞定。之后按照官网的步骤添加代码就OK