1. 程式人生 > >Android把專案打包成library--親測有效

Android把專案打包成library--親測有效

菜雞找了半天沒找到,找到的都是不太清楚,暫且就整理下吧

1.必要的地方。

去build.gradle中,把apply plugin:'com........application',更改為‘com.android.library’;註釋掉defaultConfig節點下的applicationId "....".

apply plugin: 'com.android.application'
//apply plugin: 'com.android.library'
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        //註釋即可
      applicationId "com.example.shibo.simplerecycleview"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
2.build,然後去新專案中嘗試使用

當你import moudle,然後他會提示你,你匯入的moudle的名字和你的相同,都叫app:(前提是你沒修改過,修改了另說);那就右鍵改名吧,改了名就好了。