2015-07-28 12 views
7

Próbuję uruchomić prosty test JUNIT dla klasy testowej w studiu Android. Budowa idzie dobrze. Kiedy próbuję uruchomić test JUnit i pojawia się następujący błądAndroid Studio: wyjątek wskaźnika zerowego, gdy zadanie assembleDebugUnitTest gradle jest uruchamiane

*

Execution failed for task ':app:mockableAndroidJar'. 
> java.lang.NullPointerException (no error message) 

*

kiedy wyrzucił StackTrace otrzymuję następujący. Nie mam pojęcia, dlaczego tak się dzieje.

: 
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mockableAndroidJar'. 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteAc 
tionsTaskExecuter.java:69) 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTa 
skExecuter.java:46) 
     at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecu 
tionAnalysisTaskExecuter.java:35) 
     at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskEx 
ecuter.java:64) 
     at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecut 
er.java:58) 
     at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptyS 
ourceFilesTaskExecuter.java:42) 
     at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithN 
oActionsExecuter.java:52) 
     at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecut 
er.java:53) 
     at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMost 
OnceTaskExecuter.java:43) 
     at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:31 
0) 
     at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(Abst 
ractTaskPlanExecutor.java:79) 
     at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(Abst 
ractTaskPlanExecutor.java:63) 
     at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTask 
PlanExecutor.java:51) 
     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java 
:23) 
     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.ja 
va:88) 
     at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:3 
7) 
     at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62) 
     at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23) 
     at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68) 
     at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) 

     at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62) 
     at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55) 
     at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:14 
9) 
     at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106) 
     at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86) 
     at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessB 
uildActionExecuter.java:90) 
     at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner. 
java:28) 
     at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) 
     at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter. 
java:41) 
     at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter. 
java:28) 
     at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSugges 
tingBuildActionExecuter.java:50) 
     at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSugges 
tingBuildActionExecuter.java:27) 
     at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40) 
     at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169) 
     at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineAct 
ionFactory.java:237) 
     at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineAct 
ionFactory.java:210) 
     at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.jav 
a:35) 
     at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.jav 
a:24) 
     at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFacto 
ry.java:206) 
     at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFacto 
ry.java:169) 
     at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) 
     at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) 
     at org.gradle.launcher.Main.doAction(Main.java:33) 
     at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) 
     at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54) 
     at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35) 
     at org.gradle.launcher.GradleMain.main(GradleMain.java:23) 
     at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33) 
     at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130) 
     at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48) 
Caused by: java.lang.NullPointerException 
     at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source) 
     at org.objectweb.asm.tree.MethodNode.accept(Unknown Source) 
     at org.objectweb.asm.tree.MethodNode.accept(Unknown Source) 
     at org.objectweb.asm.tree.ClassNode.accept(Unknown Source) 
     at com.android.builder.testing.MockableJarGenerator.rewriteClass(MockableJarGenerator.java:134 
) 
     at com.android.builder.testing.MockableJarGenerator.createMockableJar(MockableJarGenerator.jav 
a:91) 
     at com.android.build.gradle.internal.tasks.MockableAndroidJarTask.createMockableJar(MockableAn 
droidJarTask.groovy:50) 
     at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) 
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAct 
ion.doExecute(AnnotationProcessingTaskFactory.java:226) 
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAct 
ion.execute(AnnotationProcessingTaskFactory.java:219) 
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAct 
ion.execute(AnnotationProcessingTaskFactory.java:208) 
     at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:589) 
     at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:572) 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteAct 
ionsTaskExecuter.java:80) 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteAc 
tionsTaskExecuter.java:61) 
     ... 49 more 

Środowisko testowe stosowane:

Środowisko: 1.2.2 SDK Version: API 21 narzędzi konstrukcyjnych 22.0.1 Wersja Android Plugin: 1.2.3 wersja Gradle: 2,5 JDK: 1.7. 0_79

Czy możesz mi pomóc z tym? Czy jest jakiś problem z moją konfiguracją?

Budowa Gradle plik:

apply plugin: 'com.android.application' 


android { 
    compileSdkVersion 21 
    buildToolsVersion "22.0.1" 

    defaultConfig { 
     applicationId "com.example.krishnaswamyna.testmathsapplication" 
     minSdkVersion 21 
     targetSdkVersion 21 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:recyclerview-v7:22.2.1' 
    compile 'com.android.support:leanback-v17:22.2.1' 
    testCompile 'junit:junit:4.12' 
    testCompile 'org.mockito:mockito-core:2.0.31-beta' 
    testCompile 'org.robolectric:robolectric:3.0' 
} 

Odpowiedz

4

miałem również ten sam problem od kilku tygodni. Zobaczyłem wskazówkę dotyczącą problemu dotyczącego SDK z here.

Co pracowało dla mnie to po prostu usunąć SDK przez Menedżera SDK, a następnie ponownie go zainstalować. Może być również konieczne wyczyszczenie projektu i/lub unieważnienie nagród i ponowne uruchomienie Android Studio pomiędzy usunięciem i ponownym zainstalowaniem zestawu SDK.

+0

Mam ten sam problem, myślę, że jest jakaś poprawka w najnowszej aktualizacji SDK. Tak więc aktualizuję do najnowszej wersji lub mojego SDK 19, wszystko działa. – Happier

3

Miałem ten sam problem, gdy zainstalowałem Android Studio 2.0.

Odznacz Enable all test artifacts w:

Plik-> Ustawienia-> Build, Wykonanie, Deployement-> Budowanie Narzędzia -> Gradle-> Gradle Experimental

Info: link

+0

Potwierdzam, że wyłączając opcję * Włącz wszystkie artefakty testowe *, mogę ponownie zbudować mój projekt. – vovahost

1

Oczyść kompilację i odbuduj aplikację, co może działać i rozwiązać problem. To gradle błędy mogą pochodzić z niektórych starych plików po prostu zrobić powyższe powiedział.