问题
I have updated to the latest version of Android Studio (3.1) and I get the following error when I try to run my app. It was working with no problems before the update. I have also uninstalled Android Studio and downloaded the latest version from the official website. Nothing has changed.
null java.lang.NullPointerException
at com.android.tools.idea.run.tasks.InstantRunNotificationTask.<init>(InstantRunNotificationTask.java:64)
at com.android.tools.idea.fd.InstantRunBuildAnalyzer.getNotificationTask(InstantRunBuildAnalyzer.java:188)
at com.android.tools.idea.run.AndroidLaunchTasksProvider.getTasks(AndroidLaunchTasksProvider.java:122)
at com.android.tools.idea.run.LaunchTaskRunner.run(LaunchTaskRunner.java:102)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:713)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:543)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:165)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:315)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
回答1:
I faced the exact same problem, I was afraid I broke something... I fixed it by cleaning and rebuilding the project (I had disabled instant run as suggested here before but I guess that was not necessary as I enabled it again after cleaning and rebuilding the project and worked just fine...).
Build -> Clean Project
Build -> Rebuild Project
I am not sure if rebuilding would be necessary, I did both steps and it worked fine, maybe just cleaning the project would have been sufficient.
Hope that helps!!
EDIT
Nice, one more thing. When I solved the problem depicted here I found another problem, when I clicked run the apk was not being created and I solved it with my answer on that other thread:
The APK file does not exist on disk
回答2:
Disable "Instant Run" Work for me.
File>>Setting>>Build,Execution,Deployment>>Instant Run
Uncheck "Enable Instant Run......."
回答3:
I was having a similar issue. In my case Android Studio deleted all the "android:id"s from layout files.
回答4:
It seems that disabling "Instant Run" fixed the issue:
Settings -> Build, Execution, Deployment -> Instant Run -> untick
回答5:
The way I got solution is following:
1) Disable the "Instant Run". Settings -> Build, Execution, Deployment -> Instant Run -> Uncheck -> apply -> OK
2) Build -> Clean and Rebuild Project
回答6:
Change the buildToolsVersion '27.0.3' to '27.0.2' in build module then revert back and sync gradle
回答7:
I faced in android studio 3.5 in this same issue .Just delete android studio 3.5 and I install 3.4.1 .Then there is no error.
来源:https://stackoverflow.com/questions/49510104/android-studio-3-1-exception-in-plugin-android-support