Android Studio:未捕获的翻译错误,ExceptionWithContext

Posted

技术标签:

【中文标题】Android Studio:未捕获的翻译错误,ExceptionWithContext【英文标题】:Android Studio:Uncaught translation error, ExceptionWithContext 【发布时间】:2016-02-08 12:29:31 【问题描述】:

我正在尝试将我的应用从 eclipse 迁移到 android Studio。我没有使用导入功能,基于非常简单的一个创建项目。我成功地构建了项目,但是当我尝试运行我的应用程序时出现下一个错误。

AGPBI: "kind":"simple","text":"Uncaught translation error: com.android.dex.util.ExceptionWithContext","sources":[]
AGPBI: "kind":"simple","text":"1 error; aborting","sources":[]

我在 Google 搜索中看到类似的错误,但我找不到解决此问题的方法。

我的 build.gradle 看起来像这样。 (我删除了signingConfigs。)

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 选项来获取更多日志,但没有帮助。

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]

我检查了日志输出,似乎问题与支持注释有关......我不知道。但专家可能会发现它很有用。

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]

我添加了支持注释库,因为在谷歌搜索“支持注释”后它似乎也被链接,但它没有帮助。完全相同的错误仍然存​​在。

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]

我找到了this thread,并检查了如下所示的代码样式。

if (BuildConfig.DEBUG)

    myView.setOnClickListener(new View.OnClickListener()
    
        @Override
        public void onClick(View v) 
            // Do something
        
    );

我有许多将通过优化删除的代码行,使用静态最终变量(如 BuildConfig.DEBUG)来控制代码行为,具体取决于调试/发布、免费/付费等构建模式。但我找不到线程指出问题的相同模式。

【问题讨论】:

【参考方案1】:

终于找到了解决办法。 This answer救了我的命。

在我的例子中,我有下面的代码是导致这个烦人问题的原因。

private class MyLicenseCheckerCallback implements LicenseCheckerCallback

    public void allow()
    

让这个类public解决了这个问题。

public class MyLicenseCheckerCallback implements LicenseCheckerCallback

    public void allow()
    

只有一个词,一个文件中的“私有”导致了这个问题,而且由于构建系统没有给出我们应该查看的任何提示,所以很难修复。我用谷歌搜索了很多,我只在 SO 的一个线程中看到了that answer。没有那个答案,我无法解决这个问题。感谢 Johny_G 和这个社区。​​p>

对于那些遇到同样问题的人,首先将当前代码提交到任何 VCS,然后尝试在一次批量操作(使用良好的编辑器)中搜索并将单词“private”替换为“public”并构建/运行。如果问题消失,请将几个文件放回前一个文件并构建/运行以查看哪个文件具有“私有”密钥。

【讨论】:

干杯! .快乐编码 @IntelliJAmiya,我希望你能做点什么来改变这一点。面对这个问题绝对不开心。 这正是我的问题!感谢您分享您的经验。 在生成签名的 APK 时对我来说也是如此。你拯救了我的夜晚 类和方法都是public,但问题依旧存在!【参考方案2】:

我最近两次遇到此问题。上次我在这里的某个地方发现了一些提到匿名类得到优化的东西(这个答案:https://***.com/a/22010135/2214006)。对我来说,这个错误是通过调整这样的代码块来解决的。

例如。

if (BuildConfig.DEBUG) 
  query.findInBackground(new FindCallback<ParseObject>() 
    // etc
  );

在构建发布版本时会导致此错误。尝试通过首先将其分配给变量来使其工作并没有帮助,因为它仍然被优化:

if (BuildConfig.DEBUG) 
  FindCallback<ParseObject> findHandler = new FindCallback<ParseObject>() 
    // etc
  ;
  query.findInBackground(findHandler);

我不想在 BuildConfig.DEBUG 为 false 时创建它,所以我把它放在一个单独的类中:

private class FindHandler implements FindCallback<ParseObject> 
  //etc

然后在我的代码的主要部分:

if (BuildConfig.DEBUG) 
  query.findInBackground(new FindHandler());

【讨论】:

在我将 [Edit 4] 添加到我的问题后,我立即看到了您的答案,该问题指的是同一线程。正如我在 [Edit 4] 中所写,我找不到适合这种模式的代码。由于它看起来是检查的好地方,我将更多地研究我的代码。谢谢你帮助我。 我猜第一个是它是否在调试模式下编译但不是发布(或相反)?在我的应用程序中,我有各种标志,可以在各种不同的调试位中编译,因此我可以将它们一一剔除,以缩小问题所在的程序区域。抱歉,我无法提供更多帮助,我知道试图追查这些奇怪的、与构建工具相关的问题是多么令人沮丧。 我可以找到与您不同的解决方案,但由于您只是回答问题的人,因此您有资格获得赏金。 很高兴你找到了答案!我想知道这是否与构建工具中的错误有关?如果它至少为您提供了发生“错误”的文件名,那就太好了...【参考方案3】:

当您将 annotation processors 添加为 compile 依赖项时也会发生这种情况。他们应该是provided

例如,我有:

compiled 'frankiesardo:icepick-processor:3.2.0'

应该是:

provided 'frankiesardo:icepick-processor:3.2.0'

【讨论】:

以上是关于Android Studio:未捕获的翻译错误,ExceptionWithContext的主要内容,如果未能解决你的问题,请参考以下文章

未捕获的翻译错误构建proguard

未捕获的翻译错误:com.android.dx.cf.code.SimException:在没有 --min-sdk-version >= 24 的情况下使用默认或静态接口方法

错误 ANDROID STUDIO E/RecyclerView:未连接适配器;跳过布局

即使使用未翻译的字符串,如何在 Android Studio 上签署 APK?

Android Studio NDK链接器错误未定义引用'cv :: _ OutputArray :: _ OutputArray(cv :: Mat&)'

Fabric For Android Studio 抛出了一个未捕获的 NullPointerExcpetion