軟件:Android studio 3.1.3
新建一個module
QQ截圖20180613141232.png
在mylogin中添加一個工具類ActivityUtil:
package com.nkbh.sevenday.mylogin;
import android.content.Context;
import android.content.Intent;
public class ActivityUtil {
public static void start(Context context, Class clazz){
Intent intent=new Intent();
intent.setClass(context,clazz);
context.startActivity(intent);
}
}
1.打包成jar
1.1在mylogin的build.gradle中添加下面代碼
//Copy類型
task makeJar(type: Copy) {
//刪除存在的
delete 'build/libs/mysdk.jar'
//設置拷貝的文件
from('build/intermediates/packaged-classes/debug/')
//打進jar包后的文件目錄
into('build/libs/')
//將classes.jar放入build/libs/目錄下
//include ,exclude參數來設置過濾
//(我們只關心classes.jar這個文件)
include('classes.jar')
//重命名
rename ('classes.jar', 'mysdk.jar')
}
makeJar.dependsOn(build)
//在終端執(zhí)行生成JAR包
// gradlew makeJar
注意:跟android平級的。
1.2在Android studio右邊點擊gradle按鈕,選擇mylogin中的other中的makeJar,雙擊就行了
QQ截圖20180613141944.png
QQ截圖20180613142005.png
在運行界面出現下面的成功字樣就成功了
QQ截圖20180613142354.png
成功之后可以查看到的
QQ截圖20180613142946.png
可以調用
QQ截圖20180613143709.png
2.生成aar包
QQ截圖20180613150012.png
參考:https://www.cnblogs.com/xinaixia/p/7660173.html
https://blog.csdn.net/builder_taoge/article/details/79900895
https://blog.csdn.net/g777520/article/details/53331797