Android 7(API 24)环境下替代Data Binding/LiveData的方案咨询
Android 7(API 24)环境下替代Data Binding/LiveData的方案咨询
我现在遇到了版本限制的棘手问题:设备硬件最多只能支持Android 7(Nougat,对应API 24),而且因为依赖Stripe Android Terminal 2.23.4,API版本也没法升到25。这导致我只能基于Java开发,没法用上更新的技术栈。
我找了个适配旧版本的示例项目起步,但现在卡在了Data Binding的替代方案上。目前我的项目用的是AGP 3.3.0和Gradle 5.1.1,不确定能不能升级——感觉Android的依赖解析能力比Flutter的pub弱一些,怕升级后引发依赖冲突或兼容性问题。而且Data Binding需要依赖AndroidX,启用它的buildFeature{}语法好像需要更高版本的AGP,我当前版本完全支持不了,所以不仅用不了Data Binding,连ObservableField(属于androidx.databinding的一部分)也没法用。
我真的希望能有一份Android API、AGP和Gradle的兼容性对照表,这样升级决策时也能有明确的参考依据。现在最核心的需求是:找一个能替代ObservableField的方案,实现类似的视图与数据绑定功能,求各位大佬给点建议!
附上我当前的app级build.gradle文件,方便大家参考排查:
buildscript { repositories { google() mavenCentral() // jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.3.0' } } allprojects { repositories { google() mavenCentral() // jcenter() } } apply plugin: 'com.android.application' android { compileSdkVersion 27 defaultConfig { applicationId "com.android.*******" minSdkVersion 24 //noinspection ExpiredTargetSdkVersion targetSdkVersion 27 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') testImplementation 'junit:junit:4.12' implementation 'com.android.support:appcompat-v7:27.0.0' androidTestImplementation 'com.android.support:support-annotations:27.0.0' androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.1' implementation 'com.stripe:stripeterminal:2.23.4' // implementation 'com.android.databinding:baseLibrary:8.8.0' }
备注:内容来源于stack exchange,提问作者EatonWu
相关产品推荐
相关产品推荐

