problem to show epub in release build android !
mesismart opened this issue · 1 comments
i try to show my epub by below code , every thing is ok in debug build and when i get release build and test , epub book not show and fix loading at begining to show ,
i debug in android studio console and find same error :
I/ReactNativeJS: readBookEpub id: 4868
I/ReactNativeJS: source: http://localhost:8899/4868/
E/ReactNativeJS: Empty Response
my code:
_showEpub(bookName) {
console.log("_showEpub");
const targetPath = 'http://127.0.0.1:8899/' + bookName + '.epub';
//------------------------------------------------------show Epub
try {
this.streamer.start()
.then((origin) => {
console.log("Served from:", origin);
// this.streamer.check('http://127.0.0.1:8899/moby-dick.epub').then((t) => console.log("hiii"+t));
return this.streamer.get(targetPath);
})
.then((src) => {
console.log("Loading from:", src);
return this.setState({ urlBook: src });
});
}
catch (err) {
console.log("Error: " + err);
}
//---------------------------------------------------
}
for show book , i download book from my server by RNBackgroundDownloader and save , then unzip it in asset folder for read locally ,
my unzip function:
_unZipBook(bookName) {
console.log("_unZipBook")
const sourcePath = Dirs.DocumentDir + '/FaraSource/e/' + bookName + '.zip';
const targetPath = `${Dirs.DocumentDir}/assets/${bookName}`;
unzip(sourcePath, targetPath)
.then((path) => {
console.log("unZip " + bookName + "in" + targetPath);
this._showEpub(bookName);
// return url;
})
}
any one can help me for this problem ?
i solved the problem , must add one line in AndroidManifest
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
</manifest>
for read more
https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted/50834600#50834600