我正在开发一个 Android 应用程序,目前使用 DSL 和一些库,突然构建给了我这个错误。
任务 :app:kaptDebugKotlin FAILED 用于代码生成的 ANTLR 工具版本 4.7.1 与当前运行时版本不匹配 4.5.3ANTLR 运行时版本 4.7.1 用于解析器编译与当前运行时版本不匹配 4.5.3 失败:构建失败一个例外。
什么地方出了错:
任务 ':app:kaptDebugKotlin' 执行失败。执行 org.jetbrains.kotlin.gradle.internal.KaptExecution java.lang.reflect.InvocationTargetException 时发生故障(无错误信息)
我一直在寻找,但没有成功......
如果你想看到这个问题,你可以克隆项目。项目 GITHUB 我使用 Android Studio Canary 4.1。
以前使用时MaterialApp
有一种方法可以GlobalContext
使用NavigatorKey
位于MaterialApp widget
.
然而现在看来这种替代方案不再可能了,我有这个结构,如下Navigator 2.0
Widget build(BuildContext context, WidgetRef ref) {
return MaterialApp.router(
debugShowCheckedModeBanner: false,
restorationScopeId: 'app',
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: AppLocalizations.supportedLocales,
onGenerateTitle: (BuildContext context) =>
AppLocalizations.of(context)!.appTitle,
routeInformationParser: const RoutemasterParser(),
routeInformationProvider: routeInformationProvider,
routerDelegate: introductionRouteMap(context, ref));
}
Run Code Online (Sandbox Code Playgroud)
现在没有任何 NavigatorKey。所以我的问题是,如何使用设置 GlobalContext MaterialApp.router
?
我尝试使用 Koin 作为我的 DI 来实现权限注入,但是当我执行需要 PermissionRepository 的 ViewModel 时,我不断收到错误。
找不到类的定义:'ni.com.repository.PermissionRepositoryImplement'。检查你的定义!
该项目当前的结构是这样的。
基础应用程序
class BaseApplication : Application() {
companion object{
lateinit var context: BaseApplication
val allAppModules = listOf(coilModule, permissionsModule, blurModule, remoteDataSourceModule, preferencesModule, databaseModule, viewModelModule)
}
override fun onCreate() {
super.onCreate()
context = this
startKoin {
androidLogger()
androidContext(this@BaseApplication)
modules(allAppModules)
}
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
}
}
Run Code Online (Sandbox Code Playgroud)
PermissionModule但是我需要一个 Activity 来显示权限请求。在 Jetpack Navigation 之后,我使用 MainActivity 作为 Base 并注入到存储库中
val permissionsModule = module {
scope<MainActivity> {
scoped {
PermissionRepositoryImplement(get<MainActivity>())
}
}
}
Run Code Online (Sandbox Code Playgroud)
视图模型模块
val viewModelModule …
Run Code Online (Sandbox Code Playgroud) 突然,我在应用程序的执行中出错了.我知道这里已经提到了这个问题:现在必须明确声明注释处理器
但是解决方案没有回答问题:(
这是我的build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
buildToolsVersion '27.0.0'
aaptOptions {
cruncherEnabled = true
}
defaultConfig {
applicationId "com.freelance.crdzbird_dev.clarobadge"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile …
Run Code Online (Sandbox Code Playgroud) 我试图创建一个返回表的 postgres 函数,但是当我执行该函数时,return语句应该关闭或结束整个函数,但它一直忽略该结尾,然后继续。
该功能非常简单:只需验证字段是否为空。我知道如果我添加ELSE语句,问题就会得到解决,但是我不知道为什么它会忽略 RETURN ,我很想知道除了ELSE之外是否还有其他方法可以解决问题
create or replace function fnRegisterUserWin(rUsername text, rFname text, rLname text,rRole text, rBrand text) returns table(id_users int, message text, is_failure_location text, error_fields text[])
language plpgsql
as $$
declare
sanitazedUsername text;
sanitazedFirstname text;
sanitazedLastname text;
sanitazedRole text;
sanitazedBrand text;
errorFields text;
begin
sanitazedUsername := str_clean(rUsername,true,true,true,true,true,true,true);
sanitazedFirstname := str_clean(rFname,true,true,true,true,true,true,true);
sanitazedLastname := str_clean(rLname,true,true,true,true,true,true,true);
sanitazedRole := str_clean(rRole,true,true,true,true,true,true,true);
sanitazedBrand := str_clean(rBrand,true,true,true,true,true,true,true);
errorFields := '';
if(empty2null(sanitazedUsername) is null OR empty2null(sanitazedFirstname) is null OR
empty2null(sanitazedLastname) is …
Run Code Online (Sandbox Code Playgroud) 之前已经问过这个问题,但是解决方案仍然未知... Kotlin DSL build scripts dependency updates
随着 kotlin-dsl 的新实现。现在进口看起来像这样。
implementation Koin.core
implementation Koin.android
Run Code Online (Sandbox Code Playgroud)
和 buildSrc。
object Versions{
const val koin = "2.0.1"
}
object Koin {
val core = "org.koin:koin-core:${Versions.koin}"
val android = "org.koin:koin-android:${Versions.koin}"
val scope = "org.koin:koin-androidx-scope:${Versions.koin}"
val viewModel = "org.koin:koin-androidx-viewmodel:${Versions.koin}"
val extension = "org.koin:koin-androidx-ext:${Versions.koin}"
val test = "org.koin:koin-test:${Versions.koin}"
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下 Koin 使用的是以前的版本,但我知道有一个新版本https://github.com/InsertKoinIO/koin
有谁知道如何使用 kotlin-dsl 检查依赖项是否具有更新版本?
我知道在 MySQL 中我可以使用
decimal(9,6)
Run Code Online (Sandbox Code Playgroud)
并设置我想要的精度级别。
但是在 Oracle 10G 中,我认为以 VARCHAR2 格式存储这些值不是很方便,那么哪种格式最方便存储该值
注意:我已经访问过这个链接:用于在 oracle 数据库中存储纬度和经度的数据类型
但他们给出的答案我不清楚。
我正在开发一个 Android 应用程序,该应用程序使用带有 Koin 和 Retrofit 的 MVVM。
突然我不断收到一条错误消息
接口无法实例化!接口名称:kotlinx.coroutines.Deferred
但是我找不到问题出在哪里。
目前的结构是这样的。
视图模型。
class ExchangeRateBanksViewModel (private val comercialBanksRepository: ComercialBanksRepository): ViewModel() , KoinComponent{
private val _uiState = MutableLiveData<CredentialsDataState>()
val uiState: LiveData<CredentialsDataState> get() = _uiState
init {
viewModelScope.launch {
runCatching {
emitUiState(showProgress = true)
comercialBanksRepository.getExchangeRateByToday()
}.onSuccess {root ->
val nameMap: MutableList<ExchangeRate> = root.data.map { it }.toMutableList()
emitUiState(result = Event(nameMap))
}.onFailure {
println(it.printStackTrace())
}
}
}
private fun emitUiState(showProgress: Boolean = false, result: Event<List<ExchangeRate>>? = null, error: Event<Int>? = null){
val dataState = …
Run Code Online (Sandbox Code Playgroud) android ×4
kotlin ×4
mvvm ×2
annotations ×1
build.gradle ×1
flutter ×1
gradle ×1
java ×1
koin ×1
oracle ×1
oracle10g ×1
postgresql ×1