转:怎么合并2个project android studio

转载自: https://blog.csdn.net/u014772414/article/details/51194952

方法一:直接把相关文件夹和类复制过来,资源等都复制过来,修改相应的Manifest.xml,各种资源包

方法二:将其中一个project当成library,导入到另一个工程中,这样就不用考虑各种文件的复制修改了

https://zhidao.baidu.com/question/1371001088247490939.html

Android Studio 中创建一个Library 的module 和导入一个Library项目:

今天教大家如何用Android studio导入Liabrary并引用。

以导入XListView为例子。

先从github官网下载XListView。

然后File–>New–>Import Module
在这里插入图片描述
选择Import Module

找到下载的xListView目录

在这里插入图片描述
在这里插入图片描述
然后就导入成了Module。

build.gradle这个文件可能会有问题,自己解决一下。

无非就是compileSdkVersion和buildToolsVersion不对之类的问题。

然后把build.gradle(注意是Module:xListVie这个build.gradle)这个文件的第一行:

apply plugin: ‘com.android.application’

修改为

apply plugin: ‘com.android.library’

然后去掉defaultConfig中的

applicationId “com.dzzchao.demo”

然后Sync Project

现在就差不多了,不过还差最后一步,打开项目的Project Structure.
在这里插入图片描述

Dependencies

在这里插入图片描述
点击+号,选择Module dependency

在这里插入图片描述
选择我们刚才导入的xListView

在这里插入图片描述
点击OK,大功告成
在这里插入图片描述

现在就可以开心的使用xListView了。

重要一步:会出现Error:Dependency MyCalendarDemo-master:app1:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: D:\AndroidEx\a2\MyCalendarDemo-master\app1\build\outputs\apk\app1-release-unsigned.apk

在这里插入图片描述

1.applyplugin:'com.android.library’修改

2.applicationId "com.miao"去掉

猜你喜欢

转载自blog.csdn.net/shijx190221/article/details/89211513