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

in-app update not working Bare Expo, possible onCreate not running and onResume causing Crashes

$
0
0

I am trying to add Android in-app updates feature onto my bare expo apps, however, after trying to add the code in MainActivities.java, the app just load into the app directly without updating even though it is shown that the version is behind.

I believe that onCreate function is not running since the app just loaded into the app directly while the version is behind the one in Google Play Store. However, I am unsure since many other places can be wrong without error messages.

These code are within MainActivity class

 private AppUpdateManager appUpdateManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(this);
////    Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
    appUpdateManager.getAppUpdateInfo().addOnSuccessListener(
                appUpdateInfo -> {
                    if ((appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE)
                            && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE))
                    {
                        try{
                          appUpdateManager.startUpdateFlowForResult(
                                // Pass the intent that is returned by 'getAppUpdateInfo()'.
                                appUpdateInfo,
                                // Or 'AppUpdateType.FLEXIBLE' for flexible updates.
                                AppUpdateType.IMMEDIATE,
                                // The current activity making the update rFragmentActivityequest.
                                this,
                                // Include a request code to later monitor this update request.
                                123);
                        }catch (IntentSender.SendIntentException e) {
                            e.printStackTrace();
                        }
                    };
                });
    }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 123) {
      if (resultCode != RESULT_OK) {
//           log("Update flow failed! Result code: " + resultCode);
      }
    }
  }

  @Override
  protected void onResume() {
    super.onResume();
    appUpdateManager
        .getAppUpdateInfo()
        .addOnSuccessListener(
            appUpdateInfo -> {
              // ...
              if (appUpdateInfo.updateAvailability()
                  == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
                    // If an in-app update is already running, resume the update.
                    try{appUpdateManager.startUpdateFlowForResult(
                      appUpdateInfo,
                      AppUpdateType.IMMEDIATE,
                      this,
                      123);
                    }catch (IntentSender.SendIntentException e) {
                        e.printStackTrace();
                    }
              }
            });
  }

Edit: Forgot to mention, onResume also causes the app to crash, but even if commented out onResume, it still never seems to get to the update.


React Navigation + Redux close App on Back Pressed

$
0
0

After converting the app to redux, my react-navigation got some problem. Previously, before integrating with redux, when I press back button (Physical button) react-navigation back to the previous screen. After integrating with redux, the back button will close the app. But, it's still working with goBack() function.

And, this is my Navigator configuration

export const AppNavigator = StackNavigator(
    {
        Home: { screen: HomeScreen },
        ChatDetail: { screen: ChatDetail },
        PulsaDetail: { screen: PulsaDetailScreen },
        Pulsa: { screen: Pulsa }
    },
    {
        headerMode: 'none',
    }
)

class AppWithNavigation extends Component {
    render(){
        return(
            <AppNavigator navigation={ addNavigationHelpers({
                dispatch: this.props.dispatch,
                state: this.props.nav,
            })} />
        )
    }
}

const mapStateToProps = (state) => ({
  nav: state.nav
})

export default connect(mapStateToProps)(AppWithNavigation)

EDIT: It's can be done with manual handle & dispatch back action, but it's can't do it automaticlly? just like before using redux?

BackHandler.addEventListener('hardwareBackPress',() => {
    this.props.goBack()
    return true
})

Microphone on Android SpeechRecognition stops working

$
0
0

I'm using android SpeechRecognition on an app made with react native. The library used is react-native-voice.

The app keep listening all the time for incoming sentences and sends them through 4 websockets to 4 servers.

I make keep listening calling startSpeech() every time onEndOfSpeech() or onError() are triggered.

The problem is that, only on some devices (for example a cheap android one), when i run the app, after a random amount of time (from 5 minutes to 2 hours of normal working) microphone stops working: the java method onRmsChanged() keeps returning -2.12( the same value returned when the app stops listening or finishes to recognize something) after a successful restart of speechRecognition with startSpeech() java method. It seems like the microphone stops listening due a kind of crash or resource unavailable. When it happens i call destroySpeech() and then startSpeech() but it still stops working after one or few more recognize attempt. If i close and reopen the app from android UI, it has the same behaviour as above (speechRecognition after from 5 to 20 minutes of normal working, crash, and then it keeps crashing)

I've made a sort of fix that restart the speechRecognition when the onRmsChanged() returns 20 consecutives times the wrong value above, in order to make it keep it listening as mush as possible, but is not a solution, cause there is no guarantee that onRmsChanged() will be called during running the app.

I'm using

Android 7.0
Physical device
Android building tools 28.0.3
gradle 3.3.1
react-native 0.59.8
react-native-voice 0.3.0

All the apps in the phone are not allowed to use notifications, draw over other apps and access to microphone, except Google App, Google Play Services and my app.

I would ask: it is possible that another service on background takes the control of the microphone resource in Android system in this way? Or it could be a kind of SpeechRecognition crash?

This is the log of react-native, where 'true' is the value returned by the method isAvailable() (if is available speechRecognition in the system) and 'volume' n is the value return by onRmsChanged():

9-27 11:52:30.425 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082
9-27 11:52:30.431 16130 16424 I ReactNativeJS: true 
9-27 11:52:30.495 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082
9-27 11:52:30.499 16130 16424 I ReactNativeJS: true 
9-27 11:52:30.545 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082
9-27 11:52:30.547 16130 16424 I ReactNativeJS: true 
9-27 11:52:30.557 16130 16424 I ReactNativeJS: speech start 
9-27 11:52:35.636 16130 16424 I ReactNativeJS: 'speech error', { error: { message: '6/No speech input' } } 
9-27 11:52:35.647 16130 16424 I ReactNativeJS: start listening 
9-27 11:52:35.729 16130 16424 I ReactNativeJS: speech start 
9-27 11:52:35.799 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082
9-27 11:52:35.806 16130 16424 I ReactNativeJS: true 
9-27 11:52:35.918 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082
9-27 11:52:35.921 16130 16424 I ReactNativeJS: true 
9-27 11:52:35.967 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082 
9-27 11:52:35.969 16130 16424 I ReactNativeJS: true 
9-27 11:52:36.019 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082 
9-27 11:52:36.024 16130 16424 I ReactNativeJS: true 
9-27 11:52:36.069 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082 
9-27 11:52:36.074 16130 16424 I ReactNativeJS: true 
9-27 11:52:36.121 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082 
9-27 11:52:36.128 16130 16424 I ReactNativeJS: true 
9-27 11:52:36.180 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082 
9-27 11:52:36.188 16130 16424 I ReactNativeJS: true 
9-27 11:52:36.222 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082 
9-27 11:52:36.224 16130 16424 I ReactNativeJS: true 
9-27 11:52:36.269 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082 
9-27 11:52:36.272 16130 16424 I ReactNativeJS: true 
9-27 11:52:36.323 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082 
9-27 11:52:36.331 16130 16424 I ReactNativeJS: true 
9-27 11:52:36.373 16130 16424 I ReactNativeJS: 'volume', -2.119999885559082 
9-27 11:52:36.381 16130 16424 I ReactNativeJS: true

Thank you

access environment variable in React-Native AndroidManifest.xml

$
0
0

I'm new to React Native. The task at hand is to set my Google API key in AndroidManifest.xml without exposing it, when pushed to GitHub. I set up an environment variable called API_KEY, but however I want to access it in the .xml, I get an error when trying to spin up the dev server.

So far I tried:

android:value=${env.API_KEY}
android:value="${env.API_KEY}"
android:value="${API_KEY}"

Thank you!

How to create wallet app and what all certificates required for the same?

$
0
0

I want to create a wallet application with the following features:

  1. We can store user bank account details (Is it possible?)
  2. User can store money in his wallet and transfer it to his account at any time
  3. We can store user card details

for doing the same:

What all certifications, licenses, and permission we need?

What all the security measures we have to follow?

what will be the best DB for this?

App not showing up in Google Play Store for Galaxy S8+ (model G955U), what can be the problem?

$
0
0

I have an app in Google Play, which has such configuration:

    minSdkVersion = 21
    compileSdkVersion = 28
    targetSdkVersion = 28
    buildToolsVersion = '28.0.0'
    supportLibVersion = '28.0.0'

One of the potential user which has Galaxy S8+ (model G955U) can't see my app in Google Play. I checked the list of the supported devices in Google Play for my app and I see that other model of Galaxy S8+ is supported, but this particular model (model G955U) is not. User has latest OS on his phone. What can be the problem? What should I do so my app can support this phone model as well?

enter image description here

Android Studio setting node directory for build (Cause: error=2, No such file or directory)

$
0
0

My project build fails because it's using the incorrect directory to run Node. How do I go about setting the Node directory for these compile-time tasks?

The specific task is:

app:recordFilesBeforeBundleCommandDebug

And the related error:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:recordFilesBeforeBundleCommandDebug'.
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'node''
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'node'
Caused by: java.io.IOException: Cannot run program "node" (in directory "/Users/me/Code/appname/android/app"): error=2, No such file or directory
Caused by: java.io.IOException: error=2, No such file or directory

React Native VLCPlayer RTSP Latency (Android version)

$
0
0

I am using react-native-yz-vlcplayer for a react native application. I have a latency problem on android, the latency is too high. On iOS, I have almost no latency thanks to the plugin options:

 mediaOptions={{
 ':network-caching': 0,
 ':live-caching': 0,
 }}

I use this plugin to broadcast an RTSP feed.

I don't know how to do that in JAVA.

I also opened an issue on the player's github but no conclusive answer.

I think I need to modify the file ReactVlcPlayerView.java. I tried to follow this solution, but I couldn't fix the problem, maybe I'm completely wrong but can you help me?

Thank you so much.


Firebase in app messaging for React Native not displaying

$
0
0

I have an Android React Native app which uses Firebase. It now requires in app messaging for which I have followed the instructions here.

When I send a test message from Firebase using the instance id for my Android emulator, I get the following when restarting the app:

2019-11-21 15:26:43.472 6075-6075/? I/FIAM.Headless: Starting InAppMessaging runtime with Instance ID xxxxx
2019-11-21 15:26:43.746 6075-6075/? I/FIAM.Headless: Setting display event listener
2019-11-21 15:26:43.752 6075-6075/? I/FIAM.Headless: went foreground
2019-11-21 15:26:43.759 6075-6110/? I/FIAM.Headless: Forcing fetch from service rather than cache. Test Device: true | App Fresh Install: true
2019-11-21 15:26:43.780 6075-6110/? W/FIAM.Headless: Recoverable exception while reading cache: /data/user/0/example.app/files/fiam_impressions_store_file: open failed: ENOENT (No such file or directory)
2019-11-21 15:26:43.795 6075-6110/? I/FIAM.Headless: Fetching campaigns from service.
2019-11-21 15:26:49.556 6075-6110/example.app I/FIAM.Headless: Successfully fetched 1 messages from backend

Judging by the last line, a message has been received. However nothing is displayed in the app on the emulator.

The only change I made was to use an older version of com.google.firebase:firebase-inappmessaging-display and com.google.firebase:firebase-analytics so that the gradle files synced correctly. My build.gradle file:

    implementation "com.google.android.gms:play-services-base:16.0.1"
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation "com.google.firebase:firebase-core:16.0.6"
    implementation "com.google.firebase:firebase-firestore:17.1.5"
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation "com.google.firebase:firebase-storage:16.1.0"
    implementation "com.google.firebase:firebase-messaging:17.3.4"
    implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.5'
    implementation 'com.google.firebase:firebase-analytics:16.0.6'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
        transitive = true
    }
    implementation "com.google.android.gms:play-services-auth:16.0.1"

Is there something else I need to do in addition to the above instructions?

Task :react-native-firebase:compileReleaseJavaWithJavac FAILED

$
0
0

I clone my own repo. project in on react native, I installed node modules and set Jdk8 as per requirements of my project. Then i run my project using react-native run-android. show me error

Task :react-native-firebase:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

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

    Could not create service of type GeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().

  • 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.org

BUILD FAILED in 1m 3s 13 actionable tasks: 2 executed, 11 up-to-date Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/getting-started.html

Command failed: ./gradlew installDebug

Error: Command failed: ./gradlew installDebug at checkExecSyncError (child_process.js:601:13) at Object.execFileSync (child_process.js:621:13) at runOnAllDevices (/Volumes/Transcend/Emjoy/admin_panel_app_emjoy/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19) at buildAndRun (/Volumes/Transcend/Emjoy/admin_panel_app_emjoy/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12) at isPackagerRunning.then.result (/Volumes/Transcend/Emjoy/admin_panel_app_emjoy/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12) at at process._tickCallback (internal/process/next_tick.js:188:7)

My version of react-native,react-native-cli, react-native-firebase all packages is the same as a project required.

react-native-push-notification cannot receive any push notification from firebase

$
0
0

I've try to test push notification on CDM Firebase but still cannot receive any push notification. I'm using react-native-push-notification package, try to local notification or scheduled it works but with CDM Firebase got nothing and i've already sync my device on google service wizard setup

Here my files

Pushcontroller already called on splash screen (debug and works show token response)

import React, {Component} from "react";
import PushNotification from "react-native-push-notification";
export default class PushController extends Component{
  componentDidMount(){
    PushNotification.configure({
        onRegister: function(token) {
          console.log("TOKEN:", token);
        },

        onNotification: function(notification) {
          console.log("NOTIFICATION:", notification);

          notification.finish(PushNotificationIOS.FetchResult.NoData);
        },
        senderID: "xxxxxxxxx",
        permissions: {
          alert: true,
          badge: true,
          sound: true
        },
        popInitialNotification: true,
        requestPermissions: true
      });
 }

   render(){
    return null;
   }
 }

/android/build.gradle

// Top-level build file where you can add configuration options common to all sub- 
projects/modules.
buildscript {
    ext {
        googlePlayServicesVersion = "+" // default: "+"
        firebaseVersion = "+" // default: "+"

        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.3.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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


task wrapper(type: Wrapper) {
    gradleVersion = '4.7'
    distributionUrl = distributionUrl.replace("bin", "all")
}

AndroidManifest

<uses-permission android:name="android.permission.WAKE_LOCK" />
  <permission
      android:name="com.qas.permission.C2D_MESSAGE"
      android:protectionLevel="signature" />
<uses-permission android:name="com.qas.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<application

  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/AppTheme">

  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
          android:value="YOUR NOTIFICATION CHANNEL NAME"/>
  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
              android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>
  <!-- Change the resource name to your App's accent color - or any other color you want -->
  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
              android:resource="@android:color/white"/>
  <receiver
       android:name="com.google.android.gms.gcm.GcmReceiver"
       android:exported="true"
       android:permission="com.google.android.c2dm.permission.SEND">
       <intent-filter>
           <action android:name="com.google.android.c2dm.intent.RECEIVE" />
           <category android:name="com.qas" />
       </intent-filter>
   </receiver>
   <!-- < Only if you're using GCM or localNotificationSchedule() > -->

   <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
   <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
       <intent-filter>
           <action android:name="android.intent.action.BOOT_COMPLETED" />
       </intent-filter>
   </receiver>
   <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>

   <!-- < Only if you're using GCM or localNotificationSchedule() > -->
   <service
       android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm"
       android:exported="false">
       <intent-filter>
           <action android:name="com.google.android.c2dm.intent.RECEIVE" />
       </intent-filter>
   </service>
   <!-- </ Only if you're using GCM or localNotificationSchedule() > -->

   <!-- < Else > -->
   <!-- <service
       android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
       android:exported="false">
       <intent-filter>
           <action android:name="com.google.firebase.MESSAGING_EVENT" />
       </intent-filter>
   </service> -->

Did i miss something?

Chasing build errors on React Native every time - Solutions?

$
0
0

I have just recently dipped toes in the React Native mobile development on Android (Android Studio, Gradle). As I was setting up the development environment, I got some build error (License agreement missing). Fixed that, wrote down how to fix it. Another member of my team set up his environment, different error (annotation library is missing).

As I learned, everyone who has touched this simply have a different error, specific to their machine, depending on whether it's Tuesday or if they place their coffee mug on the left or the right side of their keyboard.

It's not realistic to be chasing build errors everyday. What's the strategies I can employ to prevent these sort of issues? (package lock down? android version lock down? lock down the SDK version?) Is there a way to lock down the development environment so that a new member can set up their development environment without constant error chasing?

Or is this even realistic with React Native development on Android? Any wisdom is appreciated.

How to solve "libmain.so not found" while using Unity as a library in Android application with latest AndroidX Versions out of ReactNative

$
0
0

We have a ReactNative application that has integrated Unity based on react-native-unity-view successfully as a library for quite a long time. However, after most recent updates on ReactNative regarding AndroidX and latest SDK-changes, we're running into the issue "libmain.so not found". This exception happens on the very first attempt to display a Unity-View.

There is a similar issue on SO, please don't mark as duplicate as our approach might be different and particulary since we give many many more details here.

There is a running and still working example on GitHub (based on ReactNative 0.57): https://github.com/f111fei/react-native-unity-demo. As long as this project is based on ReactNative 0.57 and its appropriate gradle-settings, everything works fine. But as soon as we upgrade to the latest ReactNative version (and even 0.60 for example), which gives us an android-folder that is very different against to the older one), the issue happens with a crash of the application. (We also tried to set up everything from scratch to exclude the possibility that this issue was due to upgrades. With RN 0.57 everything still works fine, with RN 0.60 and above not)

The exception is as follows:

E Unity   : Failed to load 'libmain.so', the application will terminate.
D AndroidRuntime: Shutting down VM
E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: Process: com.rnunitydemo, PID: 16887
E AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/lib/arm64, /data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]] couldn't find "libmain.so"

First I'm going to list the android-folder and gradle-files from most recent version, where the crash happens. After that, I will list the files where everything works fine:

Not working (newer) Version

./android/build.gradle:

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")
    }
}

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

        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

./android/settings.gradle:

rootProject.name = 'rnunitydemo'

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

include ":UnityExport"
project(":UnityExport").projectDir = file("./UnityExport")


include ':app'

./android/app/build.gradle:

apply plugin: "com.android.application"

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"

def enableSeparateBuildPerCPUArchitecture = false

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 "com.rnunitydemo"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    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'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            signingConfig signingConfigs.debug
            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 fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules

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

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)

./android/UnityExport/build.gradle:

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

apply plugin: 'com.android.library'


dependencies {
    api fileTree(include: ['*.jar'], dir: 'libs')
}

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.2'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        multiDexEnabled true
        versionCode 1
        versionName '0.1'
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        noCompress = ['.unity3d', '.ress', '.resource', '.obb']
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }

    buildTypes {
        debug {
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
            signingConfig signingConfigs.debug
            jniDebuggable true
        }
        release {
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
            signingConfig signingConfigs.debug
        }
    }

    packagingOptions {
        doNotStrip '*/armeabi-v7a/*.so'
        doNotStrip '*/x86/*.so'
    }


}

All these files above lead to a crash ("libmain.so not found") as soon as Unity will be launched.

Working (older) Version

In our previous version, as it can be found on GitHub, everything went fine:

./android/build.gradle:

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
    }
}

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

task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

./android/settings.gradle:

rootProject.name = 'rnunitydemo'
include ':react-native-unity-view'
project(':react-native-unity-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-unity-view/android')

include ":UnityExport"
project(":UnityExport").projectDir = file("./UnityExport")

include ':app'

./android/app/build.gradle:

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

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

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.rnunitydemo"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    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 {
        debug {
            manifestPlaceholders = [
                "DEBUGGABLE": "true"
            ]
        }
        release {
            manifestPlaceholders = [
                "DEBUGGABLE": "false"
            ]
            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
            }
        }
    }
}

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

// 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/UnityExport/build.gradle:

(same as above)

There are some other reports according to this issue in the official Unity2D-Forums, but without any working solution. According to a comment we are aware of using the very same abiFilter-Setting in both build.gradle-Files (this from our app and the build-gradle from UnityExport), but it didn't solve the issue either.

Can someone help please?

** Update **

System information of development machine:

System:
    OS: macOS Mojave 10.14.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 112.35 MB / 32.00 GB
    Shell: 5.0.11 - /usr/local/bin/bash

  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 25, 26, 27, 28, 29
      Build Tools: 23.0.1, 25.0.0, 25.0.1, 25.0.2, 26.0.1, 27.0.3, 28.0.3, 29.0.0, 29.0.2
      System Images: android-29 | Google APIs Intel x86 Atom
      Android NDK: 20.0.5594570
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
  Binaries:
    Node: 10.17.0 - /usr/local/opt/node@10/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/opt/node@10/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.4 => 0.61.4
  npmGlobalPackages:
    react-native-cli: 2.0.1

How to enable Scrollview in a Component Within a Component

$
0
0

Screenshot Of View

I am trying to add Scrollview in my main screen where i am showing an array of products. As I add a SCROLLVIEW on my screen it does not enable the scroll feature. I have made a View where a component is being rendered each of which having a array of its own.

The Code

Newsfeed.js

import React, {Component} from 'react';
import {View, Text, TouchableOpacity,StyleSheet} from 'react-native';

import Connections from './Components/Connections';
import ClearStock from './Components/ClearStock';
import NewProducts from './Components/NewProducts';
import Discounts from './Components/Discounts';
import CustomButton from './Components/CustomButton';
import { ScrollView } from 'react-native';

// import {ScrollView} from 'react-native';

export default class NewsFeed extends Component {
  state = {
    selected: 'ClearStock',
  };
  buttonClick(name) {
    this.setState({selected: name});
  }
  render() {
    return (
      <View>
        <View style={{flexDirection: 'row',borderWidth:5,backgroundColor:'#ffc687'}}>


          <CustomButton
            style={styles.btnStyle}
            onPress={() => this.buttonClick('ClearStock')}
            iconName="stumbleupon-circle">
           Clear Stock
          </CustomButton>

          <CustomButton
              style={styles.btnStyle}         
            onPress={() => this.buttonClick('Discounts')}
            iconName="home">
            Discounts
          </CustomButton>

          <CustomButton
             style={styles.btnStyle}         
            onPress={() => this.buttonClick('NewProducts')}
            iconName="free-code-camp">
            New Products
          </CustomButton>

          <CustomButton
             style={styles.btnStyle}           
            onPress={() => this.buttonClick('Connections')}
            iconName="home">
            Connections
          </CustomButton>

        </View>

        <View>
          {this.state.selected === 'ClearStock' ? (
            <ClearStock />
          ) : this.state.selected === 'Discounts' ? (
            <Discounts />
          ) : this.state.selected === 'NewProducts' ? (
            <NewProducts />
          ) : (
            <Connections />
          )}
       </View>

      </View>
    );
  }
}
styles=StyleSheet.create({
  btnStyle:{
    marginLeft:40,
    // backgroundColor:'red',
    borderRadius:10,

  }
});

CustomCard.js

import React, { Component } from 'react';
import {ImageBackground, View, TouchableOpacity, StyleSheet, Image, Text, ScrollView } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';


export default class CustomCard extends Component {

    state = {
        product: [

            {
                name: "Mug",
                quantity: 2,
                price: 199,
                category: "Kitchen ware",
                tags: ["mug", "kitchen", "utensils"],
                color: "White",
                imageUrl: "https://images-na.ssl-images-amazon.com/images/I/61KB6fUhcSL._SL1500_.jpg"

            },
            {
                name: "Samsung A50",
                quantity: 6,
                price: 15000,
                category: "Mobile Phone",
                tags: ["mug", "kitchen", "phone"],
                color: "Black",
                imageUrl: "https://johnlewis.scene7.com/is/image/JohnLewis/238087827?$rsp-pdp-port-1440$"

            },
            {
                name: "Nokia A50",
                quantity: 6,
                price: 15000,
                category: "Mobile Phone",
                tags: ["mug", "kitchen", "phone"],
                color: "Black",
                imageUrl: "https://assets.mspimages.in/wp-content/uploads/2019/03/Nokia-X71-696x435.jpg"

            },
            {
                name: "QMobile A50",
                quantity: 6,
                price: 15000,
                category: "Mobile Phone",
                tags: ["mug", "kitchen", "phone"],
                color: "Black",
                imageUrl: "https://www.whatmobile.com.pk/admin/images/Qmobile/NoirJ5b.jpg"

            },

        ]

    }
    render() {

        const { name, quantity, price, category, tags, color, imageUrl } = this.props.products;

        return (
            <View >
                <ImageBackground
                    style={styles.productView}
                    source={{ uri: "https://www.akfoconee.com/wp-content/uploads/2017/12/kids-martial-arts-landing-page-section-two-background-min-min.png" }}
                >

                    <View style={{ flexDirection: 'row' }}>
                        <Icon name="bullhorn" size={30} />
                        <View style={{ marginLeft: 30, padding: 10, height: "100%", borderRadius: 30, borderWidth: 1, borderColor: "orange", width: "30%" }}>
                            <Image style={{ marginLeft: 10, height: "100%", width: 100, resizeMode: "contain" }} source={{ uri: imageUrl }} />


                        </View>

                        <View style={{ padding: 1, marginLeft: 10 }}>


                            <Text> We are offering FLASH SALE</Text>
                            <Text style={styles.itemDescription}>{name}</Text>
                            <Text style={styles.itemDescription}>{quantity}</Text>
                            <Text style={styles.itemDescription}> original price RS {price}</Text>
                            <Text style={styles.itemDescription}> price for 100 products RS {price}</Text>

                        </View>



                    </View>
                </ImageBackground>
            </View>

        )
    }
}

const styles = StyleSheet.create({
    itemDescription: {
        fontSize: 15,
        color: "black",
    },
    productView: {
        // borderRadius:30,
        // backgroundColor:"red",
        elevation: 2,
        paddingTop: 15,
        paddingBottom: 15,
        paddingLeft: 15,
        paddingRight: 15,
        height: 150,
        width: "100%",
        marginLeft: 15,
        // marginRight: 20,
        marginTop: 10,
        // borderWidth: 0.14,
        // borderRadius:10
        // marginBottom:50,
        // borderColor:"black"
    }
})

ClearStock.js

import React, {Component} from 'react';
import {View, Text, TouchableOpacity} from 'react-native';
import CustomCard from './CustomCard';
import { ScrollView } from 'react-native';
export default class ClearStock extends Component {
  state = {
    product: [

        {
            name: "Mug",
            quantity: 2,
            price: 199,
            category: "Kitchen ware",
            tags: ["mug", "kitchen", "utensils"],
            color: "White",
            imageUrl: "https://images-na.ssl-images-amazon.com/images/I/61KB6fUhcSL._SL1500_.jpg"

        },
        {
            name: "Samsung A50",
            quantity: 6,
            price: 15000,
            category: "Mobile Phone",
            tags: ["mug", "kitchen", "phone"],
            color: "Black",
            imageUrl: "https://johnlewis.scene7.com/is/image/JohnLewis/238087827?$rsp-pdp-port-1440$"

        },
        {
            name: "Nokia A50",
            quantity: 6,
            price: 15000,
            category: "Mobile Phone",
            tags: ["mug", "kitchen", "phone"],
            color: "Black",
            imageUrl: "https://assets.mspimages.in/wp-content/uploads/2019/03/Nokia-X71-696x435.jpg"

        },
        {
            name: "QMobile A50",
            quantity: 6,
            price: 15000,
            category: "Mobile Phone",
            tags: ["mug", "kitchen", "phone"],
            color: "Black",
            imageUrl: "https://www.whatmobile.com.pk/admin/images/Qmobile/NoirJ5b.jpg"

        },

    ]

}
  render() {
    return (
      <View>
        <Text>About Clearing Stock</Text>
           {
              this.state.product.map((data,index) => {
                return( 
                  <CustomCard products={data} key={index}></CustomCard>
                    // <Text>Hello</Text>
                  )
              })
            }


      </View>
    );
  }
}

How restart android app after unlock screen

$
0
0

I have a react native app that use paho mqtt (react native module) the problem is that when the screen is lock, this service die. Im not android developer but I read that the problem is that doze mode kill all and my paho service die after a few minutes.

I read this issue https://github.com/eclipse/paho.mqtt.android/issues/226 and test a solution given there but in android > 8 this solution not work anymore.

I think 2 possible solutions:

1. Run service again after unlock the screen (dunno how to do this for
android >8).
2. Restart the app after unlock the screen (Searching for how detect that the screen is unlock in react native).

If someone know how to handle this solutions or another one.


React Native Duplicate class com.google.android.gms.measurement.internal.zzhw

$
0
0

I just did few changes in JS side of my project without updating any packages or something but now I get these errors..

Task :app:checkReleaseDuplicateClasses FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkReleaseDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.measurement.zzbv found in modules classes.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.1)
  Duplicate class com.google.android.gms.internal.measurement.zzbw found in modules classes.jar (com.google.android.gms:play-services-measurement-base:17.1.0) and classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.1)

..... continues

So probably some packages are making this conflict which use google play services, so here is my package.json.

{
  "name": "xx",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.6.1",
    "@react-native-firebase/app": "^0.2.3",
    "@react-native-firebase/database": "^0.2.3",
    "axios": "^0.19.0",
    "immutable": "^4.0.0-rc.12",
    "react": "16.8.6",
    "react-native": "0.60.4",
    "react-native-admob": "^2.0.0-beta.6",
    "react-native-device-info": "^2.3.2",
    "react-native-gesture-handler": "^1.3.0",
    "react-native-iap": "^3.3.7",
    "react-native-image-picker": "^1.0.2",
    "react-native-indicators": "^0.13.0",
    "react-native-onesignal": "^3.5.0",
    "react-native-progress": "^3.6.0",
    "react-native-sound": "^0.11.0",
    "react-native-swiper": "^1.5.14",
    "react-navigation": "^3.11.1",
    "react-redux": "^7.1.0",
    "redux": "^4.0.4",
    "redux-logger": "^3.0.6"
  },
  "devDependencies": {
    "@babel/core": "^7.5.5",
    "@babel/runtime": "^7.5.5",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.8.0",
    "eslint": "^6.1.0",
    "jest": "^24.8.0",
    "metro-react-native-babel-preset": "^0.55.0",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|react-navigation)/"
    ],
    "preset": "react-native"
  }
}

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.1")
        classpath 'com.google.gms:google-services:4.2.0'

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

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

        google()
        jcenter()
    }
}

android/app/build.gradle

apply plugin: "com.android.application"

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"

    /**
     * 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

    /**
     * The preferred build flavor of JavaScriptCore.
     *
     * For example, to use the international variant, you can use:
     * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
     *
     * The international variant includes ICU i18n library and necessary data
     * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
     * give correct results when using with locales other than en-US.  Note that
     * this variant is about 6MiB larger per architecture than default.
     */
    def jscFlavor = 'org.webkit:android-jsc:+'

    /**
     * Whether to enable the Hermes VM.
     *
     * This should be set on project.ext.react and mirrored here.  If it is not set
     * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
     * and the benefits of using Hermes will therefore be sharply reduced.
     */
    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 "xx"
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            versionCode 50
            versionName "1.0"
            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_RELEASE_STORE_FILE')) {
                     storeFile file(MYAPP_RELEASE_STORE_FILE)
                     storePassword MYAPP_RELEASE_STORE_PASSWORD
                     keyAlias MYAPP_RELEASE_KEY_ALIAS
                     keyPassword MYAPP_RELEASE_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.
                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:
                // 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
                }

            }
        }

        packagingOptions {
            pickFirst '**/armeabi-v7a/libc++_shared.so'
            pickFirst '**/x86/libc++_shared.so'
            pickFirst '**/arm64-v8a/libc++_shared.so'
            pickFirst '**/x86_64/libc++_shared.so'
            pickFirst '**/x86/libjsc.so'
            pickFirst '**/armeabi-v7a/libjsc.so'
        }
    }

    dependencies {
        implementation fileTree(dir: "libs", include: ["*.jar"])
        implementation "com.facebook.react:react-native:+"  // From node_modules
        implementation 'com.android.support:multidex:1.0.3'

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

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

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

Is there a solution for phones communicating via bluetooth in React Native?

$
0
0

Now I am developing a project in React Native, in which two phones need to communicate with each other via Bluetooth.

I've searched the Internet and found the two most popular libraries for RN Bluetooth:react-native-ble-manager, react-native-ble-plx.

But unfortunately, neither of them can turn phone to peripheral mode, which means two phones can't communicate via Bluetooth using them.

So is there a solution for phones communicating via Bluetooth in React Native?

React Native Deep Linking and fallback to webpage by passing some data

$
0
0

I have a website (implemented with React) and a React-native app to use camera and process some data.

In my scenario, on the website, there is a button to open the camera by deep-linking to my React-native app which I've already done. When the user clicks the button on the website in his/her phone, the react-native app is opened. This part is already implemented.

After taking a photo and processing it in the app, I want a clean fallback to the website with the processed data to represent it on the website.

The first solution that came to my mind is that maybe I could save the processed data to a JSON file in a certain directory on the phone and exit the app using "react-native-exit-app". After exiting the app, the browser will appear again and I can read the JSON file on the website. But I am not sure if it is a good approach.

So In other words, I just want to pass the processed data to website after exiting the app. What would be the best way to do it?

Thanks

How to Play Multiple Audio's in React Native?

$
0
0

I want to play multiple audio files in my React Native application. Currently, it is one audio at a time and i also want single audio to be played at a time. What I want is if one audio is playing and suddenly the user tapped on the second audio button the first one will get paused and second should play. And when the user tapped the first again the paused audio will start again from where it is paused. Similar to whatsapp Audio Messages.

I am using react-native-audio-recorder-player for recording and playing audio in my application. check app design

My FlatList Item Design:

{ { this.toggleMediaPlayer(item.audiourl, index) } }}>

<TouchableOpacity
                                                style={styles.viewBarWrapper}
                                                onPress={this.onStatusPress}
                                            >
                                                <View style={styles.viewBar}>
                                                    <View style={styles.viewBarPlay} />
                                                </View>
                                            </TouchableOpacity>
                                            <Text style={styles.txtCounter}>
                                                {/* {this.state.playTime} / {this.state.duration} */}
                                            </Text>

                                        </View>

MediaPlayer Function:

`toggleMediaPlayer(mediaPath, index) {

    if (this.state.mediaFlag[index] == false) {
        this.onStartPlay(mediaPath, index)

        this.state.mediaFlag[index] = true;
        var cloneObj = Object.assign({}, this.state.mediaFlag);
        this.setState({ mediaFlag: cloneObj });
        console.log(this.state.mediaFlag)

    }
    else {
        this.onPausePlay(mediaPath)
        this.state.mediaFlag[index] = false;
        var cloneObj = Object.assign({}, this.state.mediaFlag);
        this.setState({ mediaFlag: cloneObj });
        console.log(this.state.mediaFlag)
    }
}

`

REST CODE

audioRecorderPlayer = new AudioRecorderPlayer();

async onStartPlay(path, index) {
    console.log('onStartPlay');
    this.audioRecorderPlayer.stopPlayer();
    const msg = await this.audioRecorderPlayer.startPlayer(path);
    console.log(msg);
    this.audioRecorderPlayer.addPlayBackListener(async (e) => {
        if (e.current_position === e.duration) {
            console.log('finished');
            // await this.setState({ mediaFlag: !this.state.mediaFlag });

            this.state.mediaFlag[index] = false;
            var cloneObj = Object.assign({}, this.state.mediaFlag);
            this.setState({ mediaFlag: cloneObj });
            console.log(this.state.mediaFlag)

            this.audioRecorderPlayer.stopPlayer();
            this.audioRecorderPlayer.removePlayBackListener();
        }
        else {
            this.setState({
                currentPositionSec: e.current_position,
                currentDurationSec: e.duration,
                playTime: this.audioRecorderPlayer.mmssss(Math.floor(e.current_position)),
                duration: this.audioRecorderPlayer.mmssss(Math.floor(e.duration)),
            })
        }
        return;
    });
};

onPausePlay = async () => {
    await this.audioRecorderPlayer.pausePlayer();
};

async onStopPlay(index) {
    console.log('onStopPlay');
    this.audioRecorderPlayer.stopPlayer();
    this.audioRecorderPlayer.removePlayBackListener();
};

why do i have to reload the app after change direction from LTR to RTL in react-native?

$
0
0

I use I18nManager.forceRTL(true) in initialState or componentDidMount life cycle but it does't work and if I reload my App, it works.

I mean I have to reload the App to see the effect, what is the reason?

Thanks in advance

Viewing all 28474 articles
Browse latest View live


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