【发布时间】:2018-09-20 11:35:56
【问题描述】:
Android Studio 一直告诉我构建失败。我没有使用 Kotlin,我所有的代码都在 JAVA 中。仅当我想构建/运行项目时,我才会不断收到此错误。我总是需要删除 .gradle 文件夹并重新启动 Android Studio 才能让它再次工作。我觉得这不是 IDE 问题,因为我同时使用了 IDE 版本 3.1 和 3.3。我还将 Kotlin 更新到了当前 1.2.70 的最新版本
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:processProdDebugManifest'.
> java.lang.IllegalAccessException: Class kotlin.reflect.jvm.internal.FunctionCaller$FieldSetter can not access a member of class com.android.build.gradle.tasks.ManifestProcessorTask with modifiers "private"
ext.kotlin_version = "1.2.70"
在完全重新启动并使缓存失效后,构建成功,但在进行任何新更改后,我无法再次构建,直到我重新启动整个 IDE 并删除 .gradle 文件夹
这是我的根项目版本号
ext {
// SDK and tools
minSDK = 18
targetSDK = 28
compileSDK = 28
buildTools = '28.0.2'
// SUPPORT LIBRARY
SupportLibrary = '28.0.0-rc02'
// Debug the App
debugMode = true
minify = true
proguard = false
multidex = false
// App Versioning
versionCode = 7
versionName = 0.7
}
【问题讨论】:
-
你项目
build.gradle中的gradle插件版本是最新的吗? -
这是我目前拥有的
dependencies { classpath 'com.android.tools.build:gradle:3.3.0-alpha11' classpath 'com.google.gms:google-services:4.0.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } -
尝试将
'com.google.gms:google-services:4.0.1'更改为classpath 'com.google.gms:google-services:4.1.0' -
是的,当我这样做时,我得到 Firebase 应用程序未初始化错误,但我首先调用
FirebaseApp.initializeApp(LoginActivity.this);,构建工作但应用程序由于 firebase 不断崩溃 -
好的,我有点像这样修复了我的 Firebase 初始化问题,我想现在我们必须手动执行此操作,如下所示:
FirebaseOptions.Builder builder = new FirebaseOptions.Builder() . .setApplicationId("APP_ID") . .setApiKey("API_KEY") . .setDatabaseUrl("DB_URL") . .setStorageBucket("BUCKET_NAME");
标签: android android-studio kotlin