Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all 28463 articles
Browse latest View live

Unable to get ssid on Android

$
0
0

I am using @react-native-community/netinfo to get the ssid of the Network a device is connected to. It is not coming back in the NetInfo response. I am testing a debug build on a physical device (Google Pixel 3a)

I have the following permissions set (these will be refined once the ssid is returned):

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

I am then using the library like so:

const netInfo = useNetInfo();console.log(netInfo.details);

Which returns

{  isConnectionExpensive: false,  subnet: "255.255.255.0",  ipAddress: "192..",  strength: 94,  bssid: "02:00..."}

At this point:

  • Location services are enabled
  • isInternetReachable, isConnected and isWifiEnabled is truthy.

Using DataItem to communicate between react native app and Wear OS app

$
0
0

I am currently working on a Wear OS app as an extension of a React Native app. I would like to communicate between the two using a something like DataItems. But I have no idea how to do this and if this is at all possible. The problem is that there is very little information on the internet. Does someone have experience doing this? Where should I look for information? Thanks!

I did npx react-native run-android but doesn't works

$
0
0

I did that command to start the react-native application, but it returns that failure.

"Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build failed with an exception.

  • Where:Build file 'C:\Users\Usuario\Desktop\soorteiooo\node_modules\react-native-reanimated\android\build.gradle' line: 89

  • What went wrong-A problem occurred configuring project ':react-native-reanimated'.

    SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\Usuario\Desktop\soorteiooo\android\local.properties'.

  • Try-Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 7s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • Where:Build file 'C:\Users\Usuario\Desktop\soorteiooo\node_modules\react-native-reanimated\android\build.gradle' line: 89

  • What went wrong-A problem occurred configuring project ':react-native-reanimated'.

    SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\Usuario\Desktop\soorteiooo\android\local.properties'.

  • Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 7s

at makeError (C:\Users\Usuario\Desktop\soorteiooo\node_modules\execa\index.js:174:9)at Promise.all.then.arr (C:\Users\Usuario\Desktop\soorteiooo\node_modules\execa\index.js:278:16)at process._tickCallback (internal/process/next_tick.js:68:7)"

Direct print from React Native to Zebra ZQ520

$
0
0

I'm currently trying to print from my React Native app to a Zebra ZQ520 portable printer. I have been able to print using a 3rd party print service, but part of the problem is I also need this to direct print (silent print) as I want to avoid the Android print preview screen.

I'm using Expo for development so this adds another issue as a lot of the libraries cannot be used without first ejecting from Expo. This is something that I can do if need be, but right now I'm just trying to find the best solution to this problem.

So far I have printed through the 3rd party print service by calling Expo's Print.printAsync(options) and passing through HTML but again, this only serves to call the android print preview screen which I'm trying to avoid. I've also looked at PDF direct from Zebra (https://www.zebra.com/us/en/support-downloads/printer-software/pdf-virtual-device.html) which shows some promise as you can also use Expo's Print.printToFileAsync() to save to .PDF format. With this option I just currently haven't found if it's possible to use PDF direct from an Android device.

The thought I had with ejecting was using the react-native BLE PLX package (https://github.com/Polidea/react-native-ble-plx) to handle the direct connection with the Zebra printer and send raw CPCL commands to the printer. The issue this seemed to raise was the limitations in terms of any images that may need to be printed.

I'm very new to React and up until now I've never had to work with hardware either so I'm trying to learn as I go. If anyone can point me in the right direction it would be appreciated.

How to make Stickable TabView in ScrollView with ViewPager in react native?

$
0
0

I am making twitter profile like screen..UI Tree is

<ScrollView><Tabs>    ...</Tabs><ViewPager><View><FlatList/></View><View><FlatList/></View></ViewPager></ScrollView>

I want something like this

React native white blank screen when load website in a webview

$
0
0

Bug description: The site that I directed with Webview is opened in the ios simulator, Although not working in the andorid simulator.

To Reproduce:
react-native init AwesomeProjectcd AwesomeProjectreact-native run-android

&& my code

code

Expected behavior:. Work same as ios simulator

Screenshots/Videos:Screen Shot 2020-06-01 at 01 21 55Screen Shot 2020-06-01 at 01 22 16

Environment: - OS: macOS - OS version: 10.15.3 - react-native version: 0.62.2 - react-native-webview version: 10.2.3

Firebase Storage: String does not match format 'base64': Invalid character found

$
0
0

I'm working on a react-native and I need to upload an image to Firebase using Firebase Storage. I'm using react-native-image-picker to select the image from the phone which gives me the base64 encoded data.

When I try to upload the image to Firebase it gives me the error Firebase Storage: String does not match format 'base64': Invalid character found but I already checked if the string is a valid base64 string with regex and it is!

I already read a few answers from here but I tried all that. Here's my code:

function uploadImage(image){  const user = getCurrentUser();  const refImage = app.storage().ref(`profileImages/${user.uid}`);  refImage.putString(image, 'base64').then(() => {    console.log('Image uploaded');  });}

The image picker:

ImagePicker.showImagePicker(ImageOptions, (response) => {  if (response.didCancel) {    console.log('User cancelled image picker');  }  else if (response.error) {    console.log('ImagePicker Error: ', response.error);  }  else if (response.customButton) {    console.log('User tapped custom button: ', response.customButton);  }  else {    uploadImage(response.data);  }});

Google Nearby Messages API: Attempting to perform a high-power operation from a non-Activity Context

$
0
0

Calling subscribe on the Google Nearby Messages API for Android results in the Exception:

Attempting to perform a high-power operation from a non-Activity Context

My code:

public void subscribe(final Promise promise) {    _messagesClient = Nearby.getMessagesClient(reactContext.getApplicationContext(), new MessagesOptions.Builder().setPermissions(NearbyPermissions.BLE).build());    _subscribeOptions = new SubscribeOptions.Builder()            .setStrategy(Strategy.BLE_ONLY)            .setCallback(new SubscribeCallback() {                @Override                public void onExpired() {                    super.onExpired();                    emitErrorEvent(EventType.BLUETOOTH_ERROR, true);                }            }).build();    Log.d(getName(), "Subscribing...");    if (_messagesClient != null) {        if (_isSubscribed) {            promise.reject(new Exception("An existing callback is already subscribed to the Google Nearby Messages API! Please unsubscribe before subscribing again!"));        } else {            _messagesClient.subscribe(_listener, _subscribeOptions).addOnCompleteListener(new OnCompleteListener<Void>() {                @Override                public void onComplete(@NonNull Task<Void> task) {                    Exception e = task.getException();                    Log.d(getName(), "Subscribed!"+ e.getLocalizedMessage());                    if (e != null) {                        _isSubscribed = false;                        promise.reject(e);                    } else {                        _isSubscribed = true;                        promise.resolve(null);                    }                }            });        }    } else {        promise.reject(new Exception("The Messages Client was null. Did the GoogleNearbyMessagesModule native constructor fail to execute?"));    }}

Note: The promise Parameter is from React Native, I'm trying to create a wrapper for the API.

At the Log.d event inside my OnCompleteListener, it prints:

Subscribed!2803: Attempting to perform a high-power operation from a non-Activity Context

I do have the API Key and the required Permissions (BLUETOOTH, BLUETOOTH_ADMIN) in my AndroidManifest.xml.

On iOS the API calls work fine.


React Native Vertical Delivery Progress Bar

$
0
0

How can I put a Vertical progress bar on React Native

I need to make a delivery bar progress

Example: driver is at point A and needs to go to point B ...

Deep link is not working in android react native

$
0
0

I have setup a deep link in android react native. I wanted to skip the options menu when click on the link, for that I have added .well-known/assetlinks.json file over my domain address.I can see no errors when I verify using https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=&relation=delegate_permission/common.handle_all_urls, no Error is shown

assetlinks.json file:

[{"relation": ["delegate_permission/common.handle_all_urls"],"target": {"namespace": "android_app","package_name": "<package-name>","sha256_cert_fingerprints": [<SHA>] }}]

Response of digitalassetlinks

{"statements": [ {"source": {"web": {"site": "<domain>."    }  },"relation": "delegate_permission/common.handle_all_urls","target": {"androidApp": {"packageName": "<package-name>","certificate": {"sha256Fingerprint": "<SHA>"      }    }  }}],"maxAge": "59.999586063s","debugString": "********************* ERRORS *********************\nNone!\n********************* INFO MESSAGES *********************\n* Info: The following statements were considered when processing the request:\n\n---\nSource:

AndroidManifest:

<intent-filter android:label="@string/app_name" android:autoVerify="true"><action android:name="android.intent.action.VIEW" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="http" android:host="domain" /><data android:scheme="https" /></intent-filter>

MainActivity.java

public class MainActivity extends ReactActivity {/** * Returns the name of the main component registered from JavaScript. * This is used to schedule rendering of the component. */@Overrideprotected String getMainComponentName() {    return "<package-name>";}@Overrideprotected ReactActivityDelegate createReactActivityDelegate() {    return new ReactActivityDelegate(this, getMainComponentName()) {        @Override        protected ReactRootView createRootView() {            return new RNGestureHandlerEnabledRootView(MainActivity.this);        }    };}@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    // ATTENTION: This was auto-generated to handle app links.    Intent appLinkIntent = getIntent();    String appLinkAction = appLinkIntent.getAction();    Uri appLinkData = appLinkIntent.getData();}

}

FYI: When did the recommended exercise for IOS, it's working fine.

[react-native]how Can i download osm tiles for offline use?

$
0
0

please help me sir/ma'am. I want to implement offline map but I am struggling with 2 days. i can't find any proper documentation or find any proper answer to how to download tiles for offline usage.

import { LocalTile } from 'react-native-maps';<MapView  region={this.state.region}  onRegionChange={this.onRegionChange}><LocalTile   /**    * The path template of the locally stored tiles. The patterns {x} {y} {z} will be replaced at runtime    * For example, /storage/emulated/0/mytiles/{z}/{x}/{y}.png    */   pathTemplate={this.state.pathTemplate}   /**    * The size of provided local tiles (usually 256 or 512).    */   tileSize={256}  />`enter code here`</MapView>

How to create a dictionary app in React-Native?

$
0
0

What are the options/approaches available in React-Native for developing a mobile dictionary app.

How to use google maps offline in react native

$
0
0

I'm trying to enable users to use maps offline in my react native App, I'm using react-native-maps

I want to provide the offline mode just for a predefined area (let's say a city), therefore I need to download all the needed tiles which will be a huge number of images, so I wonder if there is a way in the google map API to download an area of the map (like in google map app)?
from the documentation it is possible to enable caching, which I do the same thing (according to the doc) however, In my case I don't want to cache every place that the user go to, as I said I just want to cache/download a predefined area.
EDIT 1
react-native-maps support offline navigation for that, I need to use this code :

<LocalTile pathTemplate={this.state.pathTemplate} tileSize={256}/>

with pathTemplate point to my tiles location which had to have the following hierarchy :

location/{z}/{x}/{y}

therefore my real probleme is how to get the tiles for my area.
I can do it manually by saving tiles from the google maps tile server, however I don't know if it is legal and also it will take a lot of time and calculation (when zooming in, I need to calculate the coordinated of the next tiles )
so It will be nice, if google map API provide a way to download an area's tile (with needed zoom),
another alternative would be using another map provider like OpenStreetMAp, but here also, I need to find a way to download all tiles at once

Continuous integration using Appium for React Native app

$
0
0

I am in the process of creating end to end tests for a React Native app using Appium. When I run the tests locally I do the following:

  1. Open android studio and start an emulator
  2. Start appium
  3. Run the tests

Is it possible to use Appium within a CI pipeline (I'm using Azure)?

After doing some research I see some people use Sauce Labs (or similar options) to run their Appium tests on devices during their CI pipeline. But what if using Sauce Labs or similar is not an option.

Is there any way to somehow create a device within the pipeline that can be used for testing? (ie: No third party services like Sauce labs.). Maybe some kind of headless device that can be run within the pipeline to test against?

Black screen on emulator

$
0
0

I recently uninstalled android studio and realize my emulator is no longer working upon updating to the latest version. Tried looking on past problems in stackoverflow and couldnt resolve

I have tried wiping data, cold boot and installing/update SDK packages (not exactly sure if I install the correct ones), the emulator would not turn on

Please help

https://i.imgur.com/YT6Rh9t.png

Edit:"An error occurred while creating the AVD. See idea.log for details. ubuntu 16.04"I also got this error when I delete an AVD device, not sure if its related


React Native build failed in android, @react-native-community/cli-platform-android /native_modules.gradle' line: 130

$
0
0

I've upgraded my ReactNative project from 0.59 to 0.61.2 iOS is building fine but in android i'm facing the issue in @react-native-community/cli-platform-android module.

My settings.gradle file

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

My build.gradle file

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

I get the following error while building the app.

> Task :app:generatePackageList FAILEDFAILURE: Build failed with an exception.* Where:Script '/Users/yashwanth_c/Documents/projects/MobileApp/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 130* What went wrong:Execution failed for task ':app:generatePackageList'.> ReactNativeModules$_generatePackagesFile_closure3* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.* Get more help at https://help.gradle.orgDeprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warningsBUILD FAILED in 5m 21s4 actionable tasks: 4 executed

As always i've cleaned the cache and deleted the node_module folder, tried many times but no luck. Also googled for more than a week but still not able to find a fix, any advice is appreciated.

Invariant violation: ViewPagerAndroid has been removed from React Native - ERROR ON IOS

$
0
0

enter image description here

Hi guys! This is an error I struggle with for the past 2 days. It happens when trying to run the react native project on ios. My package.json doesn't even have @react-native-community/viewpager dependency and I don't use it in my project, yet after 'npm install' , there are viewpager dependencies in my package-lock.json and in node_modules too.

enter image description hereenter image description here

Do I need viewpager to run this project? If yes, how can I make it work and if not, how do I eliminate it completly?

The development server returned response error code:404 react native

$
0
0

I am trying to run react native app like this in cmd

cd C:\Users\User\Desktop\jsreact-native run-android

enter image description here

Alert work well on Debug but not showing in release mode on Android (React Native)

$
0
0

Description

The application correctly displays all the alerts and toast messages in the debugging phase. The moment the build is built all the messages disappear.

React Native version:

System:  OS: macOS 10.15.5  CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz  Memory: 267.94 MB / 8.00 GB  Shell: 3.2.57 - /bin/bashBinaries:  Node: 13.8.0 - /usr/local/bin/node  Yarn: 1.22.4 - ~/.yarn/bin/yarn  npm: 6.13.7 - /usr/local/bin/npm  Watchman: 4.9.0 - /usr/local/bin/watchmanSDKs:  iOS SDK:    Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1IDEs:  Android Studio: 3.6 AI-192.7142.36.36.6392135  Xcode: 11.3.1/11C505 - /usr/bin/xcodebuildnpmPackages:  react: 16.8.3 => 16.8.3   react-native: 0.59.9 => 0.59.9 npmGlobalPackages:  react-native-cli: 2.0.1  react-native: 0.61.5

Expected Results

That alerts are shown in build mode.

I attach the package.json to see if there are any known incompatibilities:

{"name": "myapp","version": "0.0.1","private": true,"scripts": {"start": "node node_modules/react-native/local-cli/cli.js start","android": "react-native run-android","test": "jest"  },"dependencies": {"@react-native-community/async-storage": "^1.11.0","axios": "^0.18.0","haversine": "^1.1.0","jetifier": "^1.6.5","moment": "^2.22.2","react": "16.8.3","react-native": "0.59.9","react-native-actionsheet": "^2.4.2","react-native-android-location-services-dialog-box": "^2.8.2","react-native-auto-height-image": "^1.1.0","react-native-cached-image": "^1.4.3","react-native-cli": "1.3.0","react-native-fbsdk": "1.0.4","react-native-gesture-handler": "^1.6.0","react-native-global-font": "^1.0.2","react-native-google-places": "3.1.2","react-native-image-crop-picker": "^0.24.1","react-native-image-pan-zoom": "^2.1.10","react-native-image-placeholder": "^1.0.14","react-native-iphone-x-helper": "^1.2.0","react-native-keyboard-manager": "^4.0.13-10","react-native-maps": "0.25.0","react-native-maps-super-cluster": "^1.4.1","react-native-modal-datetime-picker": "^5.1.0","react-native-open-maps": "^0.3.3","react-native-progress": "^3.4.0","react-native-push-notification": "3.1.3","react-native-reanimated": "^1.7.0","react-native-router-flux": "^4.0.6","react-native-screens": "^2.0.0-beta.8","react-native-share": "^1.2.1","react-native-snap-carousel": "^3.7.4","react-native-swiper": "^1.5.13","react-native-vector-icons": "^4.6.0","react-native-view-shot": "^2.5.0","react-redux": "^5.0.7","redux": "^3.7.2","redux-persist": "^4.10.1","redux-persist-transform-filter": "0.0.15","redux-thunk": "^2.2.0"  },"devDependencies": {"babel-jest": "23.6.0","jest": "23.6.0","metro-react-native-babel-preset": "0.51.1","react-test-renderer": "16.6.3"  },"jest": {"preset": "react-native"  },"rnpm": {"assets": ["./src/fonts"    ]  }}

Thanks in advance to those who want to help me.

React Native broadcast and discover nearby devices

$
0
0

First off: This is more of a logical question than a code-specific question.

I am trying to create a view similar to the iOS AirDrop view where users can see other users. This means, every user needs to broadcast/advertise their custom username, which can be seen by all other nearby users that scan the area.

I have tried using react-native-ble-plx, since I read on the Apple developer forum that iPhones can act as BLE (bluetooth low energy) peripherals. (Also, I read that newer Android devices support this as well)

I've tried the following:

import ble, { BleManager, Characteristic } from 'react-native-ble-plx';// ...const bleManager = new BleManager();bleManager.startDeviceScan(null, null, async (e, d) => {    if (e) console.log(`BT Error: ${JSON.stringify(e)}`);    if (d && d.id && d.isConnectable) {        console.log(`Connecting to: ${d.id} ('${d.name}')...`);        const device = await d.connect();        const services = await device.services();        console.log('services: ', services.join(', '));        const characteristic = await device.writeCharacteristicWithResponseForService(BLE_SERVICE_UUID, BLE_SERVICE_UUID, '123');        console.log(`Characteristics: ${JSON.stringify(characteristic)}`);    }});

But I haven't found a way to broadcast a value which others can read, is that even possible with BLE?

I've also looked into beacons (specifically react-native-beacons-manager), but I'm not sure if that is what I want since an Android/iOS phone is not a 'beacon'..

So my question is: Are there technologies/libraries that allow broadcasting of a message (my custom username) which others can see? Ideally I want to communicate between them, like exchanging a token, but that's not a requirement.

I'd appreciate any help or pointings into the right direction here, thanks!

Viewing all 28463 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>