android - 运行 gradle 时找不到 kotlinx.android.synthetic
问题描述
我正在使用 Kotlin Android 扩展。我的项目毕业:
buildscript {
ext.kotlin_version = '1.2.41'
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
...
我的应用程序:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-kapt'
apply plugin: 'jacoco-android'
apply plugin: "kotlin-allopen"
...
Gradle 版本 4.6 Android Studio 3.1.2 Build #AI-173.4720617,于 2018 年 4 月 14 日构建 JRE: 1.8.0_152-release-1024-b01 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains sro Mac OS X 10.13.4
当通过 IDE 运行一切时,一切正常,但是当通过控制台运行时,gradle -p ~/source/android-app assembleDebug
IDE 突然将任何标记import kotlinx.android.synthetic.main...
为未使用,并且代码中的任何视图都标记为未找到。构建成功
它曾经可以工作,我升级的一个版本(Android studio、gradle、Kotlin 插件)破坏了它。关于下一步做什么的任何想法?
控制台输出:
19:46 $ gradle -p ~/source/android-app assembleDebug --console plain
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig
:app:mainApkListPersistenceDebug
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:processDebugGoogleServices
Parsing json file: /Users/efimerdler-kravitz/source/android-app/app/google-services.json
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:kaptGenerateStubsDebugKotlin
:app:kaptDebugKotlin
:app:compileDebugKotlin
:app:prepareLintJar UP-TO-DATE
:app:generateDebugSources
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug
:app:transformDexArchiveWithExternalLibsDexMergerForDebug
:app:transformDexArchiveWithDexMergerForDebug
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug UP-TO-DATE
:app:packageDebug
:app:assembleDebug
解决方案
在 Android Studio 文件中 -> 使缓存无效/重新启动... -> btn“无效并重新启动”
推荐阅读
- html - Bootstrap 下拉菜单不会在不滚动的情况下在附加位置打开
- deep-learning - 我可以在更差的 GPU 上运行预训练模型吗?
- angular - 告诉 Angular 组件重新加载
- ruby-on-rails - Rails 范围内的时区独立到期日比较
- css - CSS 设计按钮边框左上角等
- python - 我需要帮助找出我的代码有什么问题!('int'问题)
- java - 维护线程池任务队列的类型信息
- javascript - Laravel 5.6 + Jscript 日期选择器
- image-processing - 如何在单个字节中容纳大的量化 dct 值
- macos - 用于更改 macOS Time Machine 更新率的 Shell 命令