Android Studio v1.2.0 start up error : java.lang.N

2019-01-17 11:15发布

问题:

After updating Android Studio to v1.2.0. At start up I get below log and unable to open Android Studio. I am using Windows 7-64bit and look like same error getting in Ubuntu also

This issue also reported in Android Issues, but still not solution

java.lang.RuntimeException: java.lang.NullPointerException
    at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:178)
    at com.intellij.idea.MainImpl$1$1$1.run(MainImpl.java:52)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:738)
    at java.awt.EventQueue.access$300(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:699)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:708)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:362)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.NullPointerException
    at com.android.tools.idea.welcome.AndroidVirtualDevice.<init>(AndroidVirtualDevice.java:81)
    at com.android.tools.idea.welcome.InstallComponentsPath.createComponentTree(InstallComponentsPath.java:89)
    at com.android.tools.idea.welcome.InstallComponentsPath.init(InstallComponentsPath.java:215)
    at com.android.tools.idea.wizard.DynamicWizardPath.attachToWizard(DynamicWizardPath.java:97)
    at com.android.tools.idea.wizard.DynamicWizard.addPath(DynamicWizard.java:233)
    at com.android.tools.idea.welcome.FirstRunWizard.init(FirstRunWizard.java:75)
    at com.android.tools.idea.welcome.FirstRunWizardHost.setupWizard(FirstRunWizardHost.java:100)
    at com.android.tools.idea.welcome.FirstRunWizardHost.getWelcomePanel(FirstRunWizardHost.java:92)
    at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame.<init>(WelcomeFrame.java:68)
    at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame.showNow(WelcomeFrame.java:173)
    at com.intellij.idea.IdeaApplication$IdeStarter.main(IdeaApplication.java:302)
    at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:172)
    ... 16 more

Any help will be appreciated.

回答1:

Issue #170849 gives the reasons for the above crash.

  1. This happens (at least) when no sdk is installed and no remote repos that contain platforms are available.
  2. Actually it happens whenever remote sites aren't available and the first run wizard is run.

Found a temporary solution from Issue #170850:

Add the following code to C:\Program Files\Android\Android Studio\bin\idea.properties

disable.android.first.run=true

Updated

The issue has been fixed under Issue #170849.



回答2:

Follow the below steps:

  1. Open the folder bin under the directory where you installed your Android Studio.

  2. Find the file "idea.properties" and open it with Notepad++/UltraEdit/other_edit_tools.

  3. Add "disable.android.first.run=true" as the final line and save the file.

If you see any error while editing with Notepad ++ say in step 3. follow steps (a) and (b) like below
"Check if file is open in another program"

(a) open Notepad++ as administrator by doing a right click on Notepad++ shortcut and choose run as admin or ctrl+shift and click notepad++ shortcut

(b) Save the file after edit as listed in step 2.

  1. Restart Android Studio.


回答3:

The above answers work perfectly. Here is my alternative simple trick.

Close the Android Studio if it's already running and go to C:\Users\<your_name>\ and find-out .android directory and then delete it.

If you're a Linux user go to File system i.e., /home/<your_name>.

By default some of the directories are hidden in your home directory. So, just hit Ctrl + H to see hidden directories.

Now find-out .android directory and delete it.

(I think the same should work in Mac also why because the file structure is same as Linux)

After that start your Android Studio, now the IDE automatically creates .android directory in users home directory. Now you can use your Android Studio without any problem.



回答4:

I was facing the same problem. All you need to do is.

First close Android Studio if open.

open this folder in C:/UserName/

UserName will be different in your pc or you can see your name instead of userName

there you see .android Folder

first copy it and keep it safe on another location because we are going to delete it.

now delete that .android folder.

and start your Android Studio it'll work



回答5:

1.Close Android Studio.

2.Go to folder where Android studio is Installed. This is usually under C:\Program files\Android.

3.Now inside bin folder open file idea.properties

4.Now you will find al line something similar to this -> idea.max.intellisense.filesize=2500

add this line above it -> disable.android.first.run=true

5.Save it as Administrator.

6.Go to C:/Users/you name

7.Delete .android folder

  1. Now restart Android studio.

7.Now Set your Project location to C:/Users/Your Name/Android Studio Projects

  1. Woilaa... No Error


回答6:

I had the same problem , like mentioned above adding the specefied code will cause the android studio to open but I still couldn't create a project and it said that it couldn't find the sdk or something similar , if you encounter the same one you have to locate the folder of the sdk and it will work like a charm. to do so go to configure,project defaults,projects structure and then locate the folder. if you download the sdk seperatly enter the location , otherwise the sdk folder of the android studio is C:\Users\USERNAME\AppData\Local\Android\sdk and you should probably be good to go



回答7:

Thrown when an application attempts to use null in a case where an object is required. These include:

  1. Calling the instance method of a null object.
  2. Accessing or modifying the field of a null object.
  3. Taking the length of null as if it were an array.
  4. Accessing or modifying the slots of null as if it were an array.
  5. Throwing null as if it were a Throwable value.

To solve this you go to the directory where you installed your Android Studio in the bin folder and search "idea.properties" and edit it by adding this line

disable.android.first.run=true

using any of your text editors and save then restart Android Studio. Problem fixed.

For more check this out

https://developer.android.com/reference/java/lang/NullPointerException.html



回答8:

Today, I have experienced the same problem but how i Solved by simply closing the instance of Android Studio and reopening! Must have been an instance conflict in Android processes .



回答9:

you can simply go to bin and launch the android studio by double clicking studio64 present there.

If it does not work then change the setting in idea.properties present in bin folder and modify the code as disable.android.first.run=true