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

Refresh contentComponent in react-navigation

$
0
0

I am using React-Navigation where I am using functionality of custom drawer by using contentComponent of React-Navigation.

const DrawerNavigation = DrawerNavigator({
  DrawerStack: { screen: DrawerStack }
}, {
  contentComponent: DrawerComponent,
  drawerWidth: 300
})

Here DrawerComponent is my custom navigation drawer where I have used custom navigation items like username, profile picture, email address and other menus.

Now whenever user updates their profile I want to refresh my DrawerComponent, I am not able to find any way to do it. Can anybody suggest me a good way to implement this?


How to Refresh Native Deeplink Application When In Foreground?

$
0
0

I have a problem when I use deep linking android on react native. And when the application is in a foreground state when the application is triggered from deep-linking the application does not refresh on that screen. For example, I want deep linking to the Home Screen but when my foreground is on the profile screen then my application doesn't refresh?

this my code for deeplinking :

  async componentDidMount() {
    //  This for deeplinking
    if (Platform.OS === 'android') {
      Linking.getInitialURL().then(url => {
        this.navigate(url);
      });
    } else {
      Linking.addEventListener('url', this.handleOpenURL);
    }
  navigate = (url) => {
    const { navigate } = this.props.navigation;

    const route = url.replace(/.*?:\/\//g, '');
    const id = route.match(/\/([^\/]+)\/?$/)[1];
    const routeName = route.split('/')[0];
    if (id === 'yes') {
      alert(id)
    }
  }

Passing URI prefix to createSwitchNavigator function for Deep Linking with react-navigation

$
0
0

I have a fairly straight forward set up with react-navigation that utilizes a switch navigator which accepts a param signedIn to set the initial route which looks like this:

const uriPrefix =
  Platform.OS === 'android'
    ? 'myApp://myApp/'
    : 'myApp://'

const createRootNavigator = (signedIn = false) => (
  createSwitchNavigator({
    LoginNav,
    AllNav: { screen: AllNav, uriPrefix, path: '' }
  }, {
    initialRouteName: signedIn ? 'AllNav' : 'LoginNav',
  })
);

I then call this in RootContainer:

 const Nav = Navigation(isLoggedIn);
 return (
    <Nav />
  )

On iOS this works fine with the uriPrefix and I am able to link to the screens using Linking.openURL() with the link.

On Android it does not work. I am able to make it work on Android without using the switchNavigator and just exporting LoginNav and AllNav, but I still need a switchNavigator.

I followed the instructions here: https://reactnavigation.org/docs/en/deep-linking.html, but am unable to pass uriPrefix in the way they define. I found that at least for iOS, I was able to define that inside of my switchNavigator, but it just does not work the same for me on Android.

how can we handle assets for multiple environment?

$
0
0

Ok so I am going to use react-native-config to make my app having multiple environments. But the project requirements are such as we should be able to export different apps from same codebase for different clients with different bundle id.

We can achieve that using product flavors in android and schemes in iOS side but I don't know how to handle assets/images we have in our js project. For an example, client A has different images and client B has different images, I can definitely show/hide those images based on the .env variables but I don't want those images to get included while building the app for release.

is it possible to use Webpack or babel in such case or any automation script?

What can be the possible solution for this scenario? Feel free to ask me any questions if you didn't understand what I am asking here, sorry in advance for that.

React Native: How to fix TypeError: null is not an object (evaluating 'TrackPlayer.STATE_NONE')?

$
0
0

I entered the following commands in the powershell in the folder containing my alarm app:

npm install react-native-track-player 
react-native link react-native-track-player 

react-native link seemed to have done nothing, so I manually linked the module following the steps given from the module info.

However, when I include the following line in one of my .js components:

import TrackPlayer from 'react-native-track-player'

I get the following error on my Android device:

TypeError: null is not an object (evaluating 'TrackPlayer.STATE_NONE')

How can I fix this?

Versions:

  • react-native-cli: 2.0.1
  • react-native: 0.61.5

Here are some screenshots of the stack trace:

  1. Pt 1
  2. Pt 2
  3. Pt 3

Build react native app to apk file after making new changes?

$
0
0

I build a react native app with this documentation , its working fine then , But when i am implementing new changes to apk , its not installing properly on my android Mobile device and gives error on first open , please help .a

react-native assembleRelease can't generate app-release.apk

$
0
0

android/app/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile
import groovy.json.JsonSlurper
/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * 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,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // 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/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-sentry/sentry.gradle" // 注释掉,阻止上传sourcemap
/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

def getNpmVersion() {
    def inputFile = new File("../package.json")
    def packageJson = new JsonSlurper().parseText(inputFile.text)
    return packageJson["version"]
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "com.rn_pda"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName getNpmVersion()
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}
project.ext.vectoricons = [
    iconFontNames: [ 'Icomoon.ttf','MaterialIcons.ttf','SimpleLineIcons.ttf','EvilIcons.ttf','Foundation.ttf' ] // Name of the font files you want to copy
]

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
dependencies {
    compile project(':react-native-sentry')
    compile project(':react-native-svg')
    compile project(':react-native-push-notification')
    compile project(':react-native-vector-icons')
    compile project(':RCTHttpCache')
    compile project(':react-native-install-apk')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-fs')
    compile project(':react-native-camera')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile ("com.facebook.react:react-native:0.47.2") { force = true }
    // compile "com.facebook.react:react-native:+"  // From node_modules
    compile project(':react-native-device-info')
    compile project(':react-native-splash-screen')
    compile 'com.facebook.fresco:animated-gif:0.13.0'
}

// 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'
}

I'm trying to generating the signed APK. I got "build Success" by the command ./gradlew assembleRelease. However, I can't find the APK file at "android/app/build/outputs/apk/app-release.apk". Actually, the "build" folder doesn't even exist in the "android/app" folder.

react-native run-android is work. any solution? Thanks in advance. (v0.47.2)

Debug application when app installed on real device

$
0
0

Yet another question but I am unable to find the answer to my issue. The application works perfectly in my emulator but not on my android 9 and android 8 devices. When it starts, it shows the spinner that never ends. While I know the application flow, it is still hard for me to figure out what is not working.

Is there a way to debug an application installed on a real device, reading console logs or log messages?


React Native Apollo error: "Network error: Network request failed"

$
0
0

On IOS, the application runs correctly. But on Android I get this error. Here's my config in client and server. Please help!

Error: Error image

Here's the config on client:

import ApolloClient, { createNetworkInterface } from 'apollo-client';
import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws';

const networkInterface = createNetworkInterface({ uri: 'http://localhost:3000/graphql' });

const wsClient = new SubscriptionClient('ws://localhost:3000/subscriptions', {
  reconnect: true,
});

const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
  networkInterface,
  wsClient,
);

export const client = new ApolloClient({
  networkInterface: networkInterfaceWithSubscriptions,
});

Here's the config on server:

import express from 'express';
import {
  graphqlExpress,
  graphiqlExpress,
} from 'graphql-server-express';
import bodyParser from 'body-parser';
import cors from 'cors';
import { execute, subscribe } from 'graphql';
import { createServer } from 'http';
import { SubscriptionServer } from 'subscriptions-transport-ws';
import { schema } from './schema';

const PORT = 3000;
const server = express();

server.use('*', cors({ origin: 'http://localhost:8081' }));
server.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
server.use('/graphiql', graphiqlExpress({
  endpointURL: '/graphql',
  subscriptionsEndpoint: 'ws://localhost:3000/subscriptions',
}));

// We wrap the express server so that we can attach the WebSocket for subscriptions
const ws = createServer(server);
ws.listen(PORT, () => {
  console.log('GraphQL Server is running');
  // Set up the WebSocket for handling GraphQL subscriptions
  new SubscriptionServer({
    execute,
    subscribe,
    schema
  }, {
    server: ws,
    path: '/subscriptions',
  });
});

I'm using react-apollo: 1.4.10, apollo-client: 1.9.0-0

Tapped on firebase Notification then not getting the data from Push Notification in react native android

$
0
0

1) When i tap on Push Notification then i can't get the data from Notification.

2) I got the payload data from notification when app will be open, and debugger directly goes in the notification onNotification() section.

3) but problem is that my app is in background and when tap on notification then can't get the notification payload data.

Here i am using Firebase for notification handle


componentDidMount() {
        this.checkPermission();
        this.messageListener();
 }


   checkPermission = async () => {
     const enabled = await firebase.messaging().hasPermission();
     if (enabled) {
       this.getFcmToken();
     } else {
       this.requestPermission();
     }
   }


   getFcmToken = async () => {
     const fcmToken = await firebase.messaging().getToken();
     if (fcmToken) {
       //this.showAlert('Your Firebase Token is: ', fcmToken);
     } else {
       this.showAlert('Failed', 'No token received');
     }
   }

   requestPermission = async () => {
     try {
       await firebase.messaging().requestPermission();
       // User has authorised
     } catch (error) {
       // User has rejected permissions
     }
   }

componentWillUnmount() {
 this.notificationDisplayedListener();
 this.notificationListener();
 this.notificationOpenedListener();
}


messageListener = async () => {
 this.notificationListener=firebase.notifications().onNotification((notification) => {
   const { title, body } = notification;
   this.showAlert(title, body);
 });
 this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
   const { title, body } = notificationOpen.notification;
   this.showAlert(title, body);
 });

 debugger
 const notificationOpen = await firebase.notifications().getInitialNotification();

 if (notificationOpen) {

   const { title, body } = notificationOpen.notification;
   // this.showAlert(title, body);
 }

 this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {

   const noti = notification;
   // Process your notification as required
 });



 this.messageListener = firebase.messaging().onMessage((message) => {
   console.log(JSON.stringify(message));
 });

}

Error in Uploading app bundle on google play store due to react native update

$
0
0

I have made project in react native 0.59.5 and uploaded app bundle on play store successfully. Now I have updated react native to 0.61.5 and tried to upload app bundle on play store and got this error

Error
You can't rollout this release because it doesn't allow any existing users to upgrade to the newly added APKs.
Non-upgradable APK
Warning:
None of the users of this APK will be able to upgrade to any of the new APKs added in this release.
Tip:
Ensure that all your new APKs are added to this release.

although I have increased the version code from previous release but I am unable to understand the issue

here is code of build.gradle on react native 0.59.5

import com.android.build.OutputFile
project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
def enableSeparateBuildPerCPUArchitecture = true
def enableProguardInReleaseBuilds = false
android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "hidden"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 78
        versionName "4.1.1"
    }
     signingConfigs {
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
             signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation project(':rn-fetch-blob')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-android-location-services-dialog-box')
    implementation project(':react-native-firebase')
    implementation project(':react-native-splash-screen')
    implementation project(':@react-native-community_async-storage')
    implementation project(':@react-native-community_netinfo')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-gesture-handler')
    implementation fileTree(dir: "libs", include: ["*.aar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
      // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.firebase:firebase-core:16.0.8"
    implementation "com.google.firebase:firebase-messaging:17.5.0"
    implementation "com.google.firebase:firebase-invites:16.1.1"
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

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

and here is code of build.gradle of react native 0.61.5

import com.android.build.OutputFile
project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,  // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

def enableSeparateBuildPerCPUArchitecture = true
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'

def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "hidden"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 79
        versionName "4.1.1"
        multiDexEnabled true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
            release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }
}

dependencies {
    implementation project(':react-native-firebase')
    implementation fileTree(dir: "libs", include: ["*.aar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
     // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.firebase:firebase-core:16.0.9"
    implementation "com.google.firebase:firebase-messaging:18.0.0"
    implementation "com.google.firebase:firebase-invites:17.0.0"
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'

version code of previous app bundle which was uploaded successfully through react native 0.59.5 was 4194382 displayed on play console. App bundle which has errors shows 3145807 version code on play console and it was uploaded through react native 0.61.5

react-native run-android is unrecognized

$
0
0

I've installed react-native-cli globally:

npm install -g react-native-cli

Then run:

react-native init AwesomeProject
cd AwesomeProject

I got the following structure:

-- AwesomeProject   
---- node_modules      
------ react-native    

When I run react-native run-android I get an error:
Command run-android unrecognized. Did you mean to run this inside a react-native project?

When I run react-native start I get the same.

react-native -v
prints:
react-native-cli: 0.2.0
react-native: n/a - not inside a React Native project directory

What I'm doing wrong?

React-Native integration Support for V2 Pro device SunMI

React referral package adding issue(npm i react-native-referrer)

$
0
0

android/../MainApplication.java

@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 RNReferrerPackage());          
          packages.add(new RNFirebaseMessagingPackage());
          packages.add(new RNFirebaseNotificationsPackage());
          packages.add(new RNFirebaseLinksPackage());
          return packages;
        }

Please Refer the image enter image description here

React Native android build failed. SDK location not found

$
0
0

I have error when i start running android

What went wrong:
A problem occurred evaluating project ':app'.  
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

React-native Axios Api get response differs from debugging mode and normal mode

$
0
0

I tried to call a https request get method API using axios method, from server it responded 200 but in server side the API is not hitted. Don't know where the response is coming from, the same api i have tried using post-man, i got 200 status with updated response correctly. after that i started using react-native-debugger to debug the responses, i debugged with the network inspector and i have tried the same api, it got correct response with 200. what will be the issue in this. Someone please help me to find out this bug..

React-Native Webview With audio-player it's possible?

$
0
0

I'm just starting with React-Native. do i need to play a song inside one in a webview and be able to control it when the screen is locked by running stop / play?

Does anyone have any ideas / worked on this before?

Hiding RefreshControl in Android React Native

$
0
0

I have a requirement where I want to hide the refresh indicator completely of Refresh Control for Android. I already set most of the color properties to transparent by still see gray circular indicator. Is there any way to completely hide this circular indicator. Link to gif about what is hapenning: http://imgur.com/dkAmkC6

This is my code:

import React, {Component} from 'react';
import {
  StyleSheet,
  Text,
  TextInput,
  View,
  FlatList,
  Dimensions,
  RefreshControl,
  ToastAndroid,
} from 'react-native';


import Constants from './Constants';



export default class TestList extends Component {

  constructor(props) {
    super(props);
    this.rows =[{id: 1},{id: 2},{id: 3},{id: 4}];
    this.state = {
      refreshing: false,
    }
  }


  renderItem(row) {
    return (
      <Text style={{fontSize: 20, borderBottomWidth: 1, borderColor: 'red', color: 'blue', height:80}}>{row.item.id}</Text>
      )
    }
  render() {
    return (
      <View style={[styles.container]}>
        <FlatList
          data={this.rows}
          renderItem={this.renderItem.bind(this)}
          overScrollMode='always'
          style={{flex: 1}}
          keyExtractor={(item) => item.id}
          removeClippedSubviews={false}
          keyboardShouldPersistTaps='always'
          refreshControl={
            <RefreshControl
              colors={['transparent']}
              style={{backgroundColor: 'transparent'}}
              progressBackgroundColor='transparent'
              refreshing={this.state.refreshing}
              onRefresh={() =>
              ToastAndroid.show('Refresh completed with short duration', ToastAndroid.SHORT)}/>}
          ref="FlatList"/>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
})


  [1]: http://imgur.com/dkAmkC6

Android BiometricPrompt DeviceCredentialHandler: onCreate: Executor and/or callback was null

$
0
0

It looks like BiometricPrompt 1.0.0 has a bug where it stays in invisible state throwing that exception

ill suggest a workaround in the answer

EDIT(thanks to @Isai Damier):

Way to reproduce:

  1. open the BiometricPrompt
  2. press back button - close the prompt
  3. press back again and exit the app
  4. return to the app - try to open the prompt again

React Native - Error while running run-android

$
0
0

I get this error while running react-native run-android on windows:

Reason: error in opening zip file
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:225)
    at java.util.zip.ZipFile.<init>(ZipFile.java:155)
    at java.util.zip.ZipFile.<init>(ZipFile.java:169)
    at org.gradle.wrapper.Install.unzip(Install.java:219)
    at org.gradle.wrapper.Install.access$600(Install.java:27)
    at org.gradle.wrapper.Install$1.call(Install.java:75)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)

Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:225)
    at java.util.zip.ZipFile.<init>(ZipFile.java:155)
    at java.util.zip.ZipFile.<init>(ZipFile.java:169)
    at org.gradle.wrapper.Install.unzip(Install.java:219)
    at org.gradle.wrapper.Install.access$600(Install.java:27)
    at org.gradle.wrapper.Install$1.call(Install.java:75)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)

    at checkExecSyncError (child_process.js:621:11)
    at execFileSync (child_process.js:639:15)
    at runOnAllDevices (C:\Users\Admin01\Desktop\albums\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

My react-native info output:

info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.17134
    CPU: (4) x64 Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
    Memory: 12.85 GB / 15.90 GB
  Binaries:
    Node: 12.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.6010548
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.5 => 0.61.5

I am a bit new to react-native and have no clue as to what is going on. Can anyone tell me what's going wrong?

Viewing all 30346 articles
Browse latest View live


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