https://github.com/daemon369/android-infrastructure-application
https://github.com/daemon369/android-infrastructure-application
android kotlin
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/daemon369/android-infrastructure-application
- Owner: daemon369
- License: apache-2.0
- Created: 2021-09-03T08:03:12.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-05-05T05:47:13.000Z (about 4 years ago)
- Last Synced: 2023-08-02T07:40:00.781Z (almost 3 years ago)
- Topics: android, kotlin
- Language: Kotlin
- Homepage:
- Size: 226 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# android-infrastructure-application
## 添加依赖
`build.gradle`文件中添加:
```groovy
repositories {
mavenCentral()
}
dependencies {
implementation "io.github.daemon369:android-infrastructure-application:1.3.0"
}
```
可以在查询最新版本
## 问题
如果遇到如下错误:
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.
解决方法:
```gradle
// 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
...
```
#### 使用自定义`Application`继承`me.daemon.infrastructure.application.InfrastructureApp`类
```kotlin
package me.daemon.infrastructure.application.demo
import me.daemon.infrastructure.application.InfrastructureApp
class DemoApplication : InfrastructureApp() {
}
```
#### 应用
```kotlin
fun getString(@StringRes strId: Int): String {
return application.getString(strId)
}
```