使用带有react-native的okhttp3库(在运行'react-native run-android'命令时抛出异常)

时间:2021-03-03 20:48:27

I've been developing a native-module to use in my react-native project. And my native module uses okhttp3 library.

我一直在开发一个本机模块,用于我的react-native项目。我的本机模块使用okhttp3库。

However when I run the command of react-native run-android I get the following exception:

但是,当我运行react-native run-android的命令时,我得到以下异常:

Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexException: Multiple dex files define Lokhttp3/Address;

I guess both of react-native and I add okhttp3 library to use in the same app.

我想两个本机反应和我添加okhttp3库在同一个应用程序中使用。

Is there any chance to use okhttp3 library which is added by react-native?

有没有机会使用由react-native添加的okhttp3库?

or is there any chance to overcome this issue?

或者有没有机会克服这个问题?

1 个解决方案

#1


0  

The question on react-native github site has been responded.

关于react-native github网站的问题已得到回复。

The issue was regarding with build.gradle.

问题与build.gradle有关。

Adding the line of compile 'com.squareup.okhttp3:okhttp:3.3.1' to the dependencies part of build.gradle file was worked.

将编译'com.squareup.okhttp3:okhttp:3.3.1'的行添加到build.gradle文件的依赖项部分中。

#1


0  

The question on react-native github site has been responded.

关于react-native github网站的问题已得到回复。

The issue was regarding with build.gradle.

问题与build.gradle有关。

Adding the line of compile 'com.squareup.okhttp3:okhttp:3.3.1' to the dependencies part of build.gradle file was worked.

将编译'com.squareup.okhttp3:okhttp:3.3.1'的行添加到build.gradle文件的依赖项部分中。