Skip to content

daemon369/android-infrastructure-application

Repository files navigation

android-infrastructure-application

添加依赖

build.gradle文件中添加:

repositories {
    mavenCentral()
}

dependencies {
    implementation "io.github.daemon369:android-infrastructure-application:1.3.0"
}

可以在https://mvnrepository.com/artifact/io.github.daemon369/android-infrastructure-application查询最新版本

问题

如果遇到如下错误:

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
Adding support for Java 8 language features could solve this issue.

解决方法:

// build.gradle
android {
    // ...
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

功能介绍

通用Application实现,应用使用InfrastructureApp或其子类来作为自定义Application时,可以简化基础支持库的很多功能的使用

使用

使用AndroidManifest.xml设置为默认Application实现:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="me.daemon.infrastructure.application.demo">

    <application
        android:name="me.daemon.infrastructure.application.InfrastructureApp">
        ...
    </application>

</manifest>

使用自定义Application继承me.daemon.infrastructure.application.InfrastructureApp

package me.daemon.infrastructure.application.demo

import me.daemon.infrastructure.application.InfrastructureApp

class DemoApplication : InfrastructureApp() {
}

应用

fun getString(@StringRes strId: Int): String {
    return application.getString(strId)
}

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages