Ionic Native HTTP Error

D8: Program type already present: okhttp3.Authenticator$1

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:transformClassesWithMultidexlistForDebug’.

com.android.build.api.transform.TransformException: Error while generating the main dex list:
Error while merging dex archives:
Learn how to resolve the issue at Adicionar dependências de compilação  |  Android Studio  |  Android Developers.
Program type already present: okhttp3.Authenticator$1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 17s

Task :app:transformClassesWithMultidexlistForDebug FAILED
34 actionable tasks: 1 executed, 33 up-to-date
C:\Users\Admin\Desktop\MyApp\platforms\android\gradlew: Command failed with exit code 1 Error output:
D8: Program type already present: okhttp3.Authenticator$1

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:transformClassesWithMultidexlistForDebug’.

com.android.build.api.transform.TransformException: Error while generating the main dex list:
Error while merging dex archives:
Learn how to resolve the issue at Adicionar dependências de compilação  |  Android Studio  |  Android Developers.
Program type already present: okhttp3.Authenticator$1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 17s
[ERROR] An error occurred while running subprocess cordova.

    cordova.cmd build android exited with exit code 1.

    Re-running this command with the --verbose flag may provide more
    information.

C:\Users\Admin\Desktop\MyApp>

First thing I always do when faced with a error message that seems cryptic to me is to find the most unusual part of it and feed it to google. In your case, that would seem to be “okhttp3.Authenticator$1”, which leads one fairly quickly to this.

Hello rapropos,

I am getting this error after adding a few lines of code in build.gradle to avoid Program type already present: okhttp3.Authenticator$1

configurations {
    all*.exclude group: 'com.squareup.okhttp3', module: 'okhttp-urlconnection'
}

if add this below code then the ionic application is crashing while using http service.

configurations {
    all*.exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}

C:\Users\Admin\Desktop\MyApp\platforms\android\app\src\main\java\com\silkimen\http\OkConnectionFactory.java:4: error: cannot find symbol
import okhttp3.OkUrlFactory;
^
symbol: class OkUrlFactory
location: package okhttp3

Task :app:compileDebugJavaWithJavac
C:\Users\Admin\Desktop\MyApp\platforms\android\app\src\main\java\com\silkimen\http\OkConnectionFactory.java:15: error: cannot find symbol
OkUrlFactory urlFactory = new OkUrlFactory(this.client);
^
symbol: class OkUrlFactory
location: class OkConnectionFactory
C:\Users\Admin\Desktop\MyApp\platforms\android\app\src\main\java\com\silkimen\http\OkConnectionFactory.java:15: error: cannot find symbol
OkUrlFactory urlFactory = new OkUrlFactory(this.client);
^
symbol: class OkUrlFactory
location: class OkConnectionFactory
C:\Users\Admin\Desktop\MyApp\platforms\android\app\src\main\java\com\silkimen\http\OkConnectionFactory.java:22: error: cannot find symbol
OkUrlFactory urlFactory = new OkUrlFactory(clientWithProxy);
^
symbol: class OkUrlFactory
location: class OkConnectionFactory
C:\Users\Admin\Desktop\MyApp\platforms\android\app\src\main\java\com\silkimen\http\OkConnectionFactory.java:22: error: cannot find symbol
OkUrlFactory urlFactory = new OkUrlFactory(clientWithProxy);
^
symbol: class OkUrlFactory
location: class OkConnectionFactory
5 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:compileDebugJavaWithJavac’.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 31s

Task :app:compileDebugJavaWithJavac FAILED
24 actionable tasks: 2 executed, 22 up-to-date
C:\Users\Admin\Desktop\MyApp\platforms\android\gradlew: Command failed with exit code 1 Error output:
C:\Users\Admin\Desktop\MyApp\platforms\android\app\src\main\java\com\silkimen\http\OkConnectionFactory.java:4: error: cannot find symbol
import okhttp3.OkUrlFactory;
^
symbol: class OkUrlFactory
location: package okhttp3
C:\Users\Admin\Desktop\MyApp\platforms\android\app\src\main\java\com\silkimen\http\OkConnectionFactory.java:15: error: cannot find symbol
OkUrlFactory urlFactory = new OkUrlFactory(this.client);
^
symbol: class OkUrlFactory
location: class OkConnectionFactory
C:\Users\Admin\Desktop\MyApp\platforms\android\app\src\main\java\com\silkimen\http\OkConnectionFactory.java:15: error: cannot find symbol
OkUrlFactory urlFactory = new OkUrlFactory(this.client);
^
symbol: class OkUrlFactory
location: class OkConnectionFactory
C:\Users\Admin\Desktop\MyApp\platforms\android\app\src\main\java\com\silkimen\http\OkConnectionFactory.java:22: error: cannot find symbol
OkUrlFactory urlFactory = new OkUrlFactory(clientWithProxy);
^
symbol: class OkUrlFactory
location: class OkConnectionFactory
C:\Users\Admin\Desktop\MyApp\platforms\android\app\src\main\java\com\silkimen\http\OkConnectionFactory.java:22: error: cannot find symbol
OkUrlFactory urlFactory = new OkUrlFactory(clientWithProxy);
^
symbol: class OkUrlFactory
location: class OkConnectionFactory
5 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:compileDebugJavaWithJavac’.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 31s
[ERROR] An error occurred while running subprocess cordova.

    cordova.cmd build android exited with exit code 1.

    Re-running this command with the --verbose flag may provide more
    information.

C:\Users\Admin\Desktop\MyApp>