React native, Unable to resolve module for static image - android

I'm using react-native 0.14.1
react-native run-android
[3:10:56 PM] <START> find dependencies
Unable to resolve module image!ic_action_android_back_white3 from /Users/lion/Desktop/Developer/AwesomeProject/NewTrackActivity.js
Unable to resolve module image!ic_action_android_back_white3 from /Users/lion/Desktop/Developer/AwesomeProject/NewTrackActivity.js
If I force open my app in Genymotion it can't find my image.
Requiring unknown module image!ic_action_android_back_white3
I'm tried to move image to both ./android/app/src/main/res/drawable-xxx and ./assets/drawable-xxx but neither work.

Have you tried to mount the image, like the new asset manager allows you to do? It's described in the documentation.
Use the following prop for the Image component. Choose the right relative path and dont forget the extension.
<Image source={require('./my-icon.png')} />

Sometimes, your image might include an #2x or #3x for different screen dpi as mentioned in docs. In such case the path should specify the image name without the #2x or #3x suffix. For example if image file name is img#2x.png:
<Image source={require('./img.png')} />

Restart your react packager. That worked for me.

I think this is an issue of adding assets after your initial build.
I closed the emulator and bundler, cleared cache and ran RN - run-ios/run-andriod - and then not a problem.
I was also wondering if just running link might work, but did not get to test this.

You can save your image in that folder itself instead of saving in asset folder and give path as :
<Image source={require('../download.png')} />
It worked for me

I had the same error message Unable to resolve module for files with upper case characters.
My solution - rename file names to lower case.
Using in code:
<Image source={require('../download.png')} />
Versions:
react native - 0.62
expo - 38

Related

Flutter file picker creates symlinks

I have battled this issue for sometime now and i seem to be going nowhere, I am using file_picker flutter plugin, its working on devices with android v7, now am running the app on emulator with android v9 and the filepicker creates symlink, here is a log:
I/FilePickerUtils( 7999): File loaded and cached at:/data/user/0/com.lulliezy.videostatus/cache/file_picker/KHALIGRAPH JONES x SARKODIE - WAVY (OFFICIAL VIDEO).webm
I/FilePickerDelegate( 7999): Absolute file path:/data/user/0/com.lulliezy.videostatus/cache/file_picker/KHALIGRAPH JONES x SARKODIE - WAVY (OFFICIAL VIDEO).webm
Now my understanding bt the word cached is a symlink is created, now how do i disable this feature or rather, get the original file name with this code:
await FilePicker.getFile(
type: FileType.custom,
allowedExtensions: ['mp4', 'webm'],
);
Thanks in advance.
EDIT
I should clarify, am using flutter ffmpeg so it complains with file does not exists.
I actually found a workaround for this, I copied the picked file to another temporary directory and used that new path after which when am done, I delete the copied file.

Unable to get package name in appium

I am using Appium for mobile app testing but when i choose APK file then i am not able to see package name,launch activity name in appium drop downs,please find below screen shot .Please any one provide solution for this.
Assuming you had setup everything right then the issue is with the space in the apk path. Make sure you don't have space in your apk path.
Your path :
E:\Appium Tutorials\APK\Futurepay.apk
I suggest rename the folder to AppiumTutorials. Then path will be
E:\AppiumTutorials\APK\Futurepay.apk
That should help!

External HTML asset not bundled by React Native in production build for use by Webview

I'm building an Android application using React Native. It has a webview that reads an HTML file locally.
This is the piece of code I'm using to render webview.
<WebView ref="webview"
source={require('./helloworld.html')}
javaScriptEnabled style={styles.webView} />
This works well during development build. The HTML file loads on the webview and renders well.
But it doesn't on Android release/production build. The webview is empty and if I inspect using chrome://inspect, the webview is empty and doesn't load the HTML file.
From what I understand is the React Native fails to bundle helloworld.html as an asset during Android production build. I noticed that it works fine on iOS.
Any idea how to fix it?
As per the discussions around here https://github.com/facebook/react-native/issues/6004, it's a known defect. Assets are not bundled for Android production build but works fine in dev build.
A solution is store assets in Android assets folder manually, and then load the resource using
<WebView
source={{ uri: 'file:///android_asset/helloworld.html' }}
startInLoadingState={true} />
on RN 0.40,
require('./file.html')
is failing for me in Build release variant. It's fine in debug builds.
As workaround, I was able to put the file in android assets dir, and
{ uri: file:///android_asset/file.html }
load from there. Unfortunately for my situation, the html file loads remote third-party libs which internally reference protocol-agnostic resources: e.g., //domain.com/file.json. So those all got turned into file://domain.com/file.json links and of course failed.
I monkey patched XMLHttpRequest to change //... to https://... which solved that problem, but none of the images those libs attempt to load, will load. all broken. And I've been unable to find a way to determine what the requests look like for those images, to see why they break/fail-to-load.
on iOS production build this solution is work
<WebView
source={{ uri: 'helloworld.html' }}
startInLoadingState={true} />

File not found error when using web pack build in cordova app on android

I want to wrap a react based web app which gets build using webpack in a
cordova container for an Android device. I successfully built the
cordova app for iOS and everything worked fine. However, when building
for android, static resources like images and fonts that are required in
javascript using webpack's file-loader, aren't loaded correctly.
The web view tries to load all resources like an image from
file:///android_asset/www/build/myImage.png, but logs a file not found
error. If I link - for example - the same image directly in the
index.html via an image tag, the image is loaded correctly, but changing
the publicPath attribute in my webpack config file didn't work.
Any help is very much appreciated.
Thanks a lot in advance
My brute force solution:
Pre-React Build: add "homepage": "./", to app’s package.json.
Post-React Build, and Pre-Cordova Run Android: in www/static/js, find/replace “static/media” with “android_asset/www/static/media” for all image/pdf files in the main###.js file (not the .map file).
My solution was to add "homepage": "/android_asset/www/" to package.json, it works perfectly with dynamic paths,

Cocos2d-x Sample HelloCpp not running on Android

I have a problem with the included sample HelloCpp in cocos2d-2.0-x-2.0.4.
My environment:
Mac OSX 10.8.2
cocos2d-2.0-x-2.0.4
android-ndk-r8
The proj.ios of the sample is running fine in the xcode emulator but i have problems get the proj.android running on my Android HTC One X Device.
I am able to build the apk file with the makefile from raywenderlich and when i unzip the apk it has the assets/ipad folder included and images in it and after the installation of the apk file on the device the app loads and shows the information about frames etc. in the left lower corner of the screen. But then a notification window pops up and tells me that the program is not able to load "assets/ipad/HelloWorld.png"
The error message is thrown in cocos2dx/platform/android/CCFileUtils.ccp line 134.
Is it correct to load a png file with pData = CCFileUtils::getFileDataFromZip(s_strResourcePath.c_str(), fullPath.c_str(), pSize); ?
Because thats the line where the program is running into in cocos2dx/platform/android/CCFileUtils.ccp line 97.
the value of s_strResourcePath is /data/app/org.cocos2dx.hellocpp.apk and fullpath is assets/ipad/HelloWorld.png.
I really hope someone can help me. Or has the same problem at least.
Just check out in which folder is you all resources. In my case its in assets/Resources .. So i will setResourceDirectory as "Resources" so the path will be assets/Resources ...whereas i guess in ur case its ipad
so set it ipad
Add this lines in AppDelegate.cpp->applicationDidFinishLaunching() function. If it's already there then just change it for the android
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID )
pFileUtil->setResourceDirectory("ipad");
#endif
Try if this works
Try to add your images in "HelloCpp/Resources". Maybe you're adding image files in "HelloCpp/proj.android/assets/".
Try this:
"HelloCpp/Resources/iphone/HelloWorld.png"
"HelloCpp/Resources/ipad/HelloWorld.png"
"HelloCpp/Resources/ipadhd/HelloWorld.png"
Instead of this:
"HelloCpp/proj.android/assets/iphone/HelloWorld.png"
"HelloCpp/proj.android/assets/ipad/HelloWorld.png"
"HelloCpp/proj.android/assets/ipadhd/HelloWorld.png"

Categories

Resources