Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio:Uncaught translation error, ExceptionWithContext

I'm trying to migrate my app from eclipse to Android Studio. I did not use import feature, creating project based on very simple one. I managed to successfully build project but I got next error when I try to run my app.

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

I see similar errors with Google search but I could not find a fix for this issue.

My build.gradle looks like this. (I removed 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'
}

I tried with --stacktrace and --debug option to get more logs, but not helped.

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] 

Any help is welcome.

[Edit 1]

I checked log output and it seems problem is related to support-annotations... which I don't know about. But experts may find it useful.

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

[Edit 2]

I added support-annotations library as it seems to be linked too after googling about "support-annotions" but it did not help. Exact same error persisted.

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'
}

[Edit 3]

Since java.exe is returning error to Gradle, java.exe should know the place/file which found error. But there is no log from java.exe itself. I checked Gradle documentation but could not find a way to let get logs (standard output?) of java.exe. How can I do this? I guess that error message may lead me to the right place to look at.

[Edit 4]

I found this thread and I checked code style shown below.

if (BuildConfig.DEBUG)
{
    myView.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View v) {
            // Do something
        }
    });
}

I had many lines of code that will be deleted by optimization, using static final variable (like BuildConfig.DEBUG) to control code behavior depending on build mode like debug/release, free/paid. But I could not find same pattern that the thread pointed as an issue.

like image 538
Tomcat Avatar asked Nov 07 '15 11:11

Tomcat


People also ask

How to open the translations editor in Android Studio?

1 In the Project > Android panel on the left, select ModuleName > res > values. 2 Right-click the strings.xml file, and select Open Translations Editor . The Translations Editor displays the key and value pairs from the strings.xml ...

How do I display translated text in Spanish in the design editor?

The Design Editor displaying translated text in Spanish To set the language back to the default, select es > Language . Figure 10. Set to the default language The Android platform and Android Studio provide several features to help you manage and test your localizable app text.

What does red text mean in the translation editor?

Red text indicates an error condition that you must fix To correct an error, hover over the red text to display an explanation of the problem and its resolution. When you make changes in the Translations Editor, the underlying strings.xml files update with your changes.

How do I display translated text in my Android app layout?

To see how the translated text displays in your app layout, toggle the text between the default and translated versions in the Design Editor, as follows: In the Project > Android panel on the left, select ModuleName > res > layout. Double-click content_main.xml to open it for editing.


2 Answers

Finally I could find a solution. This answer saved my life.

In my case, I have code below which is a cause of this annoying issue.

private class MyLicenseCheckerCallback implements LicenseCheckerCallback
{
    public void allow()
    {

And making this class public fixed this.

public class MyLicenseCheckerCallback implements LicenseCheckerCallback
{
    public void allow()
    {

Just one word, "private" in one file caused that issue and since build system didn't give any hint where we should look at, it was very hard to fix. I googled a lot and I saw that answer only in one thread in SO. Without that answer, I could not fix this issue. Thanks Johny_G and this community.

For those who suffer from same issue, first commit current code to any VCS then try search and replace word "private" to "public" in one bulk operation (using good editor) and build/run. If issue goes away, put few files back to previous one and build/run to see what file has key "private".

like image 160
Tomcat Avatar answered Nov 14 '22 13:11

Tomcat


I've hand this issue crop up twice recently. Last time I found something somewhere on here that mentioned anonymous classes getting optimised out (this answer: https://stackoverflow.com/a/22010135/2214006). For me, this error was fixed by adjusting such a block of code.

eg.

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

Would cause this error when building a release version. Attempting to make it work by assigning it to a variable first didn't help as it was still optimised out:

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

I didn't want it created when BuildConfig.DEBUG was false, so I put it in a separate class:

private class FindHandler implements FindCallback<ParseObject> {
  //etc
}

Then in the main part of my code:

if (BuildConfig.DEBUG) {
  query.findInBackground(new FindHandler());
}
like image 36
Andrew Avatar answered Nov 14 '22 15:11

Andrew