React Native Error: RNHTMLtoPDF error: Could not create folder structure - android

Development Environment
System:
OS: macOS 10.15.4
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU # 2.20GHz
Memory: 248.71 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 13.2.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK: Not Found
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
Languages:
Java: 13.0.1 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
#react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
I am not able to make PDF in ANDROID API LEVEL 29. It is working fine in API LEVEL 28.
So I downgraded RN version from 0.63.2 from 0.62.2 and Gradle 3.5.3 to 3.5.2
according to this issue https://github.com/christopherdro/react-native-html-to-pdf/issues/189
also followed https://github.com/christopherdro/react-native-html-to-pdf/issues/149
this too. It says Permission error so inside componentDidMount() I have added following line
PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE)
But still no luck.
I am getting following error.
Possible Unhandled Promise Rejection (id: 0):
Error: RNHTMLtoPDF error: Could not create folder structure.
promiseMethodWrapper#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:2214:45
createPDF$#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:136885:88
tryCatch#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26640:23
invoke#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26813:32
tryCatch#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26640:23
invoke#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26713:30
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26743:19
tryCallTwo#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:28610:9
doResolve#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:28774:25
Promise#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:28633:14
callInvokeWithMethodAndArg#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26742:33
enqueue#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26747:157
async#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26764:69
createPDF#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:136851:42
requestReadPermission$#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:136835:33
tryCatch#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26640:23
invoke#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26813:32
tryCatch#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26640:23
invoke#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26713:30
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26723:21
tryCallOne#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:28601:16
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:28702:27
_callTimer#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:32141:17
_callImmediatesPass#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:32177:19
callImmediates#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:32395:33
callImmediates#[native code]
__callImmediates#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:2719:35
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:2505:34
__guard#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:2702:15
flushedQueue#http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:2504:21
flushedQueue#[native code]
invokeCallbackAndReturnFlushedQueue#[native code]
This is library which I am using https://github.com/christopherdro/react-native-html-to-pdf

I found solution from this link
If you find out that your app is not able to make any file or folder you should add
android:requestLegacyExternalStorage="true" in your `<application>` in `AndroidManifest.xml`
for more details Official Link and Other StackOverflow Question Answsers
Remember: I am using React Native and only in Android API 29 and above I stuck in this issue.

I was also facing that problem, after some researching, I solve that problem,
"Directory name must be same as the directory(folder) present in you device, if you want to make custom directory then it may or may not work in you device because of the file structure or some native permission if custom directory name not work then you have to specify 'Documents' or 'Download' at directory option"
Note:
Example:
async createPDF() {
let options = {
html: '<h1>Export PDF</h1>',
fileName: 'MyPdf',
directory: 'Documents', //or Download
};
let file = await RNHTMLtoPDF.convert(options)
alert(file.filePath);
}

Related

react-native android error: package does not exist

I am new to react-native and I have to do the support on an app.
I can’t compile it on Android. I get an error while building it either by command line or from the android studio.
My configuration :
$ react-native info
info Fetching system and libraries information...
(node:21418) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
System:
OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 # 3.00GHz
Memory: 228.16 MB / 7.68 GB
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.21.2 - ~/.nvm/versions/node/v14.21.2/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v14.21.2/bin/yarn
npm: 6.14.17 - ~/.nvm/versions/node/v14.21.2/bin/npm
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 30, 33, 33
Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 33.0.1
System Images: android-30 | Google APIs Intel x86 Atom, android-33 | Google APIs Intel x86 Atom_64
Android NDK: Not Found
IDEs:
Android Studio: AI-213.7172.25.2113.9123335
Languages:
Java: 11.0.17 - /lib/jvm/java-1.11.0-openjdk-amd64/bin/javac
npmPackages:
#react-native-community/cli: ^10.1.0 => 10.1.0
react: ^18.1.0 => 18.2.0
react-native: 0.70.6 => 0.70.6
npmGlobalPackages:
*react-native*: Not Found
The command line  :
react-native run-android --variant=stagingDebug --appId com.< app name>.staging
Error that I get :
> Task :app:compileStagingDebugJavaWithJavac FAILED
359 actionable tasks: 6 executed, 353 up-to-date
<myProject root path>/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:99: error: package com.< app name>.staging does not exist
new CodePush(com.< app name>.staging.BuildConfig.CODEPUSH_KEY, this.getApplication(), com.< app name>.staging.BuildConfig.DEBUG),
react-native.config.js :
module.exports = {
dependencies: {
// disable autolinking for these unsupported libraries
// #codepush
'react-native-code-push': {
platforms: {
android: {
packageImportPath: 'import com.microsoft.codepush.react.CodePush;',
packageInstance:
'new CodePush(BuildConfig.CODEPUSH_KEY, this.getApplication(), BuildConfig.DEBUG)',
},
},
},
},
};
I hope someone can help me!

Execution failed for task ':react-native-reanimated:compileDebugJavaWithJavac'

Although this question has been asked by others, none of the provided solutions work for my use case.
Environment
System:
OS: macOS 12.3.1
CPU: (10) arm64 Apple M1 Pro
Memory: 202.25 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.1.0 - ~/.nvm/versions/node/v16.1.0/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 7.11.2 - ~/.nvm/versions/node/v16.1.0/bin/npm
Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8609683
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /Users/AH94896/.jenv/shims/javac (Using Java 1.8 gives same result)
npmPackages:
#react-native-community/cli: Not Found
react: 16.14.0 => 16.14.0
react-native: 0.64.1 => 0.64.1
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
------------------------------------------------------------
Gradle 6.5.1
------------------------------------------------------------
Build time: 2020-06-30 06:32:47 UTC
Revision: 66bc713f7169626a7f0134bf452abde51550ea0a
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 11.0.15 (Eclipse Adoptium 11.0.15+10)
OS: Mac OS X 12.3.1 x86_64
Description
I can clean the app using ./gradlew clean. But when launching using npx react-native run-android, the build fails in the same spot:
> Configure project :react-native-reanimated
No AAR for react-native-reanimated found. Attempting to build from source.
Native libs debug enabled: false
Android gradle plugin: 4.1.0
Gradle: 6.5.1
building Reanimated2
> Task :react-native-reanimated:compileDebugJavaWithJavac FAILED
The place in the build process where it goes awry is this
/Users/AH94896/projects/app/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java:13: error: cannot find symbol
ViewManagerResolver viewManagerResolver,
^
symbol: class ViewManagerResolver
location: class ReanimatedUIImplementation
/Users/AH94896/projects/app/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java:11: error: recursive constructor invocation
public ReanimatedUIImplementation(
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-reanimated:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
The REALLY odd fact is that NO ONE else on my team experiences this problem whether using Apple M1 or Intel Macs. I have exhausted every resource I've found searching for a solution.
Please ask if you need more info. This is a critical blocker for my project work.

RN App Crashes on release in Google Play Store with: com.facebook.react.common.c: TypeError: Cannot read property 'show' of null, js engine: hermes

Every time I deploy my app to Google Play, the automated Google testing devices crash, throwing a Fatal Exception mentioned in the title. I am unable to replicate the issue on my Emulator.
Any help would be much appreciated!
Stack Trace:
Process: XXXXXX, PID: 6643
com.facebook.react.common.c: TypeError: Cannot read property 'show' of null, js engine: hermes, stack:
value#1:1574391
anonymous#1:1565462
oe#1:2225838
onPress#1:2226713
value#1:262899
value#1:262506
onResponderRelease#1:261783
o#1:99044
h#1:99101
g#1:99133
b#1:99265
xe#1:102719
H#1:100823
anonymous#1:103079
ke#1:158244
_e#1:102627
Re#1:102916
receiveTouches#1:152479
value#1:78850
anonymous#1:77331
value#1:78295
value#1:77289
at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(Unknown Source:134)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:147)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:21)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loop(Looper.java:237)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:919)
react-native -v
react-native: 0.64.3
react-native info
OS: Windows 10 10.0.22000
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU # 1.80GHz
Memory: 7.04 GB / 15.74 GB
Binaries:
Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 8.5.1 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Version 2020.3.0.0 AI-203.7717.56.2031.7621141
Visual Studio: Not Found
Languages:
Java: Not Found
npmPackages:
react-native-windows: Not Found
npmGlobalPackages:
*react-native*: Not Found```

React native: Error "Unexpected identifier '_classCallCheck'.import call expects exactly one argument"

I'm using React-Native on my android program, after open my porject with react-native run-android ,the error occurred.The same error message occurred twice.
Unexpected identifier '_classCallCheck'.import call expects exactly one argument
Unexpected identifier '_classCallCheck'.import call expects exactly one argument
no stack
no stack
I googled this and try some solutions, but still can't resolve.
Here is a similar problem that I have found:
https://github.com/facebook/react-native/issues/23669
What I have been tried for this error:
cd to /andorid, use gradlew clean
use react-native start --reset-cache
use npm install -g react-native-cli
Here is my develop environment:
Android:
AVD version: Android 7.0 with Play Store
System:
OS: Windows 10 10.0.19043
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 # 2.80GHz
Memory: 2.11 GB / 15.71 GB
Binaries:
Node: 10.16.0 - D:\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.9.0 - D:\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 28, 32
Build Tools: 28.0.3, 32.0.0
System Images: android-24 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Version 2020.3.0.0 AI-203.7717.56.2031.7935034
Visual Studio: Not Found
Languages:
Java: 1.8.0_232
npmPackages:
#react-native-community/cli: Not Found
react: 16.9.0 => 16.9.0
react-native: ^0.64.0 => 0.64.3
react-native-windows: Not Found
npmGlobalPackages:
*react-native*: Not Found
Guys,I just solved this problem.Here's the link.
https://github.com/babel/babel/issues/14139
from:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
to:
module.exports = {
presets: [['module:metro-react-native-babel-preset', {
unstable_disableES6Transforms: true
}]],
};
I had the same problem and the steps above didn't work, so i update metro-react-native-babel-preset from 0.56.0 to 0.59.0 and it worked.
"#babel/core": "7.12.0", // was "7.9.6"
"metro-react-native-babel-preset": "0.59.0", // was "0.58.0"
This helped me (RN 0.62.2)
Thank God after days of work this silly issue resolved on my side
In my case it was babel, actually i removed the yarn.lock file and after a fresh yarn the babel version was updated so its creating this issue, so what i did i just revert the yarn.lock file and remove ( ^ ) from "#babel/core" version and did a yarn and then it works....
my current babel/core version is "#babel/core": "7.12.9",
i changed this
"#babel/core": "^7.12.9",
to this
"#babel/core": "7.12.9",
this issue also listed here
1.in your terminal enter:
npm ls metro-config
you will see your version of react-native need the version of metro-config
change the version of these dependencies:
"metro": "^0.59.0",
"metro-core": "^0.59.0",
"metro-react-native-babel-preset": "^0.59.0",
Clear watchman watches: watchman watch-del-all
Delete node_modules and run yarn install
Reset Metro's cache by passing the --reset-cache flag, or adding
resetCache: true to your metro configuration file.
Remove the cache: rm -rf ${TMPDIR:-/tmp}/metro-*
if necessary add
resetCache: true,
in your metro.config.js
I think you will need to upgrade the gradle version

React Native Error: TypeError: null is not an object _RNGestureHandlerModule.default.Direction

I have tried many ways to fix this error but all attempts have failed.
FOR ANDROID NOT IOS.
_RNGestureHandlerModule.default.Direction
I was trying for android. I found bug react-native-gesture-handler buy I don't know how to fix it.
I am following this instruction step by step https://reactnavigation.org/docs/en/getting-started.html
I tried linking the react-native-gesture-handler manual. and also tried unlinked.
I made react-native.config.js with code
exports = {
dependencies: {
'react-native-gesture-handler': {
platforms: {
android: null,
ios: null,
},
},
},
};
I am using System:
OS: Linux 5.3 Arch Linux undefined
CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU # 3.70GHz
Memory: 16.06 GB / 31.21 GB
Shell: 5.0.11 - /bin/bash
Binaries:
Node: 12.13.0 - /usr/bin/node
Yarn: 1.19.1 - /usr/bin/yarn
npm: 6.12.1 - /usr/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.4 => 0.61.4
npmGlobalPackages:
react-native-cli: 2.0.1
"react-navigation": "^2.18.2",
"react-navigation-stack": "^1.10.3"
FOR ANDROID NOT IOS.
_RNGestureHandlerModule.default.Direction I wrote about the bug react-native-gesture-handler Github
Just simply you should comment line :
// export { default as Directions } from './Directions';
in the your project -> node_modules -> react-native-gesture-handler -> GestureHandler.js
I think it hope help you
Please try with
Pod update
It's working for me

Categories

Resources