Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Support For OkHttp (3.8.0) - Native Modules SDK Compatibility Issues #13996

Closed
RobertWSaunders opened this issue May 16, 2017 · 8 comments
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@RobertWSaunders
Copy link

Description

Was trying to implement a Java SDK into my React Native Android project, however after adding the SDK into my build.gradle the project would not build because the Java SDK required okhttp 3.7.0 but React Native does not support that version. The motive for adding this SDK into the project was for exposing native modules that use the Java SDK. Suggest updating the version of okhttp React Native uses, this would help with compatibility with other SDK's. This issue was also filed for the Java SDK to support React Native, however it would make more sense for React Native to update, this issue could be affecting many SDK's and could preventing developers from making native modules to extend their React Native projects. The issue filed on the Java SDK can be found here.

When compiling the error will be:

Cause: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/RealWebSocket$1;
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

Which is saying that there are two dependancies that require okhttp but different versions, therefore incompatible.

For your reference, the dependency tree of my project can be seen below:

441b37ec-372f-11e7-97f6-3689414cbc29

Reproduction Steps and Sample Code

NOTE: Assuming you can create React Native applications from the command line using the react-native-cli if not, please look at here.

  1. Create a new React Native Project: react-native init AwesomeProject

  2. Open the Android Application and add the Watson Java SDK to AwesomeProject/android/app/build.gradle and make sure to sync Gradle:

dependencies {
    compile project(':react-native-tts')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile "com.ibm.watson.developer_cloud:speech-to-text:3.8.0" //add this line
}
  1. Build the project, either through the CLI or using Android Studio.

When compiling the error will be:

Cause: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/RealWebSocket$1;
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

NOTE: This example is using the Watson Java SDK, but the same error would occur if using a different SDK that needed a version of okhttp greater than what React Native uses.

Solution

Solution to this issue would be to update the version okhttp React Native uses to be greater than or equal to version 3.7.0.

Additional Information

  • React Native version: 0.44.0
  • Platform: Android
  • Development Operating System: macOS
  • Dev tools: Android Studio
@fkgozali
Copy link
Contributor

It was very recently upgraded to v3.8.0: 93a1d59

So master should have what you need.

@RobertWSaunders
Copy link
Author

@fkgozali Thank you for updating the version of okhttp, it now works. 👍

@mikelambert
Copy link
Contributor

Will this break again with 3af9be5 ?

@RobertWSaunders
Copy link
Author

@mikelambert 3af9be5 will indeed break this again. What is the reasoning for downgrading?

@fkgozali
Copy link
Contributor

this was downgraded due to an issue that caused breakage to existing apps: square/okhttp#3308

cc @emilsjolander in case there's more details to add

@fkgozali fkgozali reopened this May 31, 2017
@RobertWSaunders
Copy link
Author

@fkgozali Thanks, when a fix is found it should be updated once again.

@pzhangleo
Copy link

I find okhttp 3.8.1 is fixed that bug.
https://github.com/square/okhttp/blob/master/CHANGELOG.md

@hramos
Copy link
Contributor

hramos commented Aug 31, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos closed this as completed Aug 31, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Aug 31, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants