其他相关文章:
android之LifeCycle:https://blog.youkuaiyun.com/li6472/article/details/119795952?spm=1001.2014.3001.5501
android之LiveData:https://blog.youkuaiyun.com/li6472/article/details/119784791?spm=1001.2014.3001.5501
android之MVVM框架使用之xml详解:https://blog.youkuaiyun.com/li6472/article/details/119782825?spm=1001.2014.3001.5501
android之MVVM框架使用之BaseObservable与双向绑定MVVM框架使用之BaseObservable与双向绑定:https://blog.youkuaiyun.com/li6472/article/details/119782825?spm=1001.2014.3001.5501
android之MVVM理解:https://blog.youkuaiyun.com/li6472/article/details/119762190?spm=1001.2014.3001.5501
amdroid之MVVM写一个简单的程序:https://blog.youkuaiyun.com/li6472/article/details/119761806?spm=1001.2014.3001.5501
报错
(Default interface methods are only supported starting with Android N (--min-api 24): void androidx.lifecycle.DefaultLifecycleObserver.onCreate(androidx.lifecycle.LifecycleOwner))
Default interface methods are only supported starting with Android N (--min-api 24): void androidx.lifecycle.DefaultLifecycleObserver.onCreate(androidx.lifecycle.LifecycleOwner)
解释:
意思是 最小api应为24(原APP只适配 8.0以上的设备)
因为没有指定jdk 1.8
build:gradle 中的android 下添加 指定jdk版本的代码
......
//指定jdk版本
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
原build:gradle 中
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.why.project.demo"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}