启动AndroidStudio后gradle创建不成功 , 问题如下:
10:13:28 Gradle sync started
10:13:28 NullPointerException: null
java.lang.NullPointerException
at com.jetbrains.cidr.lang.workspace.OCWorkspaceManager.getWorkspace(OCWorkspaceManager.java:12)
at com.jetbrains.cidr.lang.symbols.symtable.OCSymbolTablesBuildingActivity.clearAllSymbolDependentCaches(OCSymbolTablesBuildingActivity.java:381)
at com.jetbrains.cidr.lang.symbols.symtable.OCSymbolTablesBuildingActivity.access$400(OCSymbolTablesBuildingActivity.java:47)
at com.jetbrains.cidr.lang.symbols.symtable.OCSymbolTablesBuildingActivity$7.run(OCSymbolTablesBuildingActivity.java:241)
at com.jetbrains.cidr.lang.symbols.symtable.OCSymbolTablesBuildingActivity$14$1.run(OCSymbolTablesBuildingActivity.java:420)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1009)
at com.jetbrains.cidr.lang.symbols.symtable.OCSymbolTablesBuildingActivity$14.run(OCSymbolTablesBuildingActivity.java:416)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:857)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:658)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:386)
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)
10:13:47 Gradle sync completed
10:13:48 NullPointerException: null
10:13:48 Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]
10:13:52 Gradle build finished in 4s 546ms
解决办法:
在网上各种搜也没搜到,最后翻了个墙,废了双鞋才搜到一下解释:
Finally, I noticed that the exception window shows the NPE comes from the NDK support plugin. So I disabled and restarted AS to enable the plugin and the NPE is gone! Moreover, the C++ Code Style also comes back to normal. Therefore both should be somewhat related. Anyway, it would be useful to add a note for people to upgrade to 2.2.x.
大概就是禁用插件NDK 。如下
file>settings>plugins
然后就好了