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

Is it possible to change the default zoom behavior in Google Maps?

$
0
0

I was wondering if it is possible to change the default behavior zoom, the default seems to change the viewport in all directions, but I want to keep the bottom where it is, and only resize the other three, pitch is also necessary.

enter image description hereenter image description here

I want the marker to keep it's position at the bottom as shown in first pic when zoomed in/out.

Any help and guide to how this can be achieved would be appreciated.


React-native-camera appears as black screen

$
0
0

I'm trying to implement an eKYC for my application, which included 3 camera screens (2 screens with back side camera, 1 with front side camera)

On some Android devices (Samsung Note 8, Xiaomi Redmi Pro 8, Vsmart Joy 3, ...), the third screen's camera (front side camera) is not working (black screen).

I've tried to read the errors from Android logcat and I receive this error:

2021-01-11 12:29:00.704 3973-13086/com.******.vn W/CameraBase: An error occurred while connecting to camera 1: Status(-8): '8: connectHelper:1648: Too many cameras already open, cannot open camera "1"'

Things I've tried: use NavigationEvents and withNavigationFocus to render the camera when current screen is focused

const [isFocus, setFocus] = useState<boolean>(false)
<NavigationEvents onWillFocus={onFocus} onWillBlur={onBlur}></NavigationEvents>
{isFocus && props.isFocused && (<RNCamera      ref={refCamera}      style={styles.preview}      type={RNCamera.Constants.Type.front}      captureAudio={false}      onCameraReady={() => console.log('oncameraready')}      onFacesDetected={onFaceDetected}><View style={styles.progressBarContainer}><Progress.Bar          color={Colors.asEastOcean}          progress={progress}          width={200}          style={styles.progressBar}          borderColor={Colors.white}          unfilledColor={Colors.white}        /></View></RNCamera>  )}

But the camera on the third screen (front side camera) still not work. The other two work perfectly.Is there any way to fix this, thank you very much in advance!

Note: If I change the order and render the third screen first, the front side camera is working normally.

Is there any SharedPreferences reset condition except the removal of an app?

$
0
0

I'm using React Native to build an android/ios app. I'm using expo-secure-store with the bare React Native app and expo-secure-store saves data in SharedPreferences as encrypted on Android.

After I was updating my app, I received many reports from users that their data in SharedPreferences are reset and lost. On iOS, I didn't get such reports.

Is there any condition to reset data saved in SharedPreferences except the removal of the app?

As far as I know, data saved on SharedPreferences remains during its update. Is it wrong? I could not find any answer from the documentation. Please let me know about it.

login with outlook successfully but Redirect Url not working after login successfully - react native

$
0
0

am working on react native app and using react-native-app-auth library login with outlook,when i run app on ios device then redirect url working fine.but when i run app on android device then then login successfully but redirect url not working.my redirectUrl is : 'urn:ietf:wg:oauth:2.0:oob',i try this but not work.

manifestPlaceholders = [`enter code here`appAuthRedirectScheme: 'com.googleusercontent.apps.urn:ietf:wg:oauth:2.0:oob']

https connection in Android react-native not working on physical device after build

$
0
0

I created a simple app with react-native, using expo & Axios (for server requests)

Before build, while developing, all https requests worked fine.

After build, when running the apk on a physical device, https is not working at all.

The error I get with Logcat is "Network Error".Other Internet connections (after build) in the app do work, like webview opening a web page or Firebase connections also.

    analyzerApi.post('/analyze', urls) .then((res) => { dispatch({type: 'get_result', payload: res.data.analysis})}).catch(err => console.log("Error in getting analyze.. " ,err.name, err.message))

(analyzerApi is an axios instance with baseUrl directed to my server)

Open device flashlight in React Native

$
0
0

I work on react native app and I want open and close device flashlight. It is possible without any camera module?

react-native : can't push to git because of hprof file

$
0
0

I would like to push my project into the github, however i just notice there is a file called java_pid14920.hprof inside the android folder and cause around 300MB

remote: error: File android/java_pid14920.hprof is 301.75 MB; this exceeds GitHub's file size limit of 100.00 MB

I wonder it is safe to delete this file ?

How to read the parameters passed in react native cli commands programmatically?

$
0
0

How to read the variant value passed in react native cli command npx react-native run-android --variant=release programmatically?


Error app.default.object is not a function

$
0
0

I am new to react-native and I'm trying to help on a project. I started by refactoring the code to have a better file structure. I implemented the barrels and added the path aliases (module resolver).Everything works fine in vscode but when I run on android, it gives me this error:

TypeError:_app.default.objects is not a function. {...} _app.default.objects is undefined.

Here is my tsconfig:

"baseUrl": ".","paths": {"@assets/*": ["./app/assets/*"],"@components/*": ["./app/components/*"],"@components": ["./app/components"],"@containers/*": ["./app/containers/*"],"@db": ["./app/db"],"@db/*": ["./app/db/*"],"@languages/*": ["./app/languages/*"],"@navigation/*": ["./app/navigation/*"],"@styles/*": ["./app/styles/*"],"@services": ["./app/services"],"@services/*": ["./app/services/*"],"@utils": ["./app/utils"],"@utils/*": ["./app/utils/*"],    }

And my babel-config:

  plugins: [    ['module-resolver',      {        root: ['./app'],        extensions: ['.ios.js', '.android.js', '.js', '.json', '.ts', '.tsx'],        alias: {'@languages': './app/languages','@db': './app/db','@styles': './app/styles','@services': './app/services','@utils': './app/utils','@assets': './app/assets','@navigation': './app/navigation','@components': './app/components','@containers': './app/containers',        },      },    ],  ]

It raises the error each time I use the db:Here is my import:

import { Song } from '@db'import { GlobalSettings } from "@db/GlobalSettings";

also if I use something like that:

const [songs, setSongs] = useState(Song.getAll())

but it's the same with everything else from the db directory.

Thanks!

Making presets using Photo editor sdk

$
0
0

I'm looking to develop a mobile app that will be able to implement presets using photoeditor sdk.Does anybody know if I can edit one photo in Photoeditor sdk and then save these settings and use them on another photo later?

thanks ahead

expo web hide bottom navigation bar when keyboard show

$
0
0

I would like to hide my bottom navigation bar on mobile device when keyboard is show.I use Expo 40I have added in definition option bottom bar keyboardHidesTabBar: true, such as:

const TabBot = createMaterialBottomTabNavigator();...return(<TabBot.Navigator       initialRouteName="np"      tabBarOptions={{        keyboardHidesTabBar: true      }}      barStyle={TabBotOpt}>...

I have add "softwareKeyboardLayoutMode": "pan" in android section into app.json file,but when I open the website from mobile phone (android) I have this:

enter image description here

It is possible to hide bottom Tab Navigation when keyboard is open?

Could not list contents of 'third-party/glog-0.3.4/test-driver'. Couldn't follow symbolic link

$
0
0

I have a project build on react-native version 0.55.4. It was woking fine on old system. I have to change system due to some reasons. I setup on new system, I am able to run project using react-native run-android but when building a signed APK using ./gradlew assembleRelease I am receiving following error.

Task :app:processReleaseGoogleServicesParsing json file:<Project-Directory>/android/app/google-services.jsonFAILURE: Build failed with an exception.What went wrong:Could not list contents of'<Project-Directory>/node_modules/react-native/scripts/third-party/glog-0.3.4/test-driver'. Couldn't follow symbolic link.

I know this issue is already on stack overflow Invalid symlink in node_modules error when trying to deploy to simulator (RN 0.45). I have tried it. I have also tried following github question.

  1. https://github.com/facebook/react-native/issues/11212
  2. https://github.com/facebook/react-native/issues/14417
  3. https://github.com/facebook/react-native/issues/14548
  4. https://github.com/facebook/react-native/issues/14464

I have also tried following things.

  1. Deleting node modules and reinstalling them
  2. Deleting .bin folder in node modules
  3. Deleting react-native/third_party folder in node modules.
  4. Copying node modules from older system.
  5. Copying third-party and glog-0.3.4 from older system.
  6. Deleting test-driver file inside third-party folder.
  7. Unlinking test-driver file inside third-party folder.
  8. Installing automake-1.16 and creating a new alias of test-driver file inside third-party folder.

My java version is 1.8.0_201. My android studio version is 3.3.2. Projects react native version is 0.55.4. My mac os version is 10.14.4. My x code version is 10.2.

Please help.Thanks in advance.

How do I fix this error while running expo build android?

$
0
0

Hello, I need some help. So what's the case is I am trying to build an android apk from my expo react app. But when I try to do so, it fails. This is the output that is being shown when trying to run 'expo build:android'. It works fine when run on expo client on android. Please help me. The code for this project is in this GitHub repo.

✔ Choose the build type you would like: › apkChecking if there is a build in progress...Accessing credentials for setucoder in project storyhub5✔ Would you like to upload a Keystore or have us generate one for you?If you don't know what this means, let us generate it! :) › Generate new keystoreFailed to generate Android Keystore, it will be generated on Expo servers during the buildkeytool exited with non-zero code: 1Error: keytool exited with non-zero code: 1    at ChildProcess.completionListener (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:65:13)    at Object.onceWrapper (events.js:422:26)    at ChildProcess.emit (events.js:315:20)    at maybeClose (internal/child_process.js:1048:16)    at Socket.<anonymous> (internal/child_process.js:439:11)    at Socket.emit (events.js:315:20)    at Pipe.<anonymous> (net.js:673:12)    ...    at spawnAsync (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:26:19)    at createKeystore (/@expo/xdl@59.0.14/src/credentials/AndroidCredentials.ts:155:18)    at Object.generateUploadKeystore (/@expo/xdl@59.0.14/src/credentials/AndroidCredentials.ts:198:9)    at UpdateKeystore.provideOrGenerate (/usr/local/lib/node_modules/expo-cli/src/credentials/views/AndroidKeystore.ts:68:53)    at UpdateKeystore.open (/usr/local/lib/node_modules/expo-cli/src/credentials/views/AndroidKeystore.ts:39:22)    at CredentialsManager.run (/usr/local/lib/node_modules/expo-cli/src/credentials/route.ts:41:12)    at runCredentialsManager (/usr/local/lib/node_modules/expo-cli/src/credentials/route.ts:12:10)    at AndroidBuilder.collectAndValidateCredentials (/usr/local/lib/node_modules/expo-cli/src/commands/build/AndroidBuilder.ts:88:7)    at AndroidBuilder.run (/usr/local/lib/node_modules/expo-cli/src/commands/build/AndroidBuilder.ts:33:5)    at AndroidBuilder.command (/usr/local/lib/node_modules/expo-cli/src/commands/build/BaseBuilder.ts:40:7)

react-native run-android command failed, but gradlew installDebug work

$
0
0

I'm using react-native 0.43.3 on OSX.I tried to running app on Android and get message

react-native run-androidScanning 568 folders for symlinks in /Users/ruci.k/project/mayacrew/supermembers/supermembers/node_modules (5ms)JS server already running.Building and installing the app on the device (cd android && ./gradlew installDebug)...Could not install the app on the device, read the error above for details.Make sure you have an Android emulator running or a device connected and haveset up your Android development environment:https://facebook.github.io/react-native/docs/android-setup.html

./gradlew installDebug gave me some errors and fixed it all.Finally build get successed and app is working on Android device.

But react-native run-android command still not work.Only ./gradlew installDebug command work.

Is there anything can I check to use react-native run-android command?

I can't understand how could it happened.

How to use React Navigation universal links with path parameters on Android?

$
0
0

I have the following domain: https://demoproject.com

I would like to link all URL-s with /demo path parameter with my React Native application on Android so that for example URL https://demoproject.com/demo?a=1&b=2 will be linked, but any other URL with same domain, but different path parameters will be excluded.

Right now I am using React Navigation 5 like this:

const linking = {    prefixes: ['https://demoproject.com'],    config: {      DemoScreen: {          path: '/demo/*'      }    }};<NavigationContainer linking={linking}>

AndroidManifest.xml

<intent-filter 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="https" /><data android:host="demoproject.com" /></intent-filter>

Linking itself is working fine, but the problem is that all URL-s with prefix https://demoproject.com are being linked while I only want URL-s with /demo path parameter to be linked.

I have tried:

  • <data android:host="demoproject.com/demo" /> - none of the URL-s are linked
  • prefixes: ['https://demoproject.com/demo'] - all of the URL-s with https://demoproject.com domain are linked

Any ideas how to solve this or what am I doing wrong here?


How to add setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT) to react-native ScrollView in android?

$
0
0

I want to change the position of the scroll-bar in react-native to be in the left side (for RTL language), when using VERTICALScrollView/FlatList.

Since I didn't find any prop that allow to do so, I'm trying to add a native code to change it

setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT)

in node_modules\react-native\ReactAndroid\src\main\java\com\facebook\react\views\scroll\ReactScrollViewManager.java.

Just for testing, I tried to add this code in setScrollEnabled function (with some logs).See Here

But, unfortunately, It seems like this code doesn't affect the app. (even after removing and restarting the app).I cannot see the logs nor the affect of the scrollbar position :(

Any ideas how can I do it?

react-native version: 0.62.2

Thank a lot!

React Native Navigation Listener. How to stop page refresh when coming back from certain pages

$
0
0

I have logic that makes my home page refresh every time the component is mounted. I do want it to refresh every time I go from the home screen to the profile screen of my app for example, but I do not want it to reload when I open the search modal page and just dismiss it.. or click on an item in the home page and dismiss it.. its a bit excessive. My question is how would I be able to do this in an elegant way where I can pick and choose when I want the page to reload based on which page I'm going back from.

const HomeScreen = (props) => {    let TouchableCmp = TouchableOpacity    if (Platform.OS === 'android'&& Platform.Version >= 21) {        TouchableCmp = TouchableNativeFeedback    }    const [isLoading, setIsLoading] = useState(false)    const [httpError, setHttpError] = useState(false)    const homeTickets = useSelector((state) => state.tickets.homeTickets)    const dispatch = useDispatch()    const loadTickets = useCallback(async () => {        setHttpError(false)        setIsLoading(true)        try {            await dispatch(setTickets())            setIsLoading(false)        } catch (err) {            setHttpError(err.message)            setIsLoading(false)        }    }, [dispatch])    useEffect(() => {        const willFocusListener = props.navigation.addListener('willFocus',            loadTickets        )        return () => {            willFocusListener.remove()        }    }, [loadTickets])    useEffect(() => {        setIsLoading(true)        loadTickets().then(() => {            setIsLoading(false)        })    }, [dispatch, loadTickets])    if (isLoading)        return (<View style={styles.center}><LottieView                    source={require('../assets/srSPININGcompatibility.json')}                    style={{ height: 60, width: 60 }}                    autoPlay                    loop></LottieView></View>        )    if (httpError)        return (<View style={styles.center}><Text style={styles.errorStyle}>{`${httpError}`}</Text><View style={styles.refreshCont}><TouchableCmp onPress={loadTickets} activeOpacity={0.5}><Text                            style={{                                fontSize: 17,                                color: 'white',                                fontWeight: 'bold',                            }}>                            Refresh</Text></TouchableCmp></View></View>        )    return (<View style={styles.screen}><View style={styles.screen}><FlatList                    showsVerticalScrollIndicator={false}                    onRefresh={loadTickets}                    refreshing={isLoading}                    style={styles.flatList}                    data={homeTickets}                    keyExtractor={(item) => item.ticketID}                    renderItem={(itemData) => (<TicketCell                            companyName={itemData.item.company}                            requestor={itemData.item.requestedBy}                            dateStamp={itemData.item.workLogDate}                            issue={itemData.item.issue}                            companyPhone={itemData.item.businessPhone}                            navigation={props.navigation}                            ticketID={itemData.item.ticketID}                            goToDetails={() => {                                props.navigation.navigate({                                    routeName: 'HomeDetail',                                    params: { id: itemData.item.ticketID },                                })                            }}                        />                    )}                /></View></View>    )}

Recommendations for developing webview content on Android?

$
0
0

I've got a webview component that loads some html and javascript. The html + javascript is fairly large, and is compiled using webpack into a single page (html, javascript and css is all in one document). I'm having trouble figuring out a reasonably efficient approach to developing my web content, and could use some advice.

My webview is loaded like so:

<WebView        ref={inputRef}        source={          Platform.OS === 'ios'            ? require('../../assets/dist/index.html')            : { uri: 'file:///android_asset/index.html' }        }        style={{ height: 300 }}        javaScriptEnabled      />

This works on both platforms, the content is loaded and displayed as expected. The trouble comes with developing and making changes to that content.

On IOS, it's ideal -- any changes I make to index.html are automatically detected, and cause the webview to reload with the new content.

However, on Android, the only way I can see changes to 'index.html' is completely rebuild and redeploy the app, which makes things really difficult. I'm sure this is due to the require vs uri approaches necessary for the two platforms, but I'm not sure how to automatically deploy updates to android_assets, or if that's even possible without rebuilding?

I could also pass the index.html content as a raw string (i.e. using source={{ html: myHtml }}) but would this impact performance if myHtml is really large?

Is there a good way to configure Android webviews to see content changes without a complete rebuild?

Android build doesn't work (Duplicate class com.google.android.gms.internal.measurement.zzbt found in modules)

$
0
0

It worked fine until a week ago, but this week the build didn't work and I got the following error.I tried the following, but I haven't solved it yet.Any small thing is fine, so if anyone knows any hints or solutions, please let me know.

■What I tried

  • Downgrade classpath ("com.google.gms: google-services: 4.3.3")
  • Specify the versions of com.google.android.gms: play-services-measurement-sdk-api and com.google.android.gms: play-services-measurement
  • Gradle version upgrade, downgrade

■Development environment
react:16.9.0
react-native:0.61.5
Android Gradle:4.0.0
Firebase(google-services):4.3.4

> Task :app:checkDebugDuplicateClasses FAILED> Transform artifact play-services-measurement.aar (com.google.android.gms:play-services-measurement:17.4.4) with DexingWithClasspathTransform> Transform artifact play-services-measurement-impl.aar (com.google.android.gms:play-services-measurement-impl:17.4.4) with DexingWithClasspathTransformReactNativeFirebase WARNING: NPM package '@react-native-firebase/auth' depends on '@react-native-firebase/app' v8.3.1 but found v8.4.0, this might cause build issues or runtime crashes.501 actionable tasks: 7 executed, 494 up-to-dateD8: Type com.google.android.gms.internal.measurement.zzig is referenced as an interface from `com.google.android.gms.internal.measurement.zzby`.D8: Interface `com.google.android.gms.measurement.internal.zzhd(classpath class)` used as super class of `com.google.android.gms.measurement.AppMeasurement$UserProperty`.FAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:checkDebugDuplicateClasses'.> 1 exception was raised by workers:  java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.measurement.zzbt found in modules jetified-play-services-measurement-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement:17.4.4) and jetified-play-services-measurement-sdk-api-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-sdk-api:17.5.0)  Duplicate class com.google.android.gms.internal.measurement.zzbu found in modules jetified-play-services-measurement-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement:17.4.4) and jetified-play-services-measurement-sdk-api-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-sdk-api:17.5.0)  Duplicate class com.google.android.gms.internal.measurement.zzfw found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)  Duplicate class com.google.android.gms.internal.measurement.zzfy found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)  Duplicate class com.google.android.gms.internal.measurement.zzfz found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)  Duplicate class com.google.android.gms.internal.measurement.zzga found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)  Duplicate class com.google.android.gms.internal.measurement.zzgb found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)  Duplicate class com.google.android.gms.measurement.internal.zzgz found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)  Duplicate class com.google.android.gms.measurement.internal.zzik found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)  Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

Trouble checking if props is undefined

$
0
0

So I have a page in my project that has a get and then it passes the response to a const, as below.

const [reference, setReference] = useState([])   useEffect(() => {            api.get(`/${props.route.params.index}`).then( response => {                setReference(response.data)                setLegendaryAction(response.data.legendary_actions)            }).catch( error =>                 console.log(error)             )        }, [])

Then I pass diferent parts of the reference to multiple instances of the same component.As the following example, there is reference.action and reference.reaction. I will always have an action, but sometimes Reaction will be undefined, so I'm cheking if it's true before I render my component.

<ReferenceDetails                     detailTitle="Actions"                     details={reference.actions}                />                {reference.reactions && <ReferenceDetails                          detailTitle="Reactions"                          details={reference.reactions}                    />                }

But it gives me this error:

Error: Text strings must be rendered within a component.

But when I do console.log(reference.reactions) it returns undefined.Could someone shed some light here please?

Viewing all 29593 articles
Browse latest View live


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