(Voir la mise à jour en bas)
Depuis qu'Android Studio s'est mis à jour vers la version 3.0, je ne peux plus créer d'activité. Je reçois cette boîte de dialogue de rapport d'erreur affichant 2 erreurs. J'ai essayé avec un projet différent, j'ai essayé de nettoyer le projet, de resynchroniser gradle, de redémarrer mon ordinateur, de désinstaller/réinstaller Android Studio, d'essayer de suivre la vidéo de migration de project Gradle de Google , mais rien ne change et je ne peux plus travailler. des idées?
Je n'ai pas cliqué sur "Désactiver le plug-in" pour désactiver Android Support, car je ne veux pas casser quelque chose que je ne connais pas.
Détails du premier message d'erreur:
null
Java.lang.NullPointerException
at com.Android.tools.idea.templates.TemplateManager$2.actionPerformed(TemplateManager.Java:481)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.Java:215)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.Java:232)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.Java:309)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.Java:929)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.Java:136)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.Java:299)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.Java:2022)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.Java:116)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.Java:86)
at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.Java:109)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.Java:118)
at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.Java:122)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.Java:116)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.Java:513)
at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.Java:45)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.Java:533)
at Java.awt.Component.processMouseEvent(Component.Java:6541)
at javax.swing.JComponent.processMouseEvent(JComponent.Java:3324)
at Java.awt.Component.processEvent(Component.Java:6306)
at Java.awt.Container.processEvent(Container.Java:2237)
at Java.awt.Component.dispatchEventImpl(Component.Java:4897)
at Java.awt.Container.dispatchEventImpl(Container.Java:2295)
at Java.awt.Component.dispatchEvent(Component.Java:4719)
at Java.awt.LightweightDispatcher.retargetMouseEvent(Container.Java:4889)
at Java.awt.LightweightDispatcher.processMouseEvent(Container.Java:4526)
at Java.awt.LightweightDispatcher.dispatchEvent(Container.Java:4467)
at Java.awt.Container.dispatchEventImpl(Container.Java:2281)
at Java.awt.Window.dispatchEventImpl(Window.Java:2746)
at Java.awt.Component.dispatchEvent(Component.Java:4719)
at Java.awt.EventQueue.dispatchEventImpl(EventQueue.Java:764)
at Java.awt.EventQueue.access$500(EventQueue.Java:98)
at Java.awt.EventQueue$3.run(EventQueue.Java:715)
at Java.awt.EventQueue$3.run(EventQueue.Java:709)
at Java.security.AccessController.doPrivileged(Native Method)
at Java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.Java:80)
at Java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.Java:90)
at Java.awt.EventQueue$4.run(EventQueue.Java:737)
at Java.awt.EventQueue$4.run(EventQueue.Java:735)
at Java.security.AccessController.doPrivileged(Native Method)
at Java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.Java:80)
at Java.awt.EventQueue.dispatchEvent(EventQueue.Java:734)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.Java:827)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.Java:651)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.Java:365)
at Java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.Java:201)
at Java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.Java:116)
at Java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.Java:105)
at Java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.Java:101)
at Java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.Java:93)
at Java.awt.EventDispatchThread.run(EventDispatchThread.Java:82)
Détails du deuxième message d'erreur:
Error executing FreeMarker template: The following has evaluated to null or missing:
==> manifestDir [in template "root://activities/common/common_globals.xml.ftl" at line 36, column 39]
Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
The failing instruction (print stack trace for 1 more):
==> ${manifestDir} [in template "root://activities/common/common_globals.xml.ftl" at line 36, column 37]
FreeMarker template error:
The following has evaluated to null or missing:
==> manifestDir [in template "root://activities/common/common_globals.xml.ftl" at line 36, column 39]
Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
The failing instruction (FTL stack trace):
----------
==> ${manifestDir} [in template "root://activities/common/common_globals.xml.ftl" at line 36, column 37]
#include "../common/common_globals.xm... [in template "root://activities/EmptyActivity/globals.xml.ftl" at line 8, column 5]
----------
Java stack trace (for programmers):
----------
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.Java:98)
at freemarker.core.EvalUtil.coerceModelToString(EvalUtil.Java:382)
at freemarker.core.Expression.evalAndCoerceToString(Expression.Java:115)
at freemarker.core.DollarVariable.accept(DollarVariable.Java:76)
at freemarker.core.Environment.visit(Environment.Java:265)
at freemarker.core.MixedContent.accept(MixedContent.Java:93)
at freemarker.core.Environment.visit(Environment.Java:265)
at freemarker.core.Environment.include(Environment.Java:1712)
at freemarker.core.Include.accept(Include.Java:172)
at freemarker.core.Environment.visit(Environment.Java:265)
at freemarker.core.MixedContent.accept(MixedContent.Java:93)
at freemarker.core.Environment.visit(Environment.Java:265)
at freemarker.core.Environment.process(Environment.Java:243)
at freemarker.template.Template.process(Template.Java:277)
at com.Android.tools.idea.templates.FreemarkerUtils.processFreemarkerTemplate(FreemarkerUtils.Java:96)
at com.Android.tools.idea.templates.Template.processFile(Template.Java:471)
at com.Android.tools.idea.templates.Template.access$100(Template.Java:73)
at com.Android.tools.idea.templates.Template$3.startElement(Template.Java:513)
at org.Apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.Apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.Apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.Apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.Apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.Apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.Apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.Apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.Apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.Apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.Apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at com.Android.tools.idea.templates.Template.processXml(Template.Java:484)
at com.Android.tools.idea.templates.Template.processFile(Template.Java:468)
at com.Android.tools.idea.templates.Template.lambda$doRender$2(Template.Java:368)
at com.Android.tools.idea.templates.Template$1.run(Template.Java:347)
at com.intellij.openapi.application.RunResult.run(RunResult.Java:35)
at com.intellij.openapi.command.WriteCommandAction.lambda$null$1(WriteCommandAction.Java:171)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.Java:1023)
at com.intellij.openapi.command.WriteCommandAction.lambda$performWriteCommandAction$2(WriteCommandAction.Java:170)
at com.intellij.openapi.command.WriteCommandAction.lambda$doExecuteCommand$4(WriteCommandAction.Java:210)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.Java:149)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.Java:119)
at com.intellij.openapi.command.WriteCommandAction.doExecuteCommand(WriteCommandAction.Java:212)
at com.intellij.openapi.command.WriteCommandAction.performWriteCommandAction(WriteCommandAction.Java:168)
at com.intellij.openapi.command.WriteCommandAction.execute(WriteCommandAction.Java:151)
at com.Android.tools.idea.templates.Template.runWriteCommandAction(Template.Java:349)
at com.Android.tools.idea.templates.Template.doRender(Template.Java:367)
at com.Android.tools.idea.templates.Template.render(Template.Java:232)
at com.Android.tools.idea.npw.template.RenderTemplateModel$FreeMarkerTemplateRenderer.renderTemplate(RenderTemplateModel.Java:267)
at com.Android.tools.idea.npw.template.RenderTemplateModel$FreeMarkerTemplateRenderer.doDryRun(RenderTemplateModel.Java:196)
at com.Android.tools.idea.npw.template.MultiTemplateRenderer.countDown(MultiTemplateRenderer.Java:58)
at com.Android.tools.idea.npw.template.MultiTemplateRenderer.requestRender(MultiTemplateRenderer.Java:77)
at com.Android.tools.idea.npw.template.RenderTemplateModel.handleFinished(RenderTemplateModel.Java:176)
at com.Android.tools.idea.wizard.model.ModelWizard.handleFinished(ModelWizard.Java:393)
at com.Android.tools.idea.wizard.model.ModelWizard.goForward(ModelWizard.Java:324)
at com.Android.tools.idea.wizard.model.ModelWizardDialog$FinishAction.doAction(ModelWizardDialog.Java:307)
at com.intellij.openapi.ui.DialogWrapper$DialogWrapperAction.actionPerformed(DialogWrapper.Java:1838)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.Java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.Java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.Java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.Java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.Java:252)
at Java.awt.Component.processMouseEvent(Component.Java:6541)
at javax.swing.JComponent.processMouseEvent(JComponent.Java:3324)
at Java.awt.Component.processEvent(Component.Java:6306)
at Java.awt.Container.processEvent(Container.Java:2237)
at Java.awt.Component.dispatchEventImpl(Component.Java:4897)
at Java.awt.Container.dispatchEventImpl(Container.Java:2295)
at Java.awt.Component.dispatchEvent(Component.Java:4719)
at Java.awt.LightweightDispatcher.retargetMouseEvent(Container.Java:4889)
at Java.awt.LightweightDispatcher.processMouseEvent(Container.Java:4526)
at Java.awt.LightweightDispatcher.dispatchEvent(Container.Java:4467)
at Java.awt.Container.dispatchEventImpl(Container.Java:2281)
at Java.awt.Window.dispatchEventImpl(Window.Java:2746)
at Java.awt.Component.dispatchEvent(Component.Java:4719)
at Java.awt.EventQueue.dispatchEventImpl(EventQueue.Java:764)
at Java.awt.EventQueue.access$500(EventQueue.Java:98)
at Java.awt.EventQueue$3.run(EventQueue.Java:715)
at Java.awt.EventQueue$3.run(EventQueue.Java:709)
at Java.security.AccessController.doPrivileged(Native Method)
at Java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.Java:80)
at Java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.Java:90)
at Java.awt.EventQueue$4.run(EventQueue.Java:737)
at Java.awt.EventQueue$4.run(EventQueue.Java:735)
at Java.security.AccessController.doPrivileged(Native Method)
at Java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.Java:80)
at Java.awt.EventQueue.dispatchEvent(EventQueue.Java:734)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.Java:827)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.Java:651)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.Java:365)
at Java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.Java:201)
at Java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.Java:116)
at Java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.Java:109)
at Java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.Java:190)
at Java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.Java:235)
at Java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.Java:233)
at Java.security.AccessController.doPrivileged(Native Method)
at Java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.Java:233)
at Java.awt.Dialog.show(Dialog.Java:1084)
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.Java:736)
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.Java:458)
at com.intellij.openapi.ui.DialogWrapper.invokeShow(DialogWrapper.Java:1696)
at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.Java:1645)
at com.Android.tools.idea.actions.NewAndroidComponentAction.actionPerformed(NewAndroidComponentAction.Java:140)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.Java:215)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.Java:232)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.Java:309)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.Java:929)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.Java:136)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.Java:299)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.Java:2022)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.Java:116)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.Java:86)
at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.Java:109)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.Java:118)
at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.Java:122)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.Java:116)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.Java:513)
at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.Java:45)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.Java:533)
at Java.awt.Component.processMouseEvent(Component.Java:6541)
at javax.swing.JComponent.processMouseEvent(JComponent.Java:3324)
at Java.awt.Component.processEvent(Component.Java:6306)
at Java.awt.Container.processEvent(Container.Java:2237)
at Java.awt.Component.dispatchEventImpl(Component.Java:4897)
at Java.awt.Container.dispatchEventImpl(Container.Java:2295)
at Java.awt.Component.dispatchEvent(Component.Java:4719)
at Java.awt.LightweightDispatcher.retargetMouseEvent(Container.Java:4889)
at Java.awt.LightweightDispatcher.processMouseEvent(Container.Java:4526)
at Java.awt.LightweightDispatcher.dispatchEvent(Container.Java:4467)
at Java.awt.Container.dispatchEventImpl(Container.Java:2281)
at Java.awt.Window.dispatchEventImpl(Window.Java:2746)
at Java.awt.Component.dispatchEvent(Component.Java:4719)
at Java.awt.EventQueue.dispatchEventImpl(EventQueue.Java:764)
at Java.awt.EventQueue.access$500(EventQueue.Java:98)
at Java.awt.EventQueue$3.run(EventQueue.Java:715)
at Java.awt.EventQueue$3.run(EventQueue.Java:709)
at Java.security.AccessController.doPrivileged(Native Method)
at Java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.Java:80)
at Java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.Java:90)
at Java.awt.EventQueue$4.run(EventQueue.Java:737)
at Java.awt.EventQueue$4.run(EventQueue.Java:735)
at Java.security.AccessController.doPrivileged(Native Method)
at Java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.Java:80)
at Java.awt.EventQueue.dispatchEvent(EventQueue.Java:734)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.Java:827)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.Java:651)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.Java:365)
at Java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.Java:201)
at Java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.Java:116)
at Java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.Java:105)
at Java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.Java:101)
at Java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.Java:93)
at Java.awt.EventDispatchThread.run(EventDispatchThread.Java:82)
UPDATE: Lors de la lecture, j'ai remarqué que le problème ne se produisait pas si je créais un nouveau projet. Cela n'arrive que sur des projets existants.
J'ai fini par rétrograder à la version 2.3.3 en récupérant l'ancienne version: https://developer.Android.com/studio/archive.html
METTRE À JOUR:
Après avoir testé avec la solution publiée ici, le problème ne concernait que cette ligne du fichier Gradle du projet :
buildDir = "C:/tmp/${rootProject.name}/${project.name}"
Si vous supprimez cette ligne, tout fonctionnera. L'autre solution contient des modifications supplémentaires, mais elles ne sont pas nécessaires pour résoudre le problème.
Pas besoin de déclasser. Assurez-vous simplement de:
(a) appliquez le plugin Gradle 3.0.0, (b) ajoutez les références de référentiel à "google ()" et (c) supprimez le code buildDir du fichier de graduations de votre projet.
allprojects {
//String osName = System.getProperty("os.name").toLowerCase();
//if (osName.contains("windows")) {
// buildDir = "C:/tmp/${rootProject.name}/${project.name}"
//}
repositories {
google()
jcenter()
}
}
Je pourrais ajouter une nouvelle activité à un projet existant après ces étapes.
J'ai corrigé le mien en changeant le JDK pour mon projet.
WINDOWS 10: Lors de l'installation d'Android Studio (AS), le JDK par défaut sera embedded JDK, fourni avec le package AS. Il vous suffit de remplacer le JDK par celui qui est installé sur votre système.
Pas:
Avant
Après
J'espère que ça aide :)
J'avais le même problème parce que j'ai ouvert un projet cloné à partir de l'écran d'accueil plutôt que de l'ouvrir à partir de "Ouvrir un projet existant".
Fermez votre projet, puis sélectionnez dans le menu "Ouvrir un projet existant", puis ouvrez votre projet et votre problème sera résolu.
Si vous utilisez Kotlin, assurez-vous que la version ext.kotlin_ de votre build.gradle correspond à la version de votre plug-in. Pour moi, cela donnait également un avertissement dans la sortie de gradle que ceux-ci étaient différents, alors gardez un je à ce sujet!
Essayez de faire ceci Fichier> Invalider caches/redémarrer> Invalider & redémarrer.