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

react native app crash by adding this line: apply plugin: 'com.google.gms.google-services'

$
0
0

In my react native app i had added firebase , so my root gradle and app gradle is:

root build.gradle:

buildscript {
ext {
   ...
}
repositories {
    google()       
    maven {
         url 'https://maven.fabric.io/public'
    }
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'
    classpath 'com.google.gms:google-services:4.0.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
    repositories {
       mavenLocal()
       google()        
       maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
       }
       jcenter()
   }
}

...

app build.gradle:

...
dependencies {
    ...
    implementation 'com.android.support:design:${rootProject.ext.supportLibVersion}'
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.google.firebase:firebase-core:16.0.1'

}


// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply plugin: 'com.google.gms.google-services'

When i run project , app crashed ; But when i comment this line:

//    apply plugin: 'com.google.gms.google-services'

app run correctly.

I was ruined , please help me :)


Type androidx.appcompat.resources.R$dimen is defined multiple times

$
0
0

We have a React Native app where after upgrading to Android Studio 3.6.1 and Gradle plugin 3.6.1 we are seeing this compilation error:

Type androidx.appcompat.resources.R$dimen is defined multiple times: /Users/andrew/Software/project/android/app/build/intermediates/project_dex_archive/productionRelease/out/androidx/appcompat/resources/R$dimen.dex, /Users/andrew/Software/project/android/app/build/intermediates/project_dex_archive/productionRelease/out/15bdf8225afad69777cd7f9bd328ab094900c8289014e0107b56c5c62099dfea_3.jar:classes.dex

Here are our dependencies:

"dependencies": {
    "@dblackker/cameraroll": "^1.3.4",
    "@react-native-community/async-storage": "^1.7.1",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/netinfo": "^4.4.0",
    "@react-native-community/push-notification-ios": "^1.0.6",
    "@react-native-firebase/analytics": "^6.2.0",
    "@react-native-firebase/app": "^6.2.0",
    "@react-native-firebase/crashlytics": "^6.2.0",
    "@react-native-firebase/perf": "^6.2.0",
    "appcenter": "^2.6.1",
    "appcenter-analytics": "^2.6.1",
    "appcenter-crashes": "^2.6.1",
    "axios": "^0.18.0",
    "clone": "^2.1.2",
    "immutability-helper": "^2.8.1",
    "lodash": "^4.17.14",
    "memoize-one": "^5.1.1",
    "moment": "^2.22.2",
    "prop-types": "^15.7.2",
    "react": "16.9.0",
    "react-custom-validation": "^0.5.7",
    "react-native": "0.61.5",
    "react-native-add-calendar-event": "^3.0.0",
    "react-native-app-intro-slider": "^3.0.0",
    "react-native-appearance": "^0.3.1",
    "react-native-camera": "^3.8.0",
    "react-native-contacts": "^5.0.6",
    "react-native-device-info": "^4.0.1",
    "react-native-gesture-handler": "^1.4.1",
    "react-native-heic-converter": "^1.3.0",
    "react-native-image-crop-picker": "^0.26.1",
    "react-native-image-resizer": "^1.0.1",
    "react-native-inappbrowser-reborn": "^3.1.0",
    "react-native-iphone-x-helper": "^1.2.1",
    "react-native-keyboard-aware-scroll-view": "^0.7.4",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-maps": "0.26.1",
    "react-native-modal": "^7.0.2",
    "react-native-modal-datetime-picker": "^7.6.1",
    "react-native-parsed-text": "^0.0.21",
    "react-native-permissions": "^2.0.9",
    "react-native-push-notification": "^3.1.9",
    "react-native-reanimated": "^1.3.0",
    "react-native-section-list-get-item-layout": "^2.2.3",
    "react-native-shadow": "^1.2.2",
    "react-native-share": "^2.0.0",
    "react-native-svg": "^9.12.0",
    "react-native-svg-uri": "^1.2.3",
    "react-native-tab-view": "^2.3.0",
    "react-native-version-number": "^0.3.6",
    "react-navigation": "3.12.0",
    "react-navigation-tabs": "^2.1.2",
    "react-redux": "^5.0.7",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0",
    "rn-fetch-blob": "^0.11.2",
    "validator": "^10.8.0"
  }

Can anyone help figure out what the issue is, and how could we debug this type of issue in the future? Thank you!

Design approach for React Native app and Video editor in iOS / Android native code

$
0
0

We have a existing React Native app. We want to add Video and Image Filters/Editor features in the app. After reading and discussing, we think Video / Image Editor should be developed in iOS / Android native. Can you please suggest if we can integrate the iOS and Android native code in React Native app?

Even though react-native run-ios is success . Does not move from the splash screen. I will go crazy

$
0
0

Even though react-native run-ios is success . Does not move from the splash screen

success Successfully launched the app on the simulator In terminal. splash screen

I try to clean chash .

watchman watch-del-all 
rm -rf node_modules/ 
yarn install 
yarn cache clean


rm -rf ~/Library/Caches/CocoaPods
cd ios
rm -rf Pods/
pod install

But, it don't change.

I will go crazy

How to make StatusBar transparent?

$
0
0

Does anyone know a way to make Android Status Bar transparent with React Native?

NOT TRANSLUCENT, Transparent.

I am using react-navigation too.

Using Firestore in React native application

$
0
0

I'm trying to hook up an android application written in react-native with firebase firestore. but whenever i use a firestore function like,

    this.refs = firebase.firestore().collection('Users');
    this.refs.add({
        name :'athul',
        email :'athulrajts@gmail.com',
        dob :'03/01/1996'
    }).catch(err => { 
        console.log(err);
    });

It throws an exception

Could not invoke RNFirebaseFirestore.documentSet

null

Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;

Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/com.testproject-XmYvg1GYDdffiHWjlrlSoQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.testproject-XmYvg1GYDdffiHWjlrlSoQ ==/lib/arm64, /data/app/com.testproject-XmYvg1GYDdffiHWjlrlSoQ ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64

android/app/build.gradle

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'com.android.support:multidex:1.0.3'
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-auth:19.3.0'
    implementation "com.google.firebase:firebase-firestore:11.8.0"

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

//
//
    defaultConfig {
        applicationId "com.testproject"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

MainApplication.java

        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());
          packages.add(new RNFirebaseAuthPackage());
          packages.add(new RNFirebaseFirestorePackage());
          return packages;
        }

I've followed the react-native-firebase documentation to setup firebase. I've been searching for solution for a whole day now and i'm not able to find anything useful, please point me to the right direction.

React Native-Error after declining enable location popup

$
0
0

So i am trying to make a weather app and when i decline(press NO) in the popup window for enabling location, it gives me the following error: [Unhandled promise rejection: Error: Location request failed due to unsatisfied device settings.]

The important part of the code looks like this.

    let { status } = await Permissions.askAsync(Permissions.LOCATION);
    if (status !== 'granted') {
      this.setState({
        errorMessage: 'Permission to access location was denied, please activate location and reopen the app.',
      });

    }

    let location = await Location.getCurrentPositionAsync({enableHighAccuracy:true});
    let lat = location.coords.latitude;
    let lon = location.coords.longitude;

Note: I am using the last version of react native, i am on android, i used expo-location for this and it works perfectly when i enable(press YES) location.

react native secureTextEntry not working on android

$
0
0

I am trying to use react-native secureTextEntry to hide my password and confirm password fields during registration.I'm using custom InputBox component for textInput.below is my code,

<InputBox 
                error={this.state.PwordError} 
                keyboardType={'default'} 
                onChangeText={Pword =>
                    this.setState({
                        Pword
                    })
                } 
                secureTextEntry={true}
                value={this.state.Pword} 
                pHolder={"Password"} 
                color={'white'} />
            <View style={styles.spacer} />
            <InputBox 
                error={this.state.CPwordError} 
                keyboardType={'default'} 
                onChangeText={CPword =>
                    this.setState({
                        CPword
                    })
                } 
                secureTextEntry={true}
                value={this.state.CPword} 
                pHolder={"Confirm Password"} 
                color={'white'} />

The first textbox works fine when a password is entered it show as dots, but the confirm password field does not work. does anyone have an idea why this could occur?

This is the input box that is referred by the above code

<TextInput 
                    underlineColorAndroid="transparent"
                    placeholder={this.props.pHolder} 
                    placeholderTextColor={this.props.color === 'white' ? 'black':"white" } 
                    {...this.props}
                    style={this.props.color == 'white' ? styles.ReginputStyle : styles.inputStyle} 

                    /> 

i am using,

"react": "16.5.0",
"react-native": "0.57.1",

I was able to fix this by removing the keyboardType={'default'} code from my input component. Even though the problem is fixed i would like to know why the first secureTextEntry box worked while the other didn't, as both of them were identical except for the value. can any one give a reason to why this could occur,

thanks.


z-order problem between views in react-native

$
0
0

Note: I am searching for a solution that works for android.

I have the following hierarchy:

Main App:
     <View>
          <View>
              <Button title="Click Me!" />
          </View>

          <MyCustomElement />
     </View>

MyCustomElement:

     //overlay
     <View style={
                  height: '100%',
                  width: '100%',
                  backgroundColor: 'rgba(0, 0, 0, 0.25)',
                  position: 'absolute',
                  top: '100%',
                  left: 0,
                  alignItems: 'center',
                 }
      >
        //content
        <View style={
                      height: 100,
                      width: 100,
                      backgroundColor: 'red',
                    } 
        />

      </View>

The following is the obtained result:

enter image description here

I googled a bit and found that to alter z-order of views, I can use elevation, however it produces this artifact (the shadow at the edges of the screen, since my overlay color is transparent):

enter image description here

Lastly, I even tried to change only the elevation value of the red child, but it produces result as observed in 1st screenshot.

I am expecting the output as of 2nd only without the shadows.

React Native - ERROR point to the same directory in the file system. Each module must have a unique path

$
0
0

enter image description here

I try Sync Gradle in Android studio but i received error ERROR: The modules ['@react-native-community-geolocation-android-@react-native-community_geolocation', '@react-native-community-geolocation-android-react-native-community_geolocation~2'] point to the same directory in the file system. Each module must have a unique path. I check project in Android Studio, i see react-native-community_geolocation create multiple file .iml, what's cause and how to fix it?

Using expo-speech in android doesn't work and throw exception

$
0
0

I am trying to use expo-speech in my react-native app and I am getting the following error on my Android:

[Unhandled promise rejection: Error: Encountered an exception while calling native method: Exception occurred while executing exported method speak on module ExponentSpeech: null] - node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:155:41 in createErrorFromErrorData - node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:104:55 in - ... 5 more stack frames from framework internals

The code is the following: speak = async text => { Speech.speak(convertHTMLstring(text), { language: 'he', pitch: '1', rate: '0.9', }) }

react-native: 0.59.8

Dependencies are the following: "expo": "^35.0.0", "expo-speech": "~7.0.0", "react": "16.8.3", ...

Same code works in ios.

I tried to look for an answer but I couldn't find anything and according to expo docs, it shoudl support Android: https://docs.expo.io/versions/latest/sdk/speech/

Please help. Thanks.

Change package name for Android in React Native

$
0
0

I used react-native init MyApp to initialise a new React Native app. This created among others an Android project with the package com.myapp.

What's the best way to change this package name, for example to: com.mycompany.myapp?

I tried changing it in AndroidManifest.xml but it created other errors, so I'm assuming it's not the way.

Any idea?

How to use offline bundle on android for react native project?

$
0
0

How to use offline bundle on android?
I didn`t see the document about use offline bundle on android.
I tried to uncomment the code in build.gradle.

project.ext.react = [
        // the name of the generated asset file containing your JS bundle
    bundleAssetName: "index.android.bundle",

    // the entry file for bundle generation
    entryFile: "index.android.js",

    // whether to bundle JS and assets in debug mode
    bundleInDebug: false,

    // whether to bundle JS and assets in release mode
    bundleInRelease: true,

    // the root of your project, i.e. where "package.json" lives
    root: "../../",

    // where to put the JS bundle asset in debug mode
    jsBundleDirDebug: "$buildDir/intermediates/assets/debug",

    // where to put the JS bundle asset in release mode
    jsBundleDirRelease: "$buildDir/intermediates/assets/release",

    // where to put drawable resources / React Native assets, e.g. the ones you use via
    // require('./image.png')), in debug mode
    resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",

    // where to put drawable resources / React Native assets, e.g. the ones you use via
    // require('./image.png')), in release mode
    resourcesDirRelease: "$buildDir/intermediates/res/merged/release",

    // by default the gradle tasks are skipped if none of the JS files or assets change; this means
    // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
    // date; if you have any other folders that you want to ignore for performance reasons (gradle
    // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
    // for example, you might want to remove it from here.
    inputExcludes: ["android/**", "ios/**"]
]

but it didn`t work.It still fetch the JS bundle from the server.
Is there something I missed?

React Native (Android) not sensing my Touchable component absolute positioned above a TextInput

$
0
0

I have created a custom 'Autocomplete' component that has a TextInput and an absolute positioned dropdown that triggers when you type certain characters in it. In the dropdown, there are list items that are touchable and should trigger a function to fill the TextInput when pressed on.

On the screen component, I have included this 'Autocomplete' component four times. When I trigger the dropdown and try pressing on one of those list items within it, its like it ignores the dropdown completely and just lets me focus into the next 'Autocomplete' component's TextInput that is actually layered below the dropdown.

My code works perfectly fine on iOS devices but on Android, it has presented problems.

Would anyone have a solution for this?

Can I pass a function callback to headless js in react native?

$
0
0

I find I can pass some String or other primitive types by using bundle.putString("foo", "bar"); or putBoolean etc. like below:

Intent service = new Intent(getApplicationContext(), MyTaskService.class);
Bundle bundle = new Bundle();

bundle.putString("foo", "bar");
service.putExtras(bundle);

getApplicationContext().startService(service);

But how can I pass a function call back to the headless js service?

ref. react native headless js page


React-native android running out of BluetoothGatt objects using most common library react-native-ble-manager

$
0
0

I have posted on the github issues page for react-native-ble-manager #596 my problem. Has anyone else run into this problem? Basically I've collected enough data to know that BluetoothGatt objects are limited and I'm hitting that limit. The problem is I don't see anything in the library code that would cause this issue. The gatt object calls close() and gets set to null on disconnect.

So here's the details: connected to 4 devices (bonded), each device is set to notify on 2 characteristics. At times the devices get disconnected but not often; app running (in debug build) for 5-10 hours then I get the message bt_btif : Register with GATT stack failed. and that's the end of collecting data.

I've reviewed the library's android code but don't see anything that "holds" on to references of the BluetoothGatt other than the one for the peripheral object and only one of those are created for each peripheralUUID from the Manager class. I've spent way to much time on this issue to not have a solution. HMOWKYMOH

Further thoughts:

  • Do I need to manually turn off the notify characteristics when the device becomes disconnected or does the underlying object handle that?

  • Could frequent scanning when a disconnet happens cause a problem? I scan every ~6 seconds when I'm not connected to all expected devices.

Image compression in react-native

$
0
0

I am trying to compress images with mozjpeg when I implemented it in node.js according to the docs it worked fine.

const input = fs.readFileSync("in.ppm");
const out = mozjpeg.encode(input, { quality: 85 });

I need to do the compression on the client-side, so I tried to do the same with react-native since react-native doesn't contain core node modules such as fs, I need to go for a third party library react-native-fs for file reading.

When I tried to execute mozjpeg.encode(input, { quality: 85 }); in react-native it throws Unrecognized input file format --- perhaps you need -targa

server-side implementation

const mozjpeg = require("mozjpeg-js");
const fs = require("fs");

const input = fs.readFileSync(filePath);
const out = mozjpeg.encode(input, { quality: 85 });
console.error(out.stderr);
fs.writeFileSync("out.jpg", out.data);

client-side implementation

fs.readFile(image.path).then(data => {
    const out = mozjpeg.encode(data, { quality: 85 });
    console.log(out);
}

Here is the list of thing I tried

  • Tried giving input in hex, buffer, base64 and plain URL string.
  • Since the Android URL contains file:// as prefix I tried to remove them also.

React Native - Navigate to screen - Invalid hook call

$
0
0

App.js:

import React, { Component } from 'react';
import {View,Text} from 'react-native';
import { createDrawerNavigator } from 'react-navigation-drawer';
import {createAppContainer} from 'react-navigation';

import Epics from './screens/tmp';
import Pager from './screens/Pager';

const DrawerNavigator = createDrawerNavigator({
 Home: {screen: Epics},
 Page: {screen: Pager}
},{initialRouteName: 'Home'});

const Stack = createAppContainer(DrawerNavigator);

export default class App extends Component {
  render() {
    return <Stack />;
  }
}

Trying to navigate to a screen through a custom component:

import { ActivityIndicator, Image, StyleSheet, View, TouchableHighlight } from 'react-native';
import PropTypes from 'prop-types';
import React from 'react';
import { useNavigation } from 'react-navigation-hooks';

import AuthorRow from './AuthorRow';

export default class Card extends React.Component {

  static propTypes = {
    fullname: PropTypes.string.isRequired,
    image: Image.propTypes.source.isRequired,
    linkText: PropTypes.string.isRequired,
    onPressLinkText: PropTypes.func.isRequired,
    epicId: PropTypes.string.isRequired,
  };

  state = {
    loading: true,
  };

  getNav(){
    return useNavigation();
  }

  handleLoad = () => {
    this.setState({ loading: false });
  };

  render() {
    const { fullname, image, linkText, onPressLinkText, epicId, prop } = this.props;
    const { loading } = this.state;

    return (
      <View>
        <AuthorRow
          fullname={fullname}
          linkText={linkText}
          onPressLinkText={onPressLinkText}
        />
        <TouchableHighlight onPress={() => this.getNav().navigate('Pager')} underlayColor="white">
          <View style={styles.image}>
            {loading && (
              <ActivityIndicator style={StyleSheet.absoluteFill} size={'large'} />
            )}
            <Image
              style={StyleSheet.absoluteFill}
              source={image}
              onLoad={this.handleLoad}
            />
          </View>
        </TouchableHighlight>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  image: {
    aspectRatio: 1,
    backgroundColor: 'rgba(0,0,0,0.02)',
  },
});

From above code, trying to navigate using:

import { useNavigation } from 'react-navigation-hooks';

getNav(){ return useNavigation(); }

this.getNav().navigate('Pager')

It errors our stating: Invariant Violation: Invalid hook call. Hooks can only be called inside of the body of a function component.

How do I navigate using "useNavigation()" or how do I get "this.props.navigation" reference in a component? (I am new to React Native, please help me understand)

How can I get list of apps shown in Launcher in React Native for Android

$
0
0

I am using react-native-android-installed-apps for my react native application.

I want to get list of app names and their package names that are shown in launcher only.

The methods used in this package are not giving me desired output. Like getApps() gets everything, getNonSystemApps() skips Messaging and Phone apps, and getSystemApps() gets everything.

I could filter out system packages that I don't want from javascript but that's not good solution as I can't filter system apps on all kind of devices.

So I went out to .\node_modules\react-native-android-installed-apps\android\src\main\java\com\androidinstalledapps\RNAndroidInstalledAppsModule.java where the library code is.

And tried adding these 3 lines from here. But failed

Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(mainIntent, 0);

How can I modify the following code to get desired output with apps shown in Launcher only.

public void getApps(Promise promise) {
    try {
      PackageManager pm = this.reactContext.getPackageManager();
      List<PackageInfo> pList = pm.getInstalledPackages(0);
      WritableArray list = Arguments.createArray();
      for (int i = 0; i < pList.size(); i++) {
        PackageInfo packageInfo = pList.get(i);
        WritableMap appInfo = Arguments.createMap();

        appInfo.putString("packageName", packageInfo.packageName);
        appInfo.putString("versionName", packageInfo.versionName);
        appInfo.putDouble("versionCode", packageInfo.versionCode);
        appInfo.putDouble("firstInstallTime", (packageInfo.firstInstallTime));
        appInfo.putDouble("lastUpdateTime", (packageInfo.lastUpdateTime));
        appInfo.putString("appName", ((String) packageInfo.applicationInfo.loadLabel(pm)).trim());

        Drawable icon = pm.getApplicationIcon(packageInfo.applicationInfo);
        appInfo.putString("icon", Utility.convert(icon));

        String apkDir = packageInfo.applicationInfo.publicSourceDir;
        appInfo.putString("apkDir", apkDir);

        File file = new File(apkDir);
        double size = file.length();
        appInfo.putDouble("size", size);

        list.pushMap(appInfo);
      }
      promise.resolve(list);
    } catch (Exception ex) {
      promise.reject(ex);
    }
  }

React Native CouchDB/pouchDB app is not working in release apk

$
0
0

i am trying to make simple dictionary project, i use CouchDB for remote server and use pouchDB for local.

and i use remote text file for pre loading data in local db when app start.

This is my code

import React, { Component } from 'react';
...
import { localNoteDb, nameIndex, remote_url, remoteNoteDb } from '../const'

...
let handlerSync = null

class Home extends Component {

    constructor(props) {

        super(props);
        this.state = {
            arrNote1: [],
            arrNotee: [],
            isLoading: false,
            text: '',
            count: 0,
            data1: 0,
            data2: 0,
            indicator: false,
            flagadd: false,
            notfoundFlag: false
        }
    }
    ....

    componentDidMount() {
        this.getListNoteFromDb();

    }

    componentWillUnmount() {
        this.getListNoteFromDb();
    }




    syncDb = () => {

        this.setState({ isLoading: true });


        //here is my text file to pre load the data from remote amazon s3 text file
        localNoteDb.load('https://dictionary.s3.ap-north-14321.amazonaws.com/dumpdb.txt', { proxy: remote_url }).then(() => {


            localNoteDb.replicate.from(remote_url).on('complete', function () {
                console.log("DONE>>>>>>>")
            }).on('error', function (err) {
                console.log("ERROR>>>>>" + JSON.stringify(err))
            });
            var temp = localNoteDb.replicate.from(remote_url, {
                live: true,
                retry: true
            });
            this.setState({ isLoading: false });
            return temp;

        }).catch((err) => {
            this.setState({ isLoading: false });
        });



    };

    getListNoteFromDb = () => {
        this.setState({ isLoading: true })


        fetch("http://myipaddress:5984/dictionary")
            .then(Response => Response.json())
            .then(response => {
                localNoteDb.info().then((resp) => {
                    console.log(JSON.stringify(resp))
                    //resp will contain disk_size
                    if (resp.doc_count !== response.doc_count) {
                        this.syncDb();
                    } else {
                        this.setState({ isLoading: false })
                    }
                }).catch((err) => {
                    console.log("ERROR<<<<<<" + err);
                });

            });

    }


    getListNoteFromDbText = (txt) => {

        this.setState({ text: txt, indicator: true, notfoundFlag: false })

        clearTimeout(this.timer);
        this.timer = setTimeout(function () {
            localNoteDb
                .allDocs({
                    include_docs: true,
                    attachments: true,
                    startkey: txt.toLowerCase(),
                    endkey: txt.toLowerCase() + '\ufff0'
                }).then(function (result) {
                    if (result.rows.length > 0) {
                        // handle result

                        this.setState({
                            indicator: false,
                            arrNote1: result.rows.slice(0, 10)
                        })
                        clearTimeout(this.timer);
                    } else {
                        this.setState({
                            indicator: false,
                            notfoundFlag: true
                        })
                    }


                }.bind(this))
                .catch(err => {
                    this.setState({ isLoading: false })
                    Toast.show(err.message)
                })
        }.bind(this),
            100
        );

    }

    renderItem = ({ item }) => {

        console.log("ITEMS....." + JSON.stringify(item));
        return (
            <TouchableHighlight
                underlayColor={'#98c5ba'}
                onPress={() => {
                    this.isAtCurrentScreen = false
                    this.props.addWordHistory(item.doc)
                    this.props.navigation.navigate('DetailsMeaning', {
                        idNote: item.doc,
                    })

                }}
                style={{ marginLeft: 10, marginTop: 3, marginRight: 10 }}
            >
                <Text numberOfLines={1} style={{ color: '#29282A', margin: 5, fontSize: 16, fontFamily: 'Roboto-Regular' }}>{item.doc._id}</Text>

            </TouchableHighlight>
        )
    }
    render() {
        return this.state.isLoading ? <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: '#f3fffc' }}><ActivityIndicator size="large" color="#ff6a00" /><Text>Fetching Data Please wait...</Text></View> : <View style={{ flex: 1, backgroundColor: '#f3fffc', zIndex: 1 }}><View style={{ marginLeft: 15, marginRight: 15, zIndex: 2, marginTop: -28 }}>
            <SearchBar
                placeholder="Type Here..."
                lightTheme={true}
                color='black'
                searchIcon={{ size: 30, color: '#3ea58d' }}
                inputStyle={{ backgroundColor: 'white' }}
                inputContainerStyle={{ backgroundColor: 'white', height: 30 }}
                containerStyle={{ backgroundColor: 'white', borderWidth: 1, borderColor: '#3ea58d', borderRadius: 5 }}
                onChangeText={(text) => this.getListNoteFromDbText(text)}
                value={this.state.text}
            />
        </View>
            {this.state.text === '' ? <Text></Text> :
                (this.state.indicator ? <View style={{ flex: 1 }}><ActivityIndicator size="large" color="#ff6a00" /></View> : <View style={{ flex: 1, flexDirection: 'column' }}><Text style={{ backgroundColor: '#98c5ba', textAlign: 'center', color: 'white', marginTop: 5, marginLeft: 15, marginRight: 15, borderRadius: 3, fontFamily: 'Roboto-Black' }}>RESULTS</Text>{this.state.notfoundFlag ? (<Text style={{ textAlign: 'center', color: 'black', marginTop: 50, fontSize: 21, fontWeight: 'bold', fontStyle: 'italic' }}>Not Found</Text>) : (<FlatList
                    style={{ backgroundColor: '#f3fffc', marginTop: 6 }}
                    data={this.state.arrNote1}
                    showsVerticalScrollIndicator={false}
                    keyExtractor={(item, index) => index.toString()}
                    renderItem={this.renderItem}
                />)}</View>)}
            <View style={{ marginTop: 1, position: 'absolute', bottom: 0 }}>
                <AdsBanner />
            </View>
        </View>

    }
}
const mapStateToProps = (state) => {
    return {
        wordHistory: state.addHistory.wordDetails
    }
}
const mapDispatchToProps = (dispatch) => {
    return {
        addWordHistory: (product) => dispatch({ type: 'ADD_WORD', payload: product })
    }


}
export default connect(mapStateToProps, mapDispatchToProps)(Home);

My base64 code, i put the link in index.

import {decode, encode} from 'base-64'

if (!global.btoa) {
    global.btoa = encode;
}

if (!global.atob) {
    global.atob = decode;
}

process.browser = true

It works fine in debug mode but not in release mode.

I had same issue as this React Native atob() / btoa() not working without remote JS debugging

Everything work fine in debug mode by putting base64 code, but when i do ./gradlew assembleRelease and test the apk, data not able to load, it's showing loading indicator.

In release apk also it show same issue as above.

Is it related to base64 issue or any other issue? Please Help. Thanks.

Viewing all 29741 articles
Browse latest View live


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