Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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. 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. I tried of course the common way to fix Android Studio like reboot, invalidate cache, clean, uninstall, etc... Thanks for your help.

EDIT

I figured out that this happens only when updating to Android Studio 4.0

EDIT 2

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

like image 610
michelecasati Avatar asked Jun 18 '20 19:06

michelecasati


2 Answers

I think you have configuration debug signingConfigs

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

}

1.delete debug signingConfigs

2.delete .idea and .gradle folders

3.rebuild project

I think this can solve your problem

like image 188
Granden Avatar answered Oct 06 '22 23:10

Granden


have you tried this solution? Let me know if it works please.

  • close android studio
  • delete .idea and .gradle folders
  • open again your project with android studio

Or reinstall android studio?

like image 1
android_dev71 Avatar answered Oct 06 '22 23:10

android_dev71