简体   繁体   English

更新到 4.0 后无法在 Android Studio 中创建 Activity 或 Fragment

[英]Can't create Activity or Fragment in Android Studio after updating to 4.0

I have just changed my laptop and I opened the repo in which I was working.我刚刚更换了笔记本电脑,并打开了我正在工作的存储库。 The problem is that I can't create a new Activity or a new Fragment because when I try to do so nothing happens.问题是我无法创建新的活动或新的片段,因为当我尝试这样做时没有任何反应。 Nothing changes and nothing is created, but I don't get any error.没有任何变化,也没有创建任何内容,但我没有收到任何错误。 I tried also to open this repo in a Linux PC within the command prompt and I discovered that when I create a new Activity the following logs appear in the console:我还尝试在命令提示符下的 Linux PC 中打开此存储库,我发现当我创建新活动时,控制台中会出现以下日志:

2020-06-18 21:31:21,287 [1773016]  ERROR - intellij.openapi.progress.Task - Could not extract certificate from file. 
java.lang.Exception: Could not extract certificate from file.
    at com.android.tools.idea.templates.KeystoreUtils.getCertificate(KeystoreUtils.kt:151)
    at com.android.tools.idea.templates.KeystoreUtils.sha1(KeystoreUtils.kt:122)
    at com.android.tools.idea.templates.KeystoreUtils.sha1$default(KeystoreUtils.kt:121)
    ...

Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect
    at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:783)
    at com.android.tools.idea.templates.KeystoreUtils.getCertificate(KeystoreUtils.kt:143)
    ...
Caused by: java.security.UnrecoverableKeyException: Password verification failed
    at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:781)
    ... 27 more
2020-06-18 21:31:21,287 [1773016]  ERROR - intellij.openapi.progress.Task - Android Studio 4.0  Build #AI-193.6911.18.40.6514223 
2020-06-18 21:31:21,287 [1773016]  ERROR - intellij.openapi.progress.Task - JDK: 1.8.0_242-release; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o 
2020-06-18 21:31:21,287 [1773016]  ERROR - intellij.openapi.progress.Task - OS: Linux 
2020-06-18 21:31:21,288 [1773017]  ERROR - intellij.openapi.progress.Task - Last Action: template.create.ActivityEmpty Activity 

I don't understand what is the correlation between a new activity and the keystore, but I tried even to create a new one but the error keeps appearing.我不明白新活动和密钥库之间的相关性是什么,但我什至尝试创建一个新活动,但错误不断出现。 The password is 100% correct.密码100%正确。 I don't know what to do.我不知道该怎么办。 I can create new activities only on my old PC.我只能在旧电脑上创建新活动。 The other coworkers seems to be fine with the same repo I use.其他同事似乎对我使用的同一个 repo 没问题。 I tried of course the common way to fix Android Studio like reboot, invalidate cache, clean, uninstall, etc... Thanks for your help.我当然尝试了修复 Android Studio 的常用方法,例如重新启动、使缓存无效、清理、卸载等……感谢您的帮助。

EDIT编辑

I figured out that this happens only when updating to Android Studio 4.0我发现只有在更新到 Android Studio 4.0 时才会发生这种情况

EDIT 2编辑 2

https://issuetracker.google.com/issues/159364425 https://issuetracker.google.com/issues/159364425

I think you have configuration debug signingConfigs我认为您有配置调试签名配置

signingConfigs {
        debug {
            storeFile file('...')
            storePassword "..."
            keyAlias "..."
            keyPassword "..."
        }

}

1.delete debug signingConfigs 1.删除调试签名配置

2.delete.idea and.gradle folders 2.delete.idea和.gradle文件夹

3.rebuild project 3.重建项目

I think this can solve your problem我认为这可以解决您的问题

have you tried this solution?你试过这个解决方案吗? Let me know if it works please.请让我知道它是否有效。

  • close android studio关闭 android 工作室
  • delete.idea and.gradle folders删除.idea 和.gradle 文件夹
  • open again your project with android studio使用 android 工作室再次打开您的项目

Or reinstall android studio?还是重装android studio?

only need to delete只需要删除

signingConfigs {
     debug{
       ...
     }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM