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

Android React Native App HostNameVerifier Error from Google Play Store

$
0
0

Please help, I have the below implementation in MainApplication.java file. I am checking fixed hostnames and then returning true or false accordingly.

Error Insecure hostname verifier

Security Your app is using an unsafe implementation of hostnameverifier. Please see this Google Help Centre article for details,including the deadline for fixing the vulnerability.

Ld/a/a/a/a/c/e$1; Ld/a/a/a/a/c/f$1; sv:deadline:12/10/2020

 @Override  public void onCreate() {    super.onCreate();    hostnameVerifier();    MobileCore.setApplication(this);    SoLoader.init(this, /* native exopackage */ false);    ReactNativeFirebaseApp.setApplicationContext(this);  }private void hostnameVerifier(){    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {      @Override      public boolean verify(String arg0, SSLSession arg1) {        String hostList[] = {"in.appcenter.ms", "graph.facebook.com","assets.adobedtm.com", "codepushupdates.azureedge.net", "app-measurement.com","forter.com", "dmn1", "dmn2", "dmn3", "quantummetric.com", "urbanairship.com", "demdex.net", "search.unbxd.io","monetate.net", "bazaarvoice.com", "google.com", "stylitics.com", "getcandid.com","braintreegateway.com"          };          for (String host : hostList) {            if (host.contains(arg0) || arg0.endsWith(host)) {              return true;            }          }        return false;      }    });  }

What should I change, please help.


Getting “keystore.keyAlias” is not allowed to be empty error while building app apk from expo client

$
0
0

I have entered the alias, when I press enter it goes to new line and is stuck.Pressing enter again asks for key password, I enter it and press enter and the error is displayed.“keystore.keyAlias” is not allowed to be empty

enter image description here

How do I force an expo app to update

$
0
0

I have an app written in expo, and can't figure out how to push a new build. On the expo site if I run the app from the QR code the app is correct, but the native app from the app store doesn't update.

The steps I've been using are 1) exp build:android2) exp publish

How do I make the app actually update?

What's causing Expo's ImagePicker.launchCameraAsync() to crash the app on some android devices?

$
0
0

I have a managed expo app that uses expo SDK 39 and expo image picker ("expo-image-picker": "~9.1.0") currently in production. Some android users have reported the camera feature "not working" which makes a call to ImagePicker.launchCameraAsync(). I have been able to reproduce it on a Nexus S Emulator running android 10, the whole app crashes. No error messages are logged.

I thought that the issue was specific to Android 10, however some users reported the issue on Android 11 (and android 8).

I tried wrapping a try-catch block to pull out an error, with no luck, the app still crashes, and no logs.

I also tried making a dummy app with only the above functionality in question, however I get the same results on the Nexus S emulator: The app crashes, no reports logged.

Here is an example of the function call which is triggering the crashes.

const takeImage = async () => {    let result = await ImagePicker.launchCameraAsync({      mediaTypes: ImagePicker.MediaTypeOptions.Images,      allowsEditing: true,        aspect: [4, 3],      quality: 1,      base64: true,    });    if (!result.cancelled) {      console.log(result.uri);    }  };

Running Emulators on Different Device for React Native Applications

$
0
0

Since Xcode and Android studio consume a lot, I am having storage and processing capacity issues on my Mac, while developing React Native Applications.

My Question is that is there any way to run emulators (in my case android emulator) on another PC, while I am coding on Mac?

Thank you

navigationOptions weird behaviour

$
0
0

enter image description hereFirst time open the page, navigationOptions futures don't work but when I run props.navigation.navigate methot or ctrl+s in main navigation file, it works

[ ][1]

Google play console API issues

$
0
0

enter image description hereI am trying to upload a bundle (.aab) to put out a new update of an app.I am able to bundle and sign properly, but when I try and upload the .aab I get this error

Your app currently targets API level 27 and must target at least API level 29 to ensure it is built on the latest APIs optimized for security and performance. Change your app's target API level to at least 29. Learn MoreYou need to use a different version code for your APK or Android App Bundle because you already have one with version code 1.

My gradle.build is targetting API 29 and the version code is 9. I'm not sure what's going on here.

android {    compileSdkVersion 29    buildToolsVersion rootProject.ext.buildToolsVersion    defaultConfig {        applicationId "com.organization.myApplication        minSdkVersion rootProject.ext.minSdkVersion        targetSdkVersion 29        versionCode 9        versionName "9"    }...}

One solution I have come across is to update app/build.gradle to target SDK 29 then sync project with gradle files. However, it tells me that this is not a gradle based project. From what I understand it is. I imported the project with gradle, there is a gradle wrapper and I have build.gradle and settings.gradle both in the top of the android folder. The build.gradle at the top level is a configuration buildscript, where as the build.gradle that targets SDK 29 is in the android/app folder.

How to add manually a library to Android in react native?

$
0
0

Hello I'm new in react native and I was try to add the [react-native-svg][1] library

And I think the problem is in the last step, MainApplication.java

@Overrideprotected 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 new SvgPackage());  return packages;}

Error message

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: - react-native-svg (to unlink run: "react-native unlink react-native-svg")

Any suggestion?


react native error package android.support.v7.app does not exist

$
0
0

in react-native-video when react-native run-android these error occursand i can't delete these

android.useAndroidX=trueandroid.enableJetifier=true from gradle.properties

i need them for react native gesture handler

try to add implementation 'androidx.appcompat:appcompat:${rootProject.ext.supportLibVersion}'

but it dose not work

enter image description here

package com.sales_crm;import android.app.ProgressDialog;import android.content.Intent;import android.content.pm.ActivityInfo;import android.graphics.PixelFormat;import android.media.MediaPlayer;import android.net.Uri;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.util.Log;import android.widget.MediaController;import android.widget.Toast;import android.widget.VideoView;public class VideoActivity extends AppCompatActivity {    private String videoPath;    private static ProgressDialog progressDialog;    VideoView myVideoView;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);        setContentView(R.layout.player_fullscreen);        Intent i = getIntent();        if(i != null){            myVideoView = (VideoView) findViewById(R.id.videoView);            videoPath = i.getStringExtra("VIDEO_URL");            progressDialog = ProgressDialog.show(VideoActivity.this, "", "Buffering video...", true);            progressDialog.setCancelable(true);            PlayVideo();        }        else{            Toast.makeText(VideoActivity.this, "VideoURL not found", Toast.LENGTH_SHORT).show();        }    }    private void PlayVideo() {        try {            getWindow().setFormat(PixelFormat.TRANSLUCENT);            MediaController mediaController = new MediaController(VideoActivity.this);            mediaController.setAnchorView(myVideoView);            Uri video = Uri.parse(videoPath);            myVideoView.setMediaController(mediaController);            myVideoView.setVideoURI(video);            myVideoView.requestFocus();            myVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {                public void onPrepared(MediaPlayer mp) {                    progressDialog.dismiss();                    if(BridgeModule.duration!=0)                     myVideoView.seekTo(BridgeModule.duration);                    myVideoView.start();                }            });        } catch (Exception e) {            progressDialog.dismiss();            System.out.println("Video Play Error :"+ e.toString());            finish();        }    }}

my dependencies

dependencies {    implementation project(':react-native-share')    implementation project(':react-native-sound')    implementation project(':react-native-sound-player')    implementation project(':react-native-orientation-locker')    implementation project(':react-native-document-picker')    implementation project(':react-native-image-picker')    implementation project(':rn-fetch-blob')    implementation project(':react-native-pdf')    implementation project(':react-native-maps')    implementation project(':react-native-video')    implementation project(':react-native-vector-icons')    implementation project(':react-native-gesture-handler')    implementation project(':@react-native-community_async-storage')    implementation fileTree(dir: "libs", include: ["*.jar"])    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"    implementation "com.facebook.react:react-native:+"  // From node_modules}

Notifications React Native

$
0
0

Let's see... I want to send a notification in my application, when a data is uploaded to Firebase. For example, as an administrator, I upload an offer to firebase (In the application), and I want it to send it to all installed applications.

The application has a CRUD for registered users, and for non-registered users it only lets them see the list of objects.

What is the common approach to offering an ad version of your app when users do not have an account?

$
0
0

I will be placing google ads in my mobile app but because it's more or less just an app which provides data, I will not be implementing any sort of user registration.

I would like to know what is the correct protocol for submitting a paid and unpaid version of the same app one is just without ads. Is it as simple as create 2 apps in the google app console and export one with ads built in and one without, or is there some form of API that you can use?

If it is just creating 2 app projects in the console, do I have to change the package name? Are there any conflicts that I should look for? I am using React-Native if that is important and for now exporting to only Android.


Edit:People have recommended I use a single in-app purchase, but my issue is how am I supposed to detect whether a user has paid for the app or not if I'm not tracking users?

React Native Android Native Module Works Well on Debug but Doesn't Work on Release

$
0
0

I've created an Android Native Module in my React Native App to get User Installed Apps List. it works well on Debug but doesn't work on Release.

*Note : I've also tried to use a npm package called react-native-android-installed-apps, but itdoesn't work, so I decided to created a Native Module.

I don't know what's wrong that caused my Native Module works on Debug but doesn't work on Release. It will be great and I'll really appriciate it if anyone can point out to me what's wrong.

Here's my code:

@ReactMethodpublic void getUserInstalledApps(Callback successCallback) throws JSONException { PackageManager pm = reactContext.getPackageManager(); WritableArray array = new WritableNativeArray(); List<AppList> apps = new ArrayList<AppList>(); Gson g = new Gson(); List<PackageInfo> packs = reactContext.getPackageManager().getInstalledPackages(0); for (int i = 0; i < packs.size(); i++) {   PackageInfo p = packs.get(i);     if ((!isSystemPackage(p))) {       String appName = p.applicationInfo.loadLabel(reactContext.getPackageManager()).toString();       String packages = p.applicationInfo.packageName;       apps.add(new AppList(appName, packages));     }   }   for (AppList co : apps) {     JSONObject jo = new JSONObject(g.toJson(co));     WritableMap wm = convertJsonToMap(jo);     array.pushMap(wm);   }   successCallback.invoke(array);}private boolean isSystemPackage(PackageInfo pkgInfo) {  return (pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;}public class AppList { private String name; private String packages; public AppList(String name, String packages) {   this.name = name;   this.packages = packages; } public String getName() {   return name; } public String getPackages() {   return packages; }}

How to access files in folder in react native

$
0
0

I am currently stuck on how to get the files inside a folder. I have the directory to get to the folder I want. I've seen people use rnfletch-blob, but I am not sure how to install nor use it.

Change default react-native android port

$
0
0

The problem

I'm developing an app which uses MongoDB realm and Redux. When only redux is in the project, no problem. But then after debuggin it with realm installed errors started happening. Realm is using port=8083 for its XML requests, while React Native is running by default in port=8081. So, when realm does its first XML request to initialize the realm app react native crashes.

error in debugger

The troubleshooting

By looking at the react-native-debugger documentation its possible to change de debugger port. Nice! And then i searched for a way to do the same in react-native. As weird as it sounds, apparently react-native's android port is hardcoded by the react-native init, meaning that only the default 8081 port works. Actually, only the metro server and ios port can be changed. I requested support from MongoDB, about changing their default port to 8081. But still waiting for an answer.

This is the app repositoryAny suggestion?

Thanks in advance!

Error: Invalid hook call api FlatList react-native

$
0
0

I have a error on my react-native project, I use typescript and expo. So, when I use useEffect() to get api response to FlatList I receive this error:enter image description here

My code:

import React, { useEffect, useState } from 'react';import {  Image,  Text,  View,  SafeAreaView,  FlatList} from "react-native";import { useNavigation } from '@react-navigation/native';import { TouchableOpacity } from 'react-native-gesture-handler';import styles from './styles';function Products() {    const [apiProduct, setProduct] = useState([]);    useEffect(() => {        fetch('https://laravel-api.com/v1/product',{                method: 'GET',                headers: {'Accept'        : 'application/json'                },        })        .then(response =>response.json())        .then(data => {                setProduct(data.data)            })    }, []);    return (<View style={styles.container}><Text style={styles.title1}>                {"Produtos mais Buscados"} {"\n"}</Text><SafeAreaView><FlatList                         data={apiProduct}                        keyExtractor={(apiProduct) => apiProduct }                        contentContainerStyle={{ flexGrow: 1 }}                        renderItem={viewProduct}></FlatList></SafeAreaView></View>    );}function viewProduct(item) {    const navigation = useNavigation();    const { id, name, price, category_name, img_url } = item.item    const imgUrl = "https://s3.url.com/" + img_url;    return (<View style={styles.prodList}><Image source={{ uri: imgUrl }} style={styles.prodImage} /> <TouchableOpacity                 style={styles.prodName}                onPress={() => {                    navigation.navigate('productView', {                      itemId: id,                    });                  }}><Text>{name} {"\n"} </Text><Text style={styles.prodCategory}>{category_name.toUpperCase() } {"\n"}</Text><Text style={styles.prodPrice}>{"R$ " + price }</Text></TouchableOpacity></View>    )}export default Products;

but, if I remove the navigation method navigation.navigate('productView', {itemId: id});, this error desapear.


installed react native navigation and react native router flux in a running project. After installing the packages the project is not running

$
0
0

I installed the navigation and the react-native-router-flux in the project. And then got the errors

error Unrecognized command "run-andriod". Did you mean "run-android"?info Run "react-native --help" to see a list of all available commands.error Command failed with exit code 1.info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

and the 'adb devices' command is not showing any of the connected devices

React navigation 5 really slow and dropping JS FPS on Expo

$
0
0

I am currently working on a React Native (Expo) App and I am facing some performance issues. I have not found any answer yet for my problem so I hope someone can help me.

My problem is that whenever I launch the app on my physical device (Galaxy S9+) and navigate to different screens, I notice JS frames dropping from 60 all the way to like 10-30. I have a main drawer navigator, a bottom tab navigator and some stack navigators. I have basic View, Text, ... component so I don't think it is due to heavy components.(I am using react-navigation v5)

I also have to mention that I don't really see any lack of performance or JS FPS drops on an iOS simulator.

react-native run-android debugging on a physical Android TV device

$
0
0

I am trying to get react-native run-android to run on my Chromecast with Google TV from my Mac OS.
I have no problem connecting to that device with adb connect, and running logcat, and i also have no problem running react-native run-android when an Android Phone is connected to my computer.
Is this a limitation from React native or am I missing something obvious?

npx react-native run-android does not work - "java.io.IOException: The filename, directory name, or volume label syntax is incorrect"

$
0
0

Just recently ejected expo and I'm trying to run my app on an android device. I followed the instructions (hopefuly right) but I keep getting this error when I try to run my app:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warningsFAILURE: Build failed with an exception.* What went wrong:A problem occurred configuring project ':app'.> java.io.IOException: The filename, directory name, or volume label syntax is incorrect* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.* Get more help at https://help.gradle.orgBUILD FAILED in 3serror Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081FAILURE: Build failed with an exception.* What went wrong:A problem occurred configuring project ':app'.> java.io.IOException: The filename, directory name, or volume label syntax is incorrect* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.* Get more help at https://help.gradle.orgBUILD FAILED in 3s    at makeError (C:\Users\User\Documents\jad for eject\jad\jad\node_modules\execa\index.js:174:9)    at C:\Users\User\Documents\jad for eject\jad\jad\node_modules\execa\index.js:278:16    at processTicksAndRejections (internal/process/task_queues.js:97:5)    at async runOnAllDevices (C:\Users\User\Documents\jad for eject\jad\jad\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)    at async Command.handleAction (C:\Users\User\Documents\jad for eject\jad\jad\node_modules\@react-native-community\cli\build\index.js:186:9)

Thanks for the help!

how to register lifecycle extension using native android code in react native

$
0
0

Iam implementing adobe analytics in my react native project,here i need to registerLifecycle with Mobile Core in native code.

iam adding the onResume and onPause in mainapplication.java but iam getting following errorerror: method does not override or implement a method from a supertype@Overrideerror: cannot find symbolsuper.onResume();^symbol: method onResume()

//mainapplication.java

 @Override     public void onResume() {        MobileCore.setApplication(this);      MobileCore.lifecycleStart(null);   }   @Override   public void onPause() {      MobileCore.lifecyclePause();   }
Viewing all 29783 articles
Browse latest View live


Latest Images

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