Closed wtlgo closed 1 year ago
I did another thing. I removed the patch and added this to my android/build.gradle
buildscript {
// ...
subprojects { subproject ->
afterEvaluate {
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
}
Now the request just takes forever to resolve and ends with (52) Empty reply from server
when times out. As in #18.
@wtlgo Thank you for investigating! Unfortunately, I migrated to ios, so I don't have an Android phone to test this. Do you face the same issue with the Android Emulator? If yes, I will take a look at it later.
I am sorry, I have a potato laptop from 2013, there's no way I can run an emulator on this thing. Instead I tested it on all of my Android devices, and all of them behave the same.
@wtlgo No problem. I will try to reproduce the bug when I have time and get back to you!
@wtlgo I was able to reproduce the bug locally in my emulator, I will search for a solution in the next few days. In the meantime, I fixed the gradle versions (https://github.com/Alwinator/react-native-http-bridge-refurbished/commit/85d66f68241d33152aab2ce92b8caebdb71be028). So when using the npm install react-native-http-bridge-refurbished@next
at least the build errors should be gone.
This bug seems very weird. On one hand, the request is received by the Android application as I found in the logs here:
2023-08-30 19:12:05.635 15187-15260 HttpServer com.http_bridge_refurbished_test D Request received!
On the other hand, it does not send a response at all. I only get curl: (52) Empty reply from server
when I restart or stop the service.
I have found some lines that seem suspicious to me:
2023-08-30 19:11:59.026 15187-15187 NetworkSecurityConfig com.http_bridge_refurbished_test D No Network Security Config specified, using platform default
2023-08-30 19:11:59.026 15187-15187 NetworkSecurityConfig com.http_bridge_refurbished_test D No Network Security Config specified, using platform default
I think some security policies in Android changed and now non HTTP traffic must be explicitly allowed.
I have tried to set android:usesCleartextTraffic="true"
in the Android manifest of my test application, however, I am still getting these two lines in the logs.
An alternative would be to set up a Network Security Context
as shown here:
https://stackoverflow.com/a/55147267/6760875
However, I am getting this problem: https://stackoverflow.com/questions/74064839
@wtlgo @abdelhameedhamdy @mengheangrat It would be great if you could continue debugging and writing on this issue if you have any new findings.
I am very sorry, but my time is very limited because of my paid job and I don't think that I will have much time to debug this issue in the next weeks.
@Alwinator Thanks for your time for troubleshooting this issue,
I tried to run this repo with Android https://github.com/alwx/react-native-http-bridge and it works, after some modification in build.gradle
Regarding the Metro Bundler RN issue, I just added network_security_config.xml file in res/xml with this xml content
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
</domain-config>
</network-security-config>
update : and updated AndroidManifest with
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="true">
And RN screen error disappeared in emulator, but still exist with physical device, I think it needs some investigation.
Update
Repo : react-native-http-bridge https://github.com/alwx/react-native-http-bridge
Working on android without adding networkSecurityConfig/usesCleartextTraffic params in AndroidManifest.xml file.
So I think the refurbished repo needs some tuning
@abdelhameedhamdy react-native-http-bridge-refurbished is based on the repo you have sent. react-native-http-bridge is not maintained for several years now. It is only working with very old and deprecated android versions. On which Android version did you test?
I've just published a new version. Can you please test the latest version? (https://www.npmjs.com/package/react-native-http-bridge-refurbished/v/1.2.8)
@abdelhameedhamdy react-native-http-bridge-refurbished is based on the repo you have sent. react-native-http-bridge is not maintained for several years now. It is only working with very old and deprecated android versions. On which Android version did you test?
I've just published a new version. Can you please test the latest version? (https://www.npmjs.com/package/react-native-http-bridge-refurbished/v/1.2.8)
@Alwinator Android 12
@Alwinator Already tested with mavenCentral update in build.gradle and updated sdkVers, Got the same issue Empty reply from server
@abdelhameedhamdy Not sure what you are doing, but the old react-native-http-bridge repo throws several errors for me. What did you change to make it work?
@Alwinator Just followed https://github.com/alwx/react-native-http-bridge/issues/32
and the bridge build.gradle looks like this :
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 33
buildToolsVersion "33.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 2
versionName "1.1"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
lintOptions {
warning 'InvalidPackage'
}
}
dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'com.google.android.gms:play-services-gcm:+'
implementation 'org.nanohttpd:nanohttpd:2.3.1'
}
and it did work
UPD: I did some cross-platform tests and found some weird conclusions. When I opened the initial issue I was using Linux Mint as my development OS. Now I switched to Windows, updated to v1.2.8, and tried to rebuild the same exact project and it started to work. Still doesn't work when built under Linux for some reason. I hope this might be helpful.
@wtlgo Thank you for your insights! I tried to build on MacOS and it did not work either. I assume that there is some build issue on Unix.
@wtlgo Thank you for your insights! I tried to build on MacOS and it did not work either. I assume that there is some build issue on Unix.
Me too
:tada: This issue has been resolved in version 1.2.9 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
This issue has been resolved by @flokol120! I have also tested on on my MacBook and it works perfectly! Thank you a lot for your great contribution, Flo! :)
Hello! When I try to compile with the latest RN (0.72.4) for Android I get the following message:
Then when I try and patch the library with this:
It compiles, but in return nothing really works. The server is running, but is not accessible to any device in the local network. What am I doing wrong?