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

Error type 3. Activity class {com.awesome_project/ com.awesome_project.MainActivity} does not exist in react native (Android device)

$
0
0

I've created the project using the following command.

react-native init Awesome_Project

I've started the packager using the following command.

react-native start

I've connected my Android mobile using USB drive.

I've opened another command prompt and run the following adb command to make sure that only one device is connected.

adb devices

I've started the application using the following command.

react-native run-android

I've been confronted with the following error.

open: Permission denied
open: Permission denied
Starting: Intent { com.awesome_project/.MainActivity }
Error type 3
Error: Activity class {com.awesome_project/ com.awesome_project.MainActivity} does not exist.

Thanks in advance.


Can you use ReactNative module class from Native side?

$
0
0

You create native modules for react native to access native functionality.

Once you create native modules, can you use them from native code (java/swift) ?

How to combine multiple inline style objects and inline css in react-native?

$
0
0

How to combine multiple inline style objects and inline css in react-native?

it has 3 style objects TimelineGreenColor, TimelineLeftBorder, TimelineLeftLine to be used in view div

  const stylesB = StyleSheet.create( {
     TimelineGreenColor:
     {
       backgroundColor: "green",
     },
     TimelineLeftBorder:
     {
       position: 'absolute',
       width: 4,
       backgroundColor: "green",
       height: '100%',
       left: 4,
       top: 15,
     },
     TimelineLeftCircle:
     {
       position: 'absolute',
       width: 12,
       height: 12,
       backgroundColor: "green",
       top: 12,
       borderRadius: 50,
       left: 0,
       /*boxShadow: "0px 0px 10px -2px black",*/
     },
     TimelineLeftLine:
     {
       position: 'absolute',
       width: 15,
       height: 3,
       backgroundColor: "green",
       top: 16,
       left: 5,
   }

   <View style={how to write styles in react-native ??????????}></View>

React-native, use fullscreen image on android

$
0
0

I just have started developing a new app and immediately ran into a problem.

Here, ios on the right, the background successfully covers the entire screen, including the top bar and the bottom navigation. However, on android, this does not happen.

comparison

Here is my code:

import React from 'react';
import { ImageBackground, Text, View, SafeAreaView, StyleSheet } from 'react-native';
import Button from "./src/components/Button";

const Explore = ({}) => {
  return (
    <ImageBackground
      style={s.background}
      source={require('./src/assets/images/explore.png')}
    >
      <SafeAreaView style={s.safeArea}>
        <View style={s.wrapper}>
          <View style={s.header}>
            <Text style={s.title}>Explore</Text>
            <Text style={s.subTitle}>new amazing countries</Text>
          </View>

          <View style={s.spacer} />

          <View style={s.controls}>
            <Button
              style={s.button}
              label="Log in"
            />
          </View>
        </View>
      </SafeAreaView>
    </ImageBackground>
  );
};

const s = StyleSheet.create({
  background: {
    width: '100%',
    height: '100%',
  },
  safeArea: {
    flex: 1,
  },
  wrapper: {
    flex: 1,
    padding: 25,
  },
  header: {
    paddingTop: 20,
  },
  title: {
    fontSize: 24,
    fontFamily: 'RobotoSlab-Bold',
    color: '#323B45',
  },
  subTitle: {
    fontSize: 20,
    fontFamily: 'RobotoSlab-Light',
    color: '#323B45',
  },
  spacer: {
    flex: 1,
  },
  controls: {
    flexDirection: 'row'
  },
  button: {
    flex: 1
  },
  gap: {
    width: 25
  }
});

export default Explore;

Does anyone know how I can make the background on android cover the entire screen, jus like on ios?

UPDATE:

We have managed to cover the status bar with the following code:

<StatusBar translucent backgroundColor='transparent' />

Java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp

$
0
0

Screenshot from Android Studio

Google Play Services

This is React Native project. I have an error after successful build in Android Studio Emulator:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp

My files:

package.json:

...
"react-native": "^0.55.3",
"react-native-camera": "1.1.2",
"react-native-check-box": "^2.1.0",
"react-native-extended-stylesheet": "^0.8.1",
"react-native-firebase": "^4.2.0",
"react-native-geocoder": "^0.5.0",
"react-native-git-upgrade": "^0.2.7",
"react-native-htmlview": "^0.12.1",
"react-native-image-picker": "^0.26.10",
"react-native-linear-gradient": "^2.4.0",
"react-native-local-storage": "^1.5.2",
"react-native-maps": "^0.21.0",
"react-native-modal": "^5.4.0",
"react-native-modal-dropdown": "^0.6.1",
"react-native-read-more-text": "^1.0.0",
"react-native-router-flux": "^4.0.0-beta.27",
"react-native-svg-image": "^2.0.1",
"react-native-text-input-mask": "^0.7.0",
...

android/app/build.gradle:

...    
android {
    compileSdkVersion 27
    buildToolsVersion "27.0.1"

    defaultConfig {
        applicationId "com.something.anything"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        multiDexEnabled true
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            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:
            // 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
            }
        }
    }
}

dependencies {
    compile(project(':react-native-firebase')) {
        transitive = false
    }
    compile project(':react-native-geocoder')
    compile(project(':react-native-maps')) {
      exclude group: 'com.google.android.gms', module: 'play-services-base'
      exclude group: 'com.google.android.gms', module: 'play-services-maps'
      exclude group: 'com.google.android.gms', module: 'play-services-location'
    }

    compile 'com.google.android.gms:play-services-base:15.+'
    compile 'com.google.android.gms:play-services-maps:15.+'
    compile 'com.google.android.gms:play-services-location:15.+'
    compile (project(':react-native-camera')) {
    exclude group: "com.google.android.gms"
    compile 'com.android.support:exifinterface:25.+'
    compile ('com.google.android.gms:play-services-vision:12.0.1') {
        force = true
        }
    }
    compile project(':react-native-text-input-mask')
    compile project(':react-native-linear-gradient')
    compile project(':react-native-image-picker')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
    }
}

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

android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'

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

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

subprojects {
  project.configurations.all {
     resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'&& !details.requested.name.contains('multidex')
        ) {
           details.useVersion "27.1.0"
        }
     }
  }
}

I've tried a lot of solutions but nothing helped.

Change navigation bar on android with RN with expo?

$
0
0

I started using React Native with Expo, and I got my first problem, and I don't know how to deal with it. I want to change the navigation bar on Android to dark or to a custom color, but I can't figure out how to do it. Do you have any idea?

I tired to deal with https://github.com/thebylito/react-native-navigation-bar-color#readme but it returns:

TypeError: TypeError: null is not an object (evaluating 'NavigationBarColor.changeNavigationBarColor')

if (Platform.OS == 'android') {
  changeNavigationBarColor('#f00', true);
}

Do i need a local database for my app or a big object

$
0
0

consider a project that user can create auctions and others can make bids, i wonder if i need a DB or a big object can do the job.

let me explain this. this is an online job, user need to be online to see auctions and make a bid. app must fetch data from APIs and show 'em to user. no data must be out of date. so user must see what is exactly available on server side.

now i wonder if i need to have a database in my app and load these data to this DB or just have a big Object (singleton pattern) which has all fields (like auctions - bids - or any other data) and just use this object to my jobs.

in my vision i can't think about any data which i need to store offline, so what gains may DB still give me?

btw in second approach, if all classes are modeled and put in that object, it will exactly look like DB scheme

Pick multiple images in react native Expo with Imagepicker

$
0
0

It seems like Expo only supports imagepicker for selecting one image rather than multiple images. Is there any way to pick multiple images without ejecting expo or starting new react-native-init?


React native google sign in error with error code 10 in release mode

$
0
0

I am facing an issue in react native google sign in . Google sign in works fine in debug mode but after putting it in release mode it gives me error with error code 10.

I tried many possible way but none of them did work. I put the SHA-1 Key from both ./android/debug.store and android.jks file from app folder in firebase console. I also put the signing key from the play console to the firebase console. But that didn't work either. I have checked webclientId is also correct in Google.configure() method.

What can I do? Are there other ways in which this problem can be solved?

Reset password in a P2P native app using only username

$
0
0

I'm about to develop a P2P native chat app for android using react native. I would like to log in my user by asking for a username and a password. In case the user forgets his password is there any way to reset it without create the user from the start and losing all the data stored in device like chats or contacts?

react-Native: background image on iOS has cannot cover all the screen

$
0
0

The background image is not filling the whole screen on iOS devices, despite trying different options in styles. while on Android devices it looks fine and fills all the background space.

I got the same issue on iPhone6 device, also on the iPhone 11 emulator. There appears to be white edges on the left and the right which the background image does not cover, but this does not happen on android devices.

Here is a picture of both emulators of iOS and android side by side, iOS is on the right.

picture of emulators

I tried using the styles property resizeMode , with values such as 'cover', 'stretch', 'contain' etc , but none of them seemed to make a difference.. here is the code :

import React from 'react';
import { Text, View, Platform, ImageBackground } from 'react-native';
import { Button } from 'native-base'

var myBackground = require('./assets/icons/landing.jpg')

export default function App() {
  return (
    <View style={styles.container}>
      <ImageBackground
        source={myBackground}
        style={styles.imageStyle}
        >
        <View style={styles.viewStyle}>
          <Text
            style={styles.titleStyle}
          >Welcome to pokeSearch</Text>
          <Button
            block={true}
            style={styles.buttonStyle}
            onPress={() => { }}
          >
            <Text style={styles.buttonText}>Start Searching</Text>
          </Button>
        </View>
      </ImageBackground>


    </View>
  );
}

const styles = {
  container: {
    flex: 1,
    // marginTop: Platform.OS === "android" ? 20 : 0,
    justifyContent: 'center',
    alignItems: 'center'

  },
  buttonOuterLayout: {
    flex: 1,
    flexDirection: 'column',
    justifyContent: 'center',
    alignItems: 'center',


  },
  buttonLayout: {
    // marginTop: 10,
    // paddingRight: 10,
    // paddingLeft: 10

  },
  viewStyle: {
    flex: 1,
    flexDirection: 'column',
    justifyContent: 'center',
    alignItems: 'center'
  },
  titleStyle: {
    fontSize: 30,
    color: 'blue',
    alignItems: 'center'

  },
  imageStyle: {
    // flex: 1,
    width: null,
    height: null,
    resizeMode: 'contain'

    // justifyContent: 'flex-end',
    // alignItems: 'center'
  },

  buttonStyle: {
    margin: 10

  },
  buttonText: {
    color: 'white'
  }
}

I want the background image to cover the background on iOS like it does on android.

onNotificationOpened works in Android emulator but not in actual device

$
0
0

I am using firebase notification module in my react-native application. It works perfectly in emulator but when I install the app in mobile, onNotificationOpened event listener never gets called when I open the notification. what am i missing ?

Environment

  • Development Operating System: Windows

Build Tools:

  • React Native version: 0.60.5
  • React Native Firebase Version: 5.5.6
  • Firebase Module: notifications

Code Snippet:

  this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
      Linking.openURL('https://www.google.com/');
  });

  /*
  * If your app is closed, you can check if it was opened by a notification being clicked / tapped / opened as follows:
  * */
  const notificationOpen = await firebase.notifications().getInitialNotification();
  if (notificationOpen) {
      Linking.openURL('https://www.google.com/');
  }

Can not run React-Native app on Android with Firebase

$
0
0

So I was working with RN 0.59 it worked just fine then I started a new project with RN 0.60 and implemented everything in the same way then now when I try to run my app in Android Studio I get this message:

Task :react-native-firebase:compileDebugJavaWithJavac FAILED /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/ReactNativeFirebaseAppRegistrar.java:20: error: package android.support.annotation does not exist import android.support.annotation.Keep; ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/ReactNativeFirebaseAppRegistrar.java:29: error: cannot find symbol @Keep ^ symbol: class Keep /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStoragePackage.java:3: error: package android.support.annotation does not exist import android.support.annotation.RequiresPermission; ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java:7: error: cannot find symbol import android.support.v4.app.NotificationManagerCompat; ^ symbol: class NotificationManagerCompat location: package android.support.v4.app /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java:8: error: package android.support.v4.content does not exist import android.support.v4.content.LocalBroadcastManager; ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:5: error: package android.support.v4.content does not exist import android.support.v4.content.LocalBroadcastManager; ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseBackgroundNotificationActionReceiver.java:8: error: cannot find symbol import android.support.v4.app.RemoteInput; ^ symbol: class RemoteInput location: package android.support.v4.app /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java:10: error: cannot find symbol import android.support.v4.app.RemoteInput; ^ symbol: class RemoteInput location: package android.support.v4.app /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java:11: error: package android.support.v4.content does not exist import android.support.v4.content.LocalBroadcastManager; ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:20: error: package android.support.annotation does not exist import android.support.annotation.RequiresApi; ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:21: error: package android.support.v4.content does not exist import android.support.v4.content.LocalBroadcastManager; ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:15: error: cannot find symbol import android.support.v4.app.NotificationCompat; ^ symbol: class NotificationCompat location: package android.support.v4.app /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:16: error: cannot find symbol import android.support.v4.app.RemoteInput; ^ symbol: class RemoteInput location: package android.support.v4.app /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:407: error: package NotificationCompat does not exist private NotificationCompat.Action createAction( ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:494: error: cannot find symbol private RemoteInput createRemoteInput(Bundle remoteInput) { ^ symbol: class RemoteInput location: class DisplayNotificationTask /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/analytics/RNFirebaseAnalyticsPackage.java:3: error: package android.support.annotation does not exist import android.support.annotation.RequiresPermission; ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStoragePackage.java:17: error: cannot find symbol @RequiresPermission( ^ symbol: class RequiresPermission location: class RNFirebaseStoragePackage /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:370: error: cannot find symbol @RequiresApi(api = 26) ^ symbol: class RequiresApi location: class RNFirebaseNotificationManager /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:384: error: cannot find symbol @RequiresApi(api = 26) ^ symbol: class RequiresApi location: class RNFirebaseNotificationManager /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:398: error: cannot find symbol @RequiresApi(api = 26) ^ symbol: class RequiresApi location: class RNFirebaseNotificationManager /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:414: error: cannot find symbol @RequiresApi(api = 26) ^ symbol: class RequiresApi location: class RNFirebaseNotificationManager /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:457: error: cannot find symbol @RequiresApi(api = 26) ^ symbol: class RequiresApi location: class RNFirebaseNotificationManager /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/analytics/RNFirebaseAnalyticsPackage.java:17: error: cannot find symbol @RequiresPermission( ^ symbol: class RequiresPermission location: class RNFirebaseAnalyticsPackage /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java:36: error: cannot find symbol LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context); ^ symbol: class LocalBroadcastManager location: class RNFirebaseMessaging /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java:36: error: cannot find symbol LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context); ^ symbol: variable LocalBroadcastManager location: class RNFirebaseMessaging /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java:90: error: cannot find symbol Boolean enabled = NotificationManagerCompat ^ symbol: variable NotificationManagerCompat location: class RNFirebaseMessaging /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:26: error: cannot find symbol LocalBroadcastManager ^ symbol: variable LocalBroadcastManager location: class RNFirebaseMessagingService /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:41: error: cannot find symbol LocalBroadcastManager ^ symbol: variable LocalBroadcastManager location: class RNFirebaseMessagingService /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:51: error: cannot find symbol LocalBroadcastManager ^ symbol: variable LocalBroadcastManager location: class RNFirebaseMessagingService /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseBackgroundNotificationActionReceiver.java:62: error: cannot find symbol Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); ^ symbol: variable RemoteInput location: class RNFirebaseBackgroundNotificationActionReceiver /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java:54: error: cannot find symbol LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context); ^ symbol: class LocalBroadcastManager location: class RNFirebaseNotifications /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java:54: error: cannot find symbol LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context); ^ symbol: variable LocalBroadcastManager location: class RNFirebaseNotifications /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java:308: error: cannot find symbol Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); ^ symbol: variable RemoteInput location: class RNFirebaseNotifications /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:204: error: cannot find symbol LocalBroadcastManager ^ symbol: variable LocalBroadcastManager location: class RNFirebaseNotificationManager /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:81: error: package NotificationCompat does not exist NotificationCompat.Builder nb; ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:84: error: package NotificationCompat does not exist nb = new NotificationCompat.Builder(context, channelId); ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:87: error: package NotificationCompat does not exist nb = new NotificationCompat.Builder(context); ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:130: error: package NotificationCompat does not exist NotificationCompat.BigPictureStyle bp = new NotificationCompat.BigPictureStyle(); ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:130: error: package NotificationCompat does not exist NotificationCompat.BigPictureStyle bp = new NotificationCompat.BigPictureStyle(); ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:158: error: package NotificationCompat does not exist NotificationCompat.BigTextStyle bt = new NotificationCompat.BigTextStyle(); ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:158: error: package NotificationCompat does not exist NotificationCompat.BigTextStyle bt = new NotificationCompat.BigTextStyle(); ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:361: error: package NotificationCompat does not exist NotificationCompat.Action action = createAction(context, a, intentClass, notification); ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:424: error: package NotificationCompat.Action does not exist NotificationCompat.Action.Builder ab = new NotificationCompat.Action.Builder( ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:424: error: package NotificationCompat.Action does not exist NotificationCompat.Action.Builder ab = new NotificationCompat.Action.Builder( ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:437: error: cannot find symbol RemoteInput remoteInput = createRemoteInput(ri); ^ symbol: class RemoteInput location: class DisplayNotificationTask /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:496: error: package RemoteInput does not exist RemoteInput.Builder rb = new RemoteInput.Builder(resultKey); ^ /Users/kiralymark/Desktop/morzsa/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java:496: error: package RemoteInput does not exist RemoteInput.Builder rb = new RemoteInput.Builder(resultKey); ^ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 47 errors

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':react-native-firebase:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

I imported everything as the docs said. Anyone had the same issue? I looked for answers anywhere but none of them was clear.

How to add "Set as Wallpaper" option in React Native app

$
0
0

How to enable option "set as wallpaper" ? I'm using expo and I'm not able to find any API to enable that functionality. I only able to download image. I want to trigger set as wallpaper option. I tried to use react-native-wallpaper-manager library but it has not worked for me.

AAB file is too larger than IPA file after production build in React Native

$
0
0

I have been working on React-Native for 3 months. All these days I was building the app only for android platform and the size of AAB file was 36.5 MB, Today I built my app to iOS (IPA File). The size of IPA file is just 5.6 MB.

No code changes, No new library installations,

But why both files have a huge difference in size?

Thank you!


Custom Native Module stoped working on android after upgrading to react native 0.61

$
0
0

I upgraded my react native to 0.61.2 from 0.59.9, ever since then, I cannot use my custom native modules on android.

Tried to use the code from the guide in react native ( https://facebook.github.io/react-native/docs/native-modules-android ) to see if something changed in the new version of RN, but I keep getting

   TypeError: Cannot read property 'show' of undefined.

This is the basic of my code:

ToastModule.java

        public class ToastModule extends ReactContextBaseJavaModule {

        ...

        @Override
        public String getName() {
            return "ToastExample";
        }

        @ReactMethod
        public void show(String message, int duration) {
            Toast.makeText(getReactApplicationContext(), message, duration).show();
        }

        }

CustomToastPackage.java

        public class CustomToastPackage implements ReactPackage {
        ...
            @Override
            public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
                return Arrays.<NativeModule>asList(new ToastModule(reactContext));
            }

        }

MainApplication.java

        ...

        import com.xxx.CustomToastPackage;

        public class MainApplication extends NavigationApplication {

        ...

            @Nullable
            @Override
            public List<ReactPackage> createAdditionalReactPackages() {
                return new PackageList(this).getPackages();
            }

            protected List<ReactPackage> getPackages() {
                List<ReactPackage> packages = new ArrayList<>();
                packages.add(new IntercomPackage());
                packages.add(new CustomToastPackage());
                return packages;
            }


        }

example.js

        import {NativeModules} from 'react-native';
        NativeModules.ToastExample.show("test", NativeModules.ToastExample.DURATION_SHORT_KEY)

When tried to debug in JS, I see that the NativeModules object exported from react-native really doesn't have the desired modules.

It's critical for me to get native modules working.

What am I missing?

Swipe left/right not working in Android emulator - React Native app

$
0
0

Is there a setting to allow swipe gestures in the emulator? I am using react-navigation, but also am using react-native-swipe-gestures and no swipe, left or right, is working on any page under any circumstance. I go to Chrome in the emulator and go from page to page and still cannot swipe left or right within Chrome (am I supposed to be able to swipe in Chrome in Android?)

I am unfamiliar with Android - is there something I am missing? I have a very big, complicated app and am just now testing in Android. Everything works great in iOS.

I have implemented this already to install react-navigation properly for Android and linked everything properly.

How to able to open the app when I click notification on React Native Track Player?

$
0
0

i using react-native-track-player for play my music stream. I want to open my app when i Click Notification. I read a documentation but I can't found some there.

Why Might This React Native Package Not Work With Versions Of Android Above 8?

$
0
0

I know this is a long shot but it seems like one of the only options for my video calling app apart from having to write my own native Java module.

I'm using react-native-invoke-app to launch my React Native Android app when it receives a data only Firebase Cloud Message with Headless JS.

For a long time I couldn't get it working but have discovered that the problem was that the package doesn't work with versions of Android greater than 8. I now have it working fine with Android 8. The problem now is that I obviously need it to work with newer versions, but haven't got the Java skills to fix it myself. It seems like the developer has stopped keeping it up to date.

I can't imagine it needs much to get it working (a guess), so my question is, is there anything obvious that may stop it working on versions of Android higher than 8? I don't know the details for Android releases well enough, but figure for those those that have more knowledge it might be more obvious.

Here's the main Java package:

package com.codegulp.invokeapp;

import android.app.ActivityManager;

import android.content.Context;
import android.content.Intent;

import android.os.Bundle;

import android.util.Log;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;

import java.util.List;

public class RNInvokeApp extends ReactContextBaseJavaModule {

    private static ReactApplicationContext reactContext;
    public static final String LOG_TAG = "RNInvokeApp";
    private static Bundle bundle = null;

    public RNInvokeApp(ReactApplicationContext context) {
        super(context);
        reactContext = context;
    }

    @Override
    public String getName() {
        return "ReactNativeInvokeApp";
    }

    @ReactMethod
    public void invokeApp(ReadableMap params) {
        ReadableMap data = params.hasKey("data") ? params.getMap("data") : null;

        if (data != null) {
            bundle = Arguments.toBundle(data);
        }

        String packageName = reactContext.getPackageName();
        Intent launchIntent = reactContext.getPackageManager().getLaunchIntentForPackage(packageName);
        String className = launchIntent.getComponent().getClassName();

        try {
            Class<?> activityClass = Class.forName(className);
            Intent activityIntent = new Intent(reactContext, activityClass);

            activityIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            reactContext.startActivity(activityIntent);
        } catch(Exception e) {
            Log.e(LOG_TAG, "Class not found", e);
            return;
        }

        if (isAppOnForeground(reactContext)) {
            sendEvent();
        }
    }

    public static void sendEvent() {
        if (bundle != null) {
            reactContext
                .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
                .emit("appInvoked", Arguments.fromBundle(bundle));
            bundle = null;
        }
    }

    private boolean isAppOnForeground(ReactApplicationContext context) {
        /**
         * We need to check if app is in foreground otherwise the app will crash.
         * http://stackoverflow.com/questions/8489993/check-android-application-is-in-foreground-or-not
         **/
        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
        if (appProcesses == null) {
            return false;
        }
        final String packageName = context.getPackageName();
        for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
            if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
                    && appProcess.processName.equals(packageName)) {
                return true;
            }
        }
        return false;
    }
}

Any ideas or tips on how to move forward are greatly appreciated!

How to set headers downloading a file using React Native and react-native-fs?

$
0
0

In order to download an asset an Authorization header needs to be set when using react-native-fs with React Native.

Following the documentation the header is set as such:

  const options = {
    headers: {
      Authorization: `Bearer ${accessToken}`,
    },
    fromUrl: url,
    toFile: path,
  };

  // const permission = await insurePermissions();

  const task = RNFS.downloadFile(options);

It works perfect in iOS however Android, using an emulator running either Android 6, 8, 9, or 10, the header isn't being sent so the server is instead returning a different asset with error because the user isn't being authenticated.

How is the Authentication header set in Android with react-native-fs?

Viewing all 29622 articles
Browse latest View live


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