gpt4 book ai didi

android-studio - gradle 同步失败导致 : java. lang.NullPointerException

转载 作者:行者123 更新时间:2023-12-03 07:16:03 25 4
gpt4 key购买 nike

今天我盯着我的 Android Studio 并弹出了这个错误,昨天一切都很好......真的不知道会出什么问题,所以我尝试重新安装android studio,安装Android SDK构建工具,也安装android SDK工具25.2.2

帮助

来自模块应用

apply plugin: 'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "oo"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}

来自项目

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

启动 android studio 后的事件日志

> Error:Cause: java.lang.NullPointerException   at
> java.util.Objects.requireNonNull(Objects.java:203) at
> java.util.Arrays$ArrayList.<init>(Arrays.java:3813) at
> java.util.Arrays.asList(Arrays.java:3800) at
> com.intellij.openapi.util.io.FileUtilRt.doCreateTempFile(FileUtilRt.java:399)
> at
> com.intellij.openapi.util.io.FileUtilRt.createTempFile(FileUtilRt.java:361)
> at
> com.intellij.openapi.util.io.FileUtilRt.createTempFile(FileUtilRt.java:341)
> at
> com.intellij.openapi.util.io.FileUtilRt.createTempFile(FileUtilRt.java:334)
> at
> com.intellij.openapi.util.io.FileUtil.createTempFile(FileUtil.java:1479)
> at
> com.android.tools.idea.gradle.util.GradleUtil.addInitScriptCommandLineOption(GradleUtil.java:1064)
> at
> com.android.tools.idea.gradle.util.GradleUtil.addLocalMavenRepoInitScriptCommandLineOption(GradleUtil.java:1057)
> at
> com.android.tools.idea.gradle.util.GradleUtil.addLocalMavenRepoInitScriptCommandLineOption(GradleUtil.java:1023)
> at
> com.android.tools.idea.gradle.project.AndroidGradleProjectResolver.getExtraCommandLineArgs(AndroidGradleProjectResolver.java:345)
> at
> org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:175)
> at
> org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$300(GradleProjectResolver.java:73)
> at
> org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:768)
> at
> org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:752)
> at
> org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:238)
> at
> org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:112)
> at
> org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:73)
> at
> com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
> at
> com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
> at
> com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
> at
> com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
> at
> com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
> at
> com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
> at
> com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:138)
> at
> com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:124)
> at
> com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:419)
> at
> com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:500)
> at
> com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563)
> at
> com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
> at
> com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
> at
> com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
> at
> com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
> at
> com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
> at
> com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126)
> at
> com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:369)
> 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)

最佳答案

以下步骤帮助我摆脱了这种情况:

  • 文件 -> 使缓存无效/重新启动 -> 无效并重新启动
  • 构建 -> 清理项目

希望有帮助!

关于android-studio - gradle 同步失败导致 : java. lang.NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40612457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com