搜索
您的当前位置:首页正文

Android studio 下把项目作为module导入另外一

来源:二三娱乐

1.把要导入的项目变为module

  • 把build.gradle文件下的
    apply plugin: 'com.android.application'改为:apply plugin: 'com.android.library'
    同时删除文件中的:applicationId "com.dsppa.cxg.devicecontrol"
  • 在新项目进行导入:Import module
  • 导入后可能遇到以下问题:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
  • 导入后还可能遇到:
    1.找不到R文件
    2.Attribute value must be constant
    3.错误提示:元素值必须为常量表达式
    4.错误提示:找不到符号
    这主要可能模块中使用了Butterknife导致,可以参考这篇文章解决:

2.需要注意的问题

  • module下布局文件名称最好不要跟主项目文件夹下的布局文件重名,否则会出现异常:
NoSuchFieldError: No static field listView1 of type I in class Lcom/disdemo/R$id; or its superclasses
  • 如果module下的AndroidMainfest.xml文件下有
    主项目下的AndroidMainfest.xml就要再申明了
  • 要导入的module包含其他module,导入时要一起导入主项目
Top