Android把module转为library

2018-07-12  本文已影响8人  天空在微笑


apply plugin: 'com.android.application'
改成
apply plugin: 'com.android.library'

  1. 注掉applicationId
defaultConfig {
//        applicationId "com.tencent.qcloud.suixinbo"
        minSdkVersion 17
        targetSdkVersion 22
    }
  1. 在setting.gradle中加入该library
include ':app','suixinbo'
  1. 右键主工程->open module settings->dependencies->+->module dependency

5.遇到要replace的情况:
5.1 在manifest文件中添加命名空间xmlns:tools="http://schemas.android.com/tools"

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="">

5.2 在 application标签下加入诸如

tools:replace="android:allowBackup,android:icon,android:name,android:theme"
 <application
        android:name=""
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"

        tools:replace="android:allowBackup,android:icon,android:name,android:theme">

5.3 有的需要在provider节点下加入tools:replace="android:authorities" 和tools:replace="android:resource"

<provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.superfan.houe.FileProvider"
            android:exported="false"
            android:grantUriPermissions="true"
            tools:replace="android:authorities">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/rc_file_path"
                tools:replace="android:resource"/>
        </provider>
  1. 注掉启动activity
 <!--<intent-filter>-->
                <!--<action android:name="android.intent.action.MAIN" />-->
                <!--<category android:name="android.intent.category.LAUNCHER" />-->
            <!--</intent-filter>-->
上一篇 下一篇

猜你喜欢

热点阅读