Skip to content

ShaoqiangPei/AndroidLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

库引用说明

在自己项目的project对应的build.gradle里面添加如下代码:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
			maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
		}
	}

在你项目的app_module对应的build.gradle里面引用此库(以1.1.0版本为例),如下:

  android {

     //此项配置也要添加
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
  }

  dependencies {
      implementation 'com.github.ShaoqiangPei:AndroidLibrary:1.1.0'
  }

在你的项目中自定义一个Application,然后在你的自定义ApplicationonCreate()中进行初始化,类似如下:

/**
 * Title:自定义application
 * description:
 * autor:pei
 * created on 2020/1/9
 */
public class AppContext extends Application {

    private static AppContext instance;

    public static synchronized AppContext getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        //初始化AndroidLibrary
        LibraryConfig.getInstance().init(this)
                //开启log调试,默认为关闭状态
                .setDebug(true)
		//是否打印设备屏幕信息,默认false
                //必须在setDebug之后调用,且当setDebug(true)时,setShowScreenInfo(true)才生效
                .setShowScreenInfo(true);
                
    }

}

在你项目的mainfast.xml中声明自己的application,类似如下:

 <application
        android:name=".AppContext"//声明自己的Application
	//以下省略
        //......
        >
    //此处省略
    //......

  </application>

使用说明

库引用说明记载的是最新版本的引用,若你使用的不是最新版本,请留意迭代说明上的迭代历程,以帮助你迅速接入你想使用的版本 本库引入你项目以后,若要了解各模块使用详细,请参见使用说明索引