Android Studio:Uncaught translation error, ExceptionWithContext
我正在尝试将我的应用程序从eclipse迁移到Android Studio。我没有使用导入功能,基于非常简单的创建项目。我设法成功构建项目但是当我尝试运行我的应用程序时出现了下一个错误。
1 2 | AGPBI: {"kind":"simple","text":"Uncaught translation error: com.android.dex.util.ExceptionWithContext","sources":[{}]} AGPBI: {"kind":"simple","text":"1 error; aborting","sources":[{}]} |
我在Google搜索中看到了类似的错误,但我找不到解决此问题的方法。
我的build.gradle看起来像这样。 (我删除了签名配置。)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | apply plugin: 'com.android.application' android { compileSdkVersion 'Google Inc.:Google APIs:21' buildToolsVersion"23.0.2" defaultConfig { applicationId"net.dailytimer.imadoco" minSdkVersion 9 versionCode 1 versionName"1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFile 'C:/Android/AndroidStudioProjects/imadoco/document/proguard-project.txt' signingConfig signingConfigs.config } } productFlavors { free { versionCode 30800 versionName '3.08.0' applicationId 'net.DailyTimer.imadocoFree' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile files('libs/acra-4.6.1.jar') compile 'com.google.android.gms:play-services:8.3.0' compile 'com.android.support:support-v4:23.1.0' } |
我尝试使用--stacktrace和--debug选项来获取更多日志,但没有帮助。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 19:32:19.775 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':app:dexFreeDebug' 19:32:19.775 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :app:dexFreeDebug FAILED 19:32:19.776 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :app:dexFreeDebug (Thread[Daemon worker Thread 32,5,main]) completed. Took 6.205 secs. 19:32:19.776 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 32,5,main]] finished, busy: 10.137 secs, idle: 0.032 secs 19:32:19.777 [ERROR] [org.gradle.BuildExceptionReporter] 19:32:19.778 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception. 19:32:19.778 [ERROR] [org.gradle.BuildExceptionReporter] 19:32:19.778 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong: 19:32:19.778 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:dexFreeDebug'. 19:32:19.778 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_60\bin\java.exe'' finished with non-zero exit value 1 19:32:19.779 [ERROR] [org.gradle.BuildExceptionReporter] 19:32:19.779 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is: 19:32:19.779 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:dexFreeDebug'. 19:32:19.780 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) 19:32:19.780 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) 19:32:19.780 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) 19:32:19.780 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) 19:32:19.780 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 19:32:19.780 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) 19:32:19.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) 19:32:19.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) 19:32:19.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 19:32:19.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310) 19:32:19.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79) 19:32:19.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63) 19:32:19.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51) 19:32:19.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23) 19:32:19.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88) 19:32:19.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) 19:32:19.782 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62) 19:32:19.788 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23) 19:32:19.795 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68) 19:32:19.796 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) 19:32:19.796 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62) 19:32:19.796 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55) 19:32:19.796 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149) 19:32:19.796 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106) 19:32:19.797 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86) 19:32:19.797 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90) 19:32:19.797 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:54) 19:32:19.797 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) 19:32:19.797 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41) 19:32:19.798 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) 19:32:19.798 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:49) 19:32:19.798 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 19:32:19.798 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 19:32:19.799 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37) 19:32:19.799 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 19:32:19.799 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) 19:32:19.800 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 19:32:19.800 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) 19:32:19.800 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 19:32:19.800 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74) 19:32:19.801 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72) 19:32:19.801 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.util.Swapper.swap(Swapper.java:38) 19:32:19.801 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) 19:32:19.801 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 19:32:19.801 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47) 19:32:19.801 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 19:32:19.801 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66) 19:32:19.802 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 19:32:19.802 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 19:32:19.802 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:71) 19:32:19.802 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 19:32:19.802 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 19:32:19.802 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41) 19:32:19.802 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 19:32:19.803 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) 19:32:19.803 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246) 19:32:19.803 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) 19:32:19.803 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) 19:32:19.803 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.internal.UncheckedException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_60\bin\java.exe'' finished with non-zero exit value 1 19:32:19.804 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:45) 19:32:19.804 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:78) 19:32:19.804 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:243) 19:32:19.804 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219) 19:32:19.804 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:230) 19:32:19.805 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208) 19:32:19.805 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) 19:32:19.805 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) 19:32:19.806 [ERROR] [org.gradle.BuildExceptionReporter] ... 57 more 19:32:19.806 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_60\bin\java.exe'' finished with non-zero exit value 1 19:32:19.806 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:42) 19:32:19.806 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1276) 19:32:19.807 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.builder.core.AndroidBuilder$convertByteCode$7.call(Unknown Source) 19:32:19.807 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.tasks.Dex.doTaskAction(Dex.groovy:165) 19:32:19.807 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.tasks.Dex.this$6$doTaskAction(Dex.groovy) 19:32:19.807 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.tasks.Dex$this$6$doTaskAction.callCurrent(Unknown Source) 19:32:19.807 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.tasks.Dex.taskAction(Dex.groovy:99) 19:32:19.808 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) 19:32:19.808 [ERROR] [org.gradle.BuildExceptionReporter] ... 63 more 19:32:19.808 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_60\bin\java.exe'' finished with non-zero exit value 1 19:32:19.808 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:365) 19:32:19.808 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:40) 19:32:19.809 [ERROR] [org.gradle.BuildExceptionReporter] ... 70 more 19:32:19.809 [ERROR] [org.gradle.BuildExceptionReporter] |
欢迎任何帮助。
[编辑1]
我检查了日志输出,似乎问题与支持注释有关...我不知道。但专家可能会发现它很有用。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | processing archive C:\Android\AndroidStudioProjects\imadoco\app\build\intermediates\pre-dexed\free\debug\support-annotations-23.1.0-24c46cbde714be0842274322039416f341dd73a0.jar... ignored resource META-INF/ ignored resource META-INF/MANIFEST.MF ignored resource android/ ignored resource android/support/ ignored resource android/support/annotation/ processing classes.dex... 23:07:52.739 [ERROR] [org.gradle.api.Project] AGPBI: {"kind":"simple","text":"Uncaught translation error: com.android.dex.util.ExceptionWithContext","sources":[{}]} 1 error; aborting 23:07:52.739 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':app:dexFreeDebug' 23:07:52.739 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :app:dexFreeDebug FAILED 23:07:52.740 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :app:dexFreeDebug (Thread[Daemon worker Thread 5,5,main]) completed. Took 3.06 secs. 23:07:52.740 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 5,5,main]] finished, busy: 6.815 secs, idle: 0.025 secs 23:07:52.741 [ERROR] [org.gradle.BuildExceptionReporter] 23:07:52.741 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception. 23:07:52.741 [ERROR] [org.gradle.BuildExceptionReporter] 23:07:52.741 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong: 23:07:52.742 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:dexFreeDebug'. 23:07:52.742 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_60\bin\java.exe'' finished with non-zero exit value 1 |
[编辑2]
我添加了支持注释库,因为它似乎在谷歌搜索"支持 - 注释"后,但它没有帮助。完全相同的错误仍然存??在。
1 2 3 4 5 6 7 | dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile files('libs/acra-4.6.1.jar') compile 'com.google.android.gms:play-services:8.3.0' compile 'com.android.support:support-v4:23.1.0' compile 'com.android.support:support-annotations:23.1.0' } |
[编辑3]
由于java.exe将错误返回给Gradle,java.exe应该知道发现错误的位置/文件。但是java.exe本身没有日志。我检查了Gradle文档,但找不到让java.exe获取日志(标准输出?)的方法。我怎样才能做到这一点?我想这个错误信息可能会让我到正确的地方去看看。
[编辑4]
我找到了这个帖子,并检查了下面显示的代码样式。
1 2 3 4 5 6 7 8 9 10 | if (BuildConfig.DEBUG) { myView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Do something } }); } |
我有很多代码将被优化删除,使用静态最终变量(如BuildConfig.DEBUG)来控制代码行为,具体取决于构建模式,如debug / release,free / paid。但是我找不到线程指出的相同模式。
最后我找到了解决方案。这个答案救了我的命。
在我的情况下,我有下面的代码是导致这个恼人问题的原因。
1 2 3 4 | private class MyLicenseCheckerCallback implements LicenseCheckerCallback { public void allow() { |
并使这个类公开修复此问题。
1 2 3 4 | public class MyLicenseCheckerCallback implements LicenseCheckerCallback { public void allow() { |
只有一个词,一个文件中的"私有"导致了这个问题,而且由于构建系统没有给出我们应该查看的任何提示,因此很难修复。我google了很多,我只在SO中的一个帖子中看到了答案。没有这个答案,我无法解决这个问题。感谢Johny_G和这个社区。
对于那些遭受同样问题的人,首先将当前代码提交给任何VCS然后尝试搜索并在一个批量操作(使用良好编辑器)和构建/运行中将单词"private"替换为"public"。如果问题消失了,请将几个文件放回到上一个文件并构建/运行以查看哪个文件具有密钥"私有"。
我最近把这个问题提到了两次。上次我在这里发现某些地方提到的匿名类被优化了(这个答案:https://stackoverflow.com/a/22010135/2214006)。对我来说,通过调整这样的代码块来修复此错误。
例如。
1 2 3 4 5 | if (BuildConfig.DEBUG) { query.findInBackground(new FindCallback<ParseObject>() { // etc }); } |
在构建发布版本时会导致此错误。尝试通过首先将其分配给变量来使其工作并没有帮助,因为它仍然被优化:
1 2 3 4 5 6 | if (BuildConfig.DEBUG) { FindCallback<ParseObject> findHandler = new FindCallback<ParseObject>() { // etc }; query.findInBackground(findHandler); } |
当BuildConfig.DEBUG为false时我不想创建它,所以我把它放在一个单独的类中:
1 2 3 | private class FindHandler implements FindCallback<ParseObject> { //etc } |
然后在我的代码的主要部分:
1 2 3 | if (BuildConfig.DEBUG) { query.findInBackground(new FindHandler()); } |
将
例如,我有:
1 | compiled 'frankiesardo:icepick-processor:3.2.0' |
应该是:
1 | provided 'frankiesardo:icepick-processor:3.2.0' |