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

How to set callback function to react native UI component (Android)

$
0
0

I followed react native module and react-native UI component docs. As described we can set a callback when creating an RN module, but not with react-native UI component on over the RN Bridge. Events can be implemented on UI components, But my requirements are set callback functions from RN to UI component view manager object.

My problems are:

  1. Can we implement Callbacks in UI components?
  2. Are there any examples or references online?
  3. If there are no official approaches, are there any hacks to overcome this issue?

Cannot see all devices with Bluetooth (not interested in establish connections)

$
0
0

I would like clarification on device scanning using bluetooth in React Native. I state one thing: I am not interested in establishing connections with the devices, it is enough for me to know that they are present. I am using react-native-ble-plx library and I have tried it both on Android devices (Samsung J5 and Huawei P8) and on iOS devices (two iPhone 8 and one iPad) but also on laptops (Lenovo Thinkpad and two MacBook Pro) plus various non-personal devices (Smart TV, home speakers, smart watch and so on.

I noticed that not all devices are capable of scanning each other. I am using the startDeviceScan function, for example with the Samsung J5 I can see all the IoT devices and all the iOS devices but I cannot see the Huawei. Worse still, with iPhones I can see all IoT devices, but I can't see any of the Android smartphones.

What are the causes? What can I do to solve this problem (if it were possible)? Are there other libraries that would allow me to see the signal from other devices using React Native?

React Native linking Error: ENOENT: no such file or directory

$
0
0

I used Windows Subsystem for Linux, maybe this is the problem? I will be glad of any help, I will provide the information you need.

error Linking "@react-native-community/cameraroll" failed. Run CLI with --verbose flag for more details.Error: ENOENT: no such file or directory, open 'C:\Users\Username\Desktop\react-native-app\android\src\main\res\values\strings.xml

React native Android fade animation flashing in loop

$
0
0

In React Native 0.61, I've got a pulse animation happening. It works properly on iOS, but not on Android.

Here's the code:

  state = {fadeAnim: new Animated.Value(1),springValue: new Animated.Value(0),  };  runPulseAnimation() {Animated.loop(  Animated.parallel([    Animated.timing(this.state.springValue, {      toValue: 1,      friction: 3,      tension: 40,      duration: 1500,    }),    Animated.timing(this.state.fadeAnim, {      toValue: 0,      duration: 1500,    }),  ]),).start();  }

The loop happens properly, however on Android, right after the animation ends, opacity switches back to 1 before the spring value resets. Again, this doesn't happen on iOS.

Anyone run into something like this?

WebView not loading page, after form submit

$
0
0

Looking to solve a problem that I have with React Native with the component of WebView link, I did a direct test in android obtaining the same error when trying to load a specific page.

The first page contains a form, but after entering the user data and submitting, it does not show the next page, it only shows a message of "Loading ..."

This is my android code:

public class WebViewActivity extends Activity {private WebView webView;public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.webview_main);    webView = (WebView) findViewById(R.id.webView1);    webView.clearCache(true);    webView.setWebViewClient(new WebViewClient());    webView .getSettings().setJavaScriptEnabled(true);    webView .getSettings().setDomStorageEnabled(true);    webView.loadUrl("https://auth.mercadopago.com.ve/authorization?client_id=6012820321480442&response_type=code&platform_id=mp&redirect_uri=https%3A%2F%2Fus-central1-quicpyapp.cloudfunctions.net%2FmercadoPagoConnect%3FuserId%3DcljvLoUJNoOHfe636ofMHduXu2o2");}

}

I have also been able to observe that the page works correctly if I comment the following line:

//webView.setWebViewClient(new WebViewClient());

The test user data are as follows:"user": "TETE5691798", "password": "qatest6094"

Any help would be appreciated.

Problem with Signed APK when using Hermes

$
0
0

I created a new project with react native in version 0.62, I activated Hermes following the tutorial: https://reactnative.dev/docs/hermes

I can generate APK and run the project normally, however, when I try to create an APK signed by either Android Studio or react-native, I get the error message:

org.gradle.process.internal.ExecException: Process 'command' cmd '' finished with non-zero exit value

If I disable Hermes, the APK is generated without errors. This problem also does not occur in projects created with version 0.61.5 of react-native.

Full screen landscape video in React Native - Android

$
0
0

I'm trying to build a view which on changing to lancscape rotation, will present the video in 100% width/height.

I'm running into an issue through the emulator where the Video in landscape does not always stretch to 100% width and shows a grey bar instead. Also I've had mixed experiences with the emulator being accurate to what's rendered on the actual device - with a device it goes to about 50% of the screen width whereas on the emulator it's usually 90% if not 100%.

Video component:

<Video    ref={this.videoRef}    source={{      uri: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',    }}    style={this.state.fullscreen ? styles.fullscreenVideo : styles.video}    controls={false}    resizeMode={'contain'}    onLoad={this.onLoadEnd}    onProgress={this.onProgress}    onEnd={this.onEnd}    paused={!this.state.play}            />

Styles:

video: {    height: Dimensions.get('window').width * (9 / 16),    width: Dimensions.get('window').width,    backgroundColor: 'black',},fullscreenVideo: {    height: "100%",    width: "100%",    backgroundColor: 'black',},

Task 'installDebug' not found in project ':app' - run-android after creating project

$
0
0

After creating a react native project, I tried to run it on my android device. I enter adb devices into the terminal, I saw my device. I ran react-native run-android. And after a while Task 'installDebug' not found in project ':app' popped up.

Jetifier found 962 file(s) to forward-jetify. Using 4 workers...info Starting JS server...'D:\Android\android-sdk\platform-tools' is not recognized as an internal or external command, operable program or batch file.info Launching emulator...error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.info Installing the app...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_warningsFAILURE: Build failed with an exception.* What went wrong:Task 'installDebug' not found in project ':app'.* Try:Run gradlew tasks to get a list of available tasks. 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.orgBUILD FAILED in 15serror Failed to install the app. Make sure you have the Android development environment set up:https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081FAILURE: Build failed with an exception.* What went wrong:Task 'installDebug' not found in project ':app'.

Here is react-native info

info Fetching system and libraries information...System:    OS: Windows 7 6.1.7601    CPU: (4) x64 Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz    Memory: 881.91 MB / 3.97 GB  Binaries:    Node: 10.16.1 - C:\Program Files\nodejs\node.EXE    Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD    Watchman: Not Found  SDKs:    Android SDK: Not Found  IDEs:    Android Studio: Version  3.2.0.0 AI-181.5540.7.32.5014246  Languages:    Python: Not Found  npmPackages:    @react-native-community/cli: Not Found    react: 16.11.0 => 16.11.0    react-native: 0.62.0 => 0.62.0  npmGlobalPackages:    *react-native*: Not Found

I ran gradlew tasks and I did not see installDebug under the install tasks. I am sure that I set up the environment variables correctly, including android SDK, JDK. I tried reinstalling react-native. I put the location of my sdk in local.properties under android folder. I ran gradlew installDebug and installDebug not found in root project '[app's name]' appeared. None of the solutions on the internet worked.

Can anyone please help me to sort out this?Thank you.


react native 'installDebug' not found in project ':app'

$
0
0

when i run: $ react-native run-android

Task 'installDebug' not found in project ':app'.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

details:

"react-native": "0.62.0","react-native-fbsdk": "^1.1.2"


Gradle 6.0.1

Build time: 2019-11-18 20:25:01 UTCRevision: fad121066a68c4701acd362daf4287a7c309a0f5

Kotlin: 1.3.50Groovy: 2.5.8Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019JVM: 1.8.0_231 (Oracle Corporation 25.231-b11)OS: Windows 10 10.0 amd64

Call Android Library in React Native

$
0
0

I have a following code in Native Android

package org.jitsi.example;import android.os.Bundle;import android.support.v4.app.FragmentActivity;import org.jitsi.meet.sdk.JitsiMeetView;import org.jitsi.meet.sdk.ReactActivityLifecycleCallbacks;// Example//public class MainActivity extends FragmentActivity implements JitsiMeetActivityInterface {    private JitsiMeetView view;    @Override    protected void onActivityResult(            int requestCode,            int resultCode,            Intent data) {        JitsiMeetActivityDelegate.onActivityResult(                this, requestCode, resultCode, data);    }    @Override    public void onBackPressed() {        JitsiMeetActivityDelegate.onBackPressed();    }    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        view = new JitsiMeetView(this);        JitsiMeetConferenceOptions options = new JitsiMeetConferenceOptions.Builder()            .setRoom("https://meet.jit.si/test123")            .build();        view.join(options);        setContentView(view);    }    @Override    protected void onDestroy() {        super.onDestroy();        view.dispose();        view = null;        JitsiMeetActivityDelegate.onHostDestroy(this);    }    @Override    public void onNewIntent(Intent intent) {        JitsiMeetActivityDelegate.onNewIntent(intent);    }    @Override    public void onRequestPermissionsResult(            final int requestCode,            final String[] permissions,            final int[] grantResults) {        JitsiMeetActivityDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);    }    @Override    protected void onResume() {        super.onResume();        JitsiMeetActivityDelegate.onHostResume(this);    }    @Override    protected void onStop() {        super.onStop();        JitsiMeetActivityDelegate.onHostPause(this);    }}

Also

JitsiMeetConferenceOptions options = new JitsiMeetConferenceOptions.Builder()    .setServerURL(new URL("https://meet.jit.si"))    .setRoom("test123")    .setAudioMuted(false)    .setVideoMuted(false)    .setAudioOnly(false)    .setWelcomePageEnabled(false)    .build();

React native doesnt well support this library so i am looking to call this android library inside of react native .So i have created following class

public class ToastModule extends ReactContextBaseJavaModule  {    private static final String DURATION_SHORT_KEY = "SHORT";    private static final String DURATION_LONG_KEY = "LONG";    public ToastModule(ReactApplicationContext reactContext) {        super(reactContext);    }    @Override    public String getName() {        return "CustomToastAndroid";    }    @Override    public Map<String, Object> getConstants() {        final Map<String, Object> constants = new HashMap<>();        constants.put(DURATION_SHORT_KEY, Toast.LENGTH_SHORT);        constants.put(DURATION_LONG_KEY, Toast.LENGTH_LONG);        return constants;    }    //this @ReactMethod will be available in javascript environment    @ReactMethod    public JitsiMeetConferenceOptions show(String message, int duration) {        Log.d(getName(),"toast called with "+message);        Toast.makeText(getReactApplicationContext(), "Yes John its coming from android", duration).show();        JitsiMeetConferenceOptions options=null;        try {            options = new JitsiMeetConferenceOptions.Builder()                   .setServerURL(new URL("https://meet.jit.si"))                   .setRoom("test123")                   .setAudioMuted(false)                   .setVideoMuted(false)                   .setAudioOnly(false)                   .setWelcomePageEnabled(false)                   .build();            Toast.makeText(getReactApplicationContext(), message, duration).show();        } catch (MalformedURLException e) {            e.printStackTrace();        }        return options;    }}

This below packager will communicate to react native

public class CustomReactPackage implements ReactPackage {    @Override    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {        return Collections.emptyList();    }    @Override    public List<NativeModule> createNativeModules(            ReactApplicationContext reactContext) {        List<NativeModule> modules = new ArrayList<>();        modules.add(new ToastModule(reactContext));        return modules;    }}

if i call CustomToastAndroid.show("Testing this package from andorid",100); this i can see toast message in my app but i need to access jitsi meet features.can nay one help on integrating this to react native

Ref:https://github.com/jitsi/jitsi-meet/blob/master/android/README.md#use-pre-build-sdk-artifactsbinaries

Android Version Not found while running npx react-native doctor

$
0
0

So I asked a question before here about setting up react native environment for windows. But I got error about android licensing so someone suggested me to run npx react-native doctor which resulted in one error which is

this errorHere is the list of SDK installedenter image description herePlease help me what does this error means

Problems with Stack Navigators nested in Drawer Navigators

$
0
0

I am trying to update the react navigation from 3.x to 5.x.

Current Behavior

I have an authentication flow in a stack navigator as follows

import React, { useState } from 'react';import { NavigationContainer } from '@react-navigation/native';import { createStackNavigator } from '@react-navigation/stack';import AuthLoaderScreen from '../screens/AuthLoaderScreen';import HomeNavigation from './navigations/HomeNavigation';import AuthNavigation from './navigations/AuthNavigation';import { AuthContext, HomeContext} from '../shared/contexts';const Stack = createStackNavigator();const Routes = () => {  const [isLoading, setIsLoading] = useState(true);  const [isLoggedIn, setIsLoggedIn] = useState(false);  const [isNewAccount, setIsNewAccount] = useState(false);  const [user, setUser] = useState({}); return (<NavigationContainer><AuthContext.Provider value={{            loaded: () => setIsLoading(false),            login: () => setIsLoggedIn(true),            signup: user => {              setIsNewAccount(true);              setUser(user);              setIsLoggedIn(true);            },            signout: () => {              setIsLoggedIn(false);            }          }}><HomeContext.Provider value={{            newAccount: isNewAccount,            user          }}><Stack.Navigator            screenOptions={{              header: () => null,            }}>          {isLoading          ? (<Stack.Screen name="AuthLoaderScreen" component={AuthLoaderScreen} />          ) : (            null          )}          {!isLoggedIn          ? (<Stack.Screen name="AuthNavigation" component={AuthNavigation} />          )          : (<Stack.Screen name='HomeNavigation' component={HomeNavigation} />          )}</Stack.Navigator></HomeContext.Provider></AuthContext.Provider></NavigationContainer> );  };export default Routes;

The problem appears when I'm in the "HomeNavigation":

import React from 'react';import { createDrawerNavigator } from '@react-navigation/drawer';import HomeStack from '../stacks/HomeStack';import EditUserStack from '../stacks/EditUserStack';import MinimumEditUserStack from '../stacks/MinimumEditUserStack';import UserSignatureStack from '../stacks/UserSignatureStack';import SignoutScreen from '../../screens/AuthScreens/SignoutScreen';Drawer = createDrawerNavigator();const HomeNavigation = () => (<Drawer.Navigator    initialRouteName="Home"    drawerPosition="left"><Drawer.Screen      name="Home"      component={HomeStack}    /><Drawer.Screen      name="EditUserStack"      component={EditUserStack}    /><Drawer.Screen      name="MinimumEditUserStack"      component={MinimumEditUserStack}    /><Drawer.Screen      name="UserSignatureStack"      component={UserSignatureStack}    /><Drawer.Screen      name="Signout"      component={SignoutScreen}    /></Drawer.Navigator>);export default HomeNavigation;

Which opens normally in the HomeStack and navigates through all the stacks, excpet one, the UserSignatureStack:

import React from 'react';import { createStackNavigator } from '@react-navigation/stack';import ManageUserSignatureScreen from '../../screens/UserSignatureScreens/ManageUserSignatureScreen';import EditUserSignatureScreen from '../../screens/UserSignatureScreens/EditUserSignatureScreen';import { hamburguerLeftMenu, defaultNavigationOptions } from '../../components/navigation';const Stack = createStackNavigator();const UserSignatureStack = () => (<Stack.Navigator   initialRouteName="ManageUserSignatureScreen"   screenOptions={{     ...defaultNavigationOptions,     title: 'Assinatura e Rubrica',   }}><Stack.Screen      name="ManageUserSignatureScreen"      component={ManageUserSignatureScreen}      options={({ navigation }) => ({        title: 'Minhas Assinaturas',        headerLeft: () => hamburguerLeftMenu({ navigation }),      })}    /><Stack.Screen      name="EditUserSignatureScreen"      component={EditUserSignatureScreen}      options={({ route }) => ({        title: route.params?.screen ?? 'signature' === 'signature'          ? 'Sua assinatura'          : 'Sua rubrica',      })}    /></Stack.Navigator>);export default UserSignatureStack;

Here it opens as it should, but I can't go anywhere from here, it just crashes. If I try to move to any screen in the same stack with "navigation.navigate" it accuses a problem in the Stack Navigator (UserSignatureStack) and gives me:

cb is not a function. (In 'cb(event)', 'cb' is undefined)- node_modules\@react-navigation\core\src\useEventEmitter.tsx:120:15 in React.useCallback$argument_0* [native code]:null in forEach- node_modules\@react-navigation\core\src\useEventEmitter.tsx:118:16 in React.useCallback$argument_0- node_modules\@react-navigation\core\src\useFocusEvents.tsx:65:4 in React.useEffect$argument_0- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:16921:31 in commitHookEffectList- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:16970:29 in commitPassiveHookEffects- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:307:15 in invokeGuardedCallbackImpl- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:531:36 in invokeGuardedCallback- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:20061:28 in flushPassiveEffectsImpl* [native code]:null in flushPassiveEffectsImpl- node_modules\scheduler\cjs\scheduler.development.js:643:23 in unstable_runWithPriority- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19597:25 in scheduleCallback$argument_1- node_modules\scheduler\cjs\scheduler.development.js:482:68 in flushTask- node_modules\scheduler\cjs\scheduler.development.js:607:20 in flushWork- node_modules\scheduler\cjs\scheduler.development.js:58:18 in _flushCallback- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:146:14 in _callTimer- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:399:17 in callTimers- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0* [native code]:null in callFunctionReturnFlushedQueue

And when I try to go back a get the same, but with a problem in the Drawer Navigator (HomeNavigation).

Expected Behavior

I just wanted to go from one screen to another.

Your Environment

| Android | SDK 28|

| @react-navigation/native | 5.1.4 |

| @react-navigation/stack | 5.2.9 |

| @react-navigation/drawer | 5.4.0 |

| react-native-gesture-handler | 1.6.0 |

| react-native-safe-area-context | 0.7.3 |

| react-native-screens | 2.2.0 |

| react-native | 61.4 |

| expo | 37 |

| node | 12.9.0 |

| npm or yarn | yarn |

Continuously increasing counter with long press React Native

$
0
0

I have a button next to a TextInput that increases its counter when pressed.

<TouchableWithoutFeedback onPress={() => {this.increaseAmount(step, rowID)}}><View style={styles.amountPlusButtonContainer}><Text style={styles.amountButtonText}>+</Text></View></TouchableWithoutFeedback>

It currently increases by 1 each time I tap the button. What I want to achieve is to keep increasing the counter for as long as the user is pressing it.

I have tried to use setInterval() but I don't know exactly when to stop it nor if it's the right approach to this problem.

How do I manage to run my react-native app?

$
0
0

I am trying to run with react-native run-android but I cant manage to make it run. instantly get some errors.

tried:

  • $ react-native run-android --variant[productFlavorName][debug/release]
  • $ ./gradlew task
  • $ ./gradlewinstallDevDebu
    $ react-native run-android    info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.    Jetifier found 960 file(s) to forward-jetify. Using 12 workers...    info JS server already running.    info Launching emulator...    error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.    warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.    info Installing the app...    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.    * What went wrong:    Task 'installDebug' not found in project ':app'.    * Try:    Run gradlew tasks to get a list of available tasks. 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 1s    error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.    Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081    FAILURE: Build failed with an exception.    * What went wrong:    Task 'installDebug' not found in project ':app'.    * Try:    Run gradlew tasks to get a list of available tasks. 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 1s        at makeError (/Users/mac/Downloads/RN-login-register-screen/SPORTIUM/node_modules/execa/index.js:174:9)        at /Users/mac/Downloads/RN-login-register-screen/SPORTIUM/node_modules/execa/index.js:278:16        at processTicksAndRejections (internal/process/task_queues.js:93:5)        at async runOnAllDevices (/Users/mac/Downloads/RN-login-register-        screen/SPORTIUM/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)            at async Command.handleAction (/Users/mac/Downloads/RN-login-register-screen/SPORTIUM/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)

Call Android Library in React Native

$
0
0

I have a following code in Native Android

package org.jitsi.example;import android.os.Bundle;import android.support.v4.app.FragmentActivity;import org.jitsi.meet.sdk.JitsiMeetView;import org.jitsi.meet.sdk.ReactActivityLifecycleCallbacks;// Example//public class MainActivity extends FragmentActivity implements JitsiMeetActivityInterface {    private JitsiMeetView view;    @Override    protected void onActivityResult(            int requestCode,            int resultCode,            Intent data) {        JitsiMeetActivityDelegate.onActivityResult(                this, requestCode, resultCode, data);    }    @Override    public void onBackPressed() {        JitsiMeetActivityDelegate.onBackPressed();    }    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        view = new JitsiMeetView(this);        JitsiMeetConferenceOptions options = new JitsiMeetConferenceOptions.Builder()            .setRoom("https://meet.jit.si/test123")            .build();        view.join(options);        setContentView(view);    }    @Override    protected void onDestroy() {        super.onDestroy();        view.dispose();        view = null;        JitsiMeetActivityDelegate.onHostDestroy(this);    }    @Override    public void onNewIntent(Intent intent) {        JitsiMeetActivityDelegate.onNewIntent(intent);    }    @Override    public void onRequestPermissionsResult(            final int requestCode,            final String[] permissions,            final int[] grantResults) {        JitsiMeetActivityDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);    }    @Override    protected void onResume() {        super.onResume();        JitsiMeetActivityDelegate.onHostResume(this);    }    @Override    protected void onStop() {        super.onStop();        JitsiMeetActivityDelegate.onHostPause(this);    }}

Also

JitsiMeetConferenceOptions options = new JitsiMeetConferenceOptions.Builder()    .setServerURL(new URL("https://meet.jit.si"))    .setRoom("test123")    .setAudioMuted(false)    .setVideoMuted(false)    .setAudioOnly(false)    .setWelcomePageEnabled(false)    .build();

React native doesnt well support this library so i am looking to call this android library inside of react native .So i have created following class

public class ToastModule extends ReactContextBaseJavaModule  {    private static final String DURATION_SHORT_KEY = "SHORT";    private static final String DURATION_LONG_KEY = "LONG";    public ToastModule(ReactApplicationContext reactContext) {        super(reactContext);    }    @Override    public String getName() {        return "CustomToastAndroid";    }    @Override    public Map<String, Object> getConstants() {        final Map<String, Object> constants = new HashMap<>();        constants.put(DURATION_SHORT_KEY, Toast.LENGTH_SHORT);        constants.put(DURATION_LONG_KEY, Toast.LENGTH_LONG);        return constants;    }    //this @ReactMethod will be available in javascript environment    @ReactMethod    public JitsiMeetConferenceOptions show(String message, int duration) {        Log.d(getName(),"toast called with "+message);        Toast.makeText(getReactApplicationContext(), "Yes John its coming from android", duration).show();        JitsiMeetConferenceOptions options=null;        try {            options = new JitsiMeetConferenceOptions.Builder()                   .setServerURL(new URL("https://meet.jit.si"))                   .setRoom("test123")                   .setAudioMuted(false)                   .setVideoMuted(false)                   .setAudioOnly(false)                   .setWelcomePageEnabled(false)                   .build();            Toast.makeText(getReactApplicationContext(), message, duration).show();        } catch (MalformedURLException e) {            e.printStackTrace();        }        return options;    }}

This below packager will communicate to react native

public class CustomReactPackage implements ReactPackage {    @Override    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {        return Collections.emptyList();    }    @Override    public List<NativeModule> createNativeModules(            ReactApplicationContext reactContext) {        List<NativeModule> modules = new ArrayList<>();        modules.add(new ToastModule(reactContext));        return modules;    }}

if i call CustomToastAndroid.show("Testing this package from andorid",100); this i can see toast message in my app but i need to access jitsi meet features.can nay one help on integrating this to react native

Ref:https://github.com/jitsi/jitsi-meet/blob/master/android/README.md#use-pre-build-sdk-artifactsbinaries


react-native on android getting error like "TypeError: Network request failed"

$
0
0

export function rtiUpdate(data, callback) {enter code here console.log("dimuuuu"); console.log(data);enter code here if(data.asking == "AskingMoreYes"){ const formData = new FormData(); formData.append('asking', data.asking); formData.append('rti_id', data.rti_id); // formData.append('test', "test one"); return dispatch => { dispatch({ type: RTIUPDATE}); fetch(URL +'/rti-request/update-status',{ method: 'POST', headers: {'Authorization': global.TOKEN_TYPE +''+ global.TOKEN,"Accept": "application/json","Content-Type": "application/json" }, body: formData, }) .then(response => { console.log(response) if (!response.ok) { callback(false); throw new Error(response.status); } else { return response.json(); } }) .then(responseJson => { console.log('rtiUpdate - ', responseJson); dispatch({ type: RTIUPDATE_SUCCESS, data: responseJson }); callback(true); }) .catch(err => { console.log('rtiUpdate Err- ', err); dispatch({ type: RTIUPDATE_FAILD }); callback(false); }); }; }else{ const formData2 = new FormData();

    formData2.append('rti_payment_file', data.rti_payment_file);    formData2.append('rti_id', data.rti_id);      return dispatch => {          dispatch({ type: RTIUPDATE});          fetch(URL +'/rti-request/update-status',{              method: 'POST',              headers: {'Authorization': global.TOKEN_TYPE +''+ global.TOKEN,"Accept": "application/json","Content-Type": "application/json"              },              body: formData2,          })              .then(response => {                  console.log(response)                  if (!response.ok) {                      callback(false);                      throw new Error(response.status);                  }                  else {                      return response.json();                  }              })              .then(responseJson => {                  console.log('rtiUpdate - ', responseJson);                  dispatch({ type: RTIUPDATE_SUCCESS, data: responseJson });                  callback(true);              })              .catch(err => {                  console.log('rtiUpdate Err- ', err);                  dispatch({ type: RTIUPDATE_FAILD });                  callback(false);              });      };  }}

React Native build failed while executing task > Path is not a readable directory

$
0
0

I used Windows Subsystem for Linux, maybe this is the problem? I will be glad of any help, I will provide the information you need.

> Task :app:processDebugResources FAILED320 actionable tasks: 1 executed, 319 up-to-dateFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:processDebugResources'.> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> Path 'C:\Users\Username\Desktop\react-native-app\node_modules\unimodules-sensors-interface\android\build\intermediates\compiled_local_resources\debug\out' is not a readable directory.

Code Push functionality not working for react native app

$
0
0

I am new to code push and react native, I followed the steps given in the official docs- https://docs.microsoft.com/en-us/appcenter/distribution/codepush/react-native#getting-started, but even after pushing code to appcenter, it is not updating the app. Please find below the necessary code.

Index.js

import 'react-native-gesture-handler';import {AppRegistry} from 'react-native';import App from './App';import {name as appName} from './app.json';import codePush from 'react-native-code-push';let codePushOptions = {checkFrequency: codePush.CheckFrequency.ON_APP_START};AppRegistry.registerComponent(appName, () => codePush(codePushOptions)(App));

MainApplication.java

package com.awesomeproject;import com.microsoft.codepush.react.CodePush;import android.app.Application;import android.content.Context;import com.facebook.react.PackageList;import com.facebook.react.ReactApplication;import com.facebook.react.ReactInstanceManager;import com.facebook.react.ReactNativeHost;import com.facebook.react.ReactPackage;import com.facebook.soloader.SoLoader;import java.lang.reflect.InvocationTargetException;import java.util.List;public class MainApplication extends Application implements ReactApplication {  private final ReactNativeHost mReactNativeHost =      new ReactNativeHost(this) {        @Override        public boolean getUseDeveloperSupport() {          return BuildConfig.DEBUG;        }        @Override        protected String getJSBundleFile() {          return CodePush.getJSBundleFile();        }        @Override        protected List<ReactPackage> getPackages() {          @SuppressWarnings("UnnecessaryLocalVariable")          List<ReactPackage> packages = new PackageList(this).getPackages();          // // Packages that cannot be autolinked yet can be added manually here, for example:          // packages.add(new MyReactNativePackage());          return packages;        }        @Override        protected String getJSMainModuleName() {          return "index";        }      };  @Override  public ReactNativeHost getReactNativeHost() {    return mReactNativeHost;  }  @Override  public void onCreate() {    super.onCreate();    SoLoader.init(this, /* native exopackage */ false);    initializeFlipper(this, getReactNativeHost().getReactInstanceManager());  }  /**   * Loads Flipper in React Native templates. Call this in the onCreate method with something like   * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());   *   * @param context   * @param reactInstanceManager   */  private static void initializeFlipper(      Context context, ReactInstanceManager reactInstanceManager) {    if (BuildConfig.DEBUG) {      try {        /*         We use reflection here to pick up the class that initializes Flipper,        since Flipper library is not available in release mode        */        Class<?> aClass = Class.forName("com.awesomeproject.ReactNativeFlipper");        aClass            .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)            .invoke(null, context, reactInstanceManager);      } catch (ClassNotFoundException e) {        e.printStackTrace();      } catch (NoSuchMethodException e) {        e.printStackTrace();      } catch (IllegalAccessException e) {        e.printStackTrace();      } catch (InvocationTargetException e) {        e.printStackTrace();      }    }  }}

strings.xml

<resources><string name="app_name">AwesomeProject</string><string moduleConfig="true" name="CodePushDeploymentKey">"I have added the deployment key here"</string></resources>

package.json

    {"name": "AwesomeProject","version": "0.0.1","private": true,"scripts": {"android": "react-native run-android","ios": "react-native run-ios","start": "react-native start","test": "jest","lint": "eslint ."  },"dependencies": {"@react-native-community/masked-view": "^0.1.7","@react-navigation/native": "^5.1.4","@react-navigation/stack": "^5.2.9","appcenter-cli": "^2.4.0","react": "16.11.0","react-native": "0.62.0","react-native-code-push": "^6.2.0","react-native-gesture-handler": "^1.6.1","react-native-paper": "^3.6.0","react-native-reanimated": "^1.7.1","react-native-safe-area-context": "^0.7.3","react-native-screens": "^2.4.0","react-native-vector-icons": "^6.6.0"  },"devDependencies": {"@babel/core": "^7.9.0","@babel/runtime": "^7.9.2","@react-native-community/eslint-config": "^1.0.0","babel-jest": "^25.2.4","eslint": "^6.8.0","jest": "^25.2.4","metro-react-native-babel-preset": "^0.59.0","react-test-renderer": "16.11.0"  },"jest": {"preset": "react-native"  }}

Appcenter Code-push screenshotAppcenter code push

Please let me know, if there's anything else need.

React native 0.62.0 - Network request error on Android for file upload

$
0
0

I have upgraded react-native to 0.62 and i got the problem of Network error for Android only, iOS works fine.

I use FormData object to populate data formated as

const data = new FormData(); // On Android i add file protocol to file path - file://... data.append('photos', {    uri: 'file:///data/.../my-image.jpeg',    type: 'image/jpeg',   name: 'my-image.jpeg'});

and other textual data

data.append('description', 'my long description...');

Does anyone have the problem?

I have tried multiple Android SDKs 27, 28, 29, and got same problem on all :(

The things is if i do not upload images, but only textual data request works just fine :(

Any suggestion welcome :)?

React native build issue while adding google sign in [closed]

$
0
0

Could not resolve all files for configuration '

:app:debugRuntimeClasspath'.> Failed to transform full.jar (project :react-native-community_google-signin) to match attributes {artifactType=android-dex, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.api.attributes.VariantAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=16, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.> Execution failed for DexingWithClasspathTransform: F:\Renters\RentersApp\node_modules\@react-native-community\google-signin\android\build\intermediates\full_jar\debug\createFullJarDebug\full.jar.> Error while dexing.
Viewing all 29508 articles
Browse latest View live