您可以使用自己的类创建自己的.jar
,该类可以使用Bitmap
或任何Android API类。
这是一个文件BitmapHelper.java
package com.its.test;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class BitmapHelper {
public static void getBitmap(String fileName){
Bitmap bitmap= BitmapFactory.decodeFile(fileName);
}
}
Jar文件仅仅是具有压缩文件数量.class
文件,所以BitmapHelper.class
文件是在我的.jar
当我们需要使用.jar
只是将它加入在构建路径中进行编译。
或者在gradle这个项目把你.jar
libs
文件夹内,并以这种方式
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
编译如果在本地/远程Maven回购或其他任何使用group name
,artifact
和version
你可以编译部署了.jar
那件神器。
The main difference between a Jar and a AAR is that AARs include resources such as layouts, drawables etc. This makes it a lot easier to create self-contained visual components. For example if you have multiple apps that use the same login screen, with Jars you could share classes but not the layout, styles, etc., you still had to duplicate them. With AARs everything is bundled in one neat package.
编辑
Java库是.jar
不同,图书馆是罐子的集合。您可以轻松地将.jars
整合到android项目中,但如果您想添加Java库,则需要定义纯Java库和android之间的绑定。
你可以检查这个答案。
https://stackoverflow.com/a/42099343/3445320
'android.graphics.Bitmap'是一个Android框架类。 JAR和AAR都不会“包含”它。 “包含Bitmap类”是什么意思? – CommonsWare
你可以用自己的类创建你的jar,可以使用'Bitmap'或任何Android API类。 – Aryan
@CommonsWare意味着当我在jar文件和orid studio中的类中使用android.graphics.Bitmap时显示错误:无法解析符号'位图' –