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

react native mapbox gl - crash on Android

$
0
0

I'm facing this issue, can't find the solution yet.

I'm using @react-native-mapbox-gl/maps for my app.

This is reported from firebase crashlytics.

Fatal Exception: java.lang.NullPointerException Attempt to invoke virtual method 'android.view.ViewGroup com.mapbox.rctmgl.components.mapview.RCTMGLMapView.offscreenAnnotationViewContainer()' on a null object reference com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation.removeFromMap

I can't reproduce too. Here is the code

<S.MapView styleURL={mapboxConfig.styleUrl} compassEnabled={false}><MapboxGL.Camera        defaultSettings={{          zoomLevel: 16,          centerCoordinate: position        }}      /><MapboxGL.PointAnnotation        id='pin'        coordinate={props.coordinate}        anchor={anchor}><IconMarker width='32' height='42' /></MapboxGL.PointAnnotation></S.MapView>

It happen on Android only.

Thanks for your helps.


Error:null is not an object (evaluating '_RNGestureHandlerModule.default.Direction')

$
0
0

I am working on react native project. Code and dependencies files are given below and I am getting the error as Error:null is not an object (evaluating '_RNGestureHandlerModule.default.Direction')

Below file homeStack.js

import { createStackNavigator } from 'react-navigation-stack';import { createAppContainer } from 'react-navigation';import Login from '../src/pages/Login';import ReviewDetails from '../src/pages/reviewDetails';const screens={Login:{  screen: Login },ReviewDetails:{screen: ReviewDetails}}const HomeStack = createStackNavigator(screens);export default createAppContainer(HomeStack);

package.json file:

"dependencies": {"@react-native-community/masked-view": "^0.1.10","@react-navigation/native": "^5.1.6","react": "16.11.0","react-native": "0.62.2","react-native-gesture-handler": "^1.6.1","react-native-reanimated": "^1.8.0","react-native-safe-area-context": "^0.7.3","react-native-screens": "^2.5.0","react-navigation": "^4.3.8","react-navigation-stack": "^2.3.13"

},

react-native run-android Fails MacOS

$
0
0

Complete Console Output is below

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.Jetifier found 967 file(s) to forward-jetify. Using 8 workers...info JS server already running.info Installing the app...FAILURE: Build failed with an exception.* What went wrong:Could not initialize class org.codehaus.groovy.runtime.InvokerHelper* 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 696mserror Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081FAILURE: Build failed with an exception.* What went wrong:Could not initialize class org.codehaus.groovy.runtime.InvokerHelper* 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 696ms    at makeError (/Users/user/Desktop/sa/MyReactApp/node_modules/execa/index.js:174:9)    at /Users/user/Desktop/sa/MyReactApp/node_modules/execa/index.js:278:16    at processTicksAndRejections (internal/process/task_queues.js:97:5)    at async runOnAllDevices (/Users/user/Desktop/sa/MyReactApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)    at async Command.handleAction (/Users/user/Desktop/sa/MyReactApp/node_modules/@react-native-community/cli/build/index.js:186:9)

Bash_profile

export ANDROID_HOME=$HOME/Library/Android/sdkexport PATH=$PATH:$ANDROID_HOME/emulatorexport PATH=$PATH:$ANDROID_HOME/toolsexport PATH=$PATH:$ANDROID_HOME/tools/binexport PATH=$PATH:$ANDROID_HOME/platform-toolsexport ANDROID_SDK_ROOT=$ANDROID_HOMEexport ANDROID_AVD_HOME=$HOME/.android/avdalias emulator='$ANDROID_SDK_ROOT/tools/emulator'

Requested Attachments

  1. Android SDK Link From Android Studio

enter image description here

  1. SDK Tools Installed

enter image description here

  1. npx @react-native-community/cli doctor Result

enter image description here

Installed Android EmulatorNexus 6P (Android R and Pie)

New To React Nativeit works perfectly on iOSbut it fails to launch in Android Simulator

Tried Ways

  1. npm start
  2. npx react-native run-ios
  3. npx react-native run-android

Show AdMob Rewarded Ad multiple times in React Native

$
0
0

I have created a Button to display a rewarded Ad whenever it gets clicked.There are two issues now:1. It takes too much time to load the Ad (I can click the button once or twice before anything happens).2. I want to reload the Ad right after it closes. It works but the App needs to restart.

AdMobRewardedComponent.js

  async componentDidMount() {  await setTestDeviceIDAsync("EMULATOR");  AdMobRewarded.setAdUnitID("ca-app-pub-3940256099942544/5224354917");  AdMobRewarded.addEventListener("rewardedVideoDidLoad", () => {  console.log("VideoLoaded")  });  AdMobRewarded.addEventListener("rewardedVideoDidFailToLoad", () =>  console.log("FailedToLoad")  );  AdMobRewarded.addEventListener("rewardedVideoDidOpen", () =>  console.log("Opened")  );  AdMobRewarded.addEventListener("rewardedVideoDidClose", () => {    loadAd(request.build());  console.log("Closed")  });  AdMobRewarded.addEventListener("rewardedVideoWillLeaveApplication", () =>  console.log("LeaveApp")  );  AdMobRewarded.addEventListener("rewardedVideoDidStart", () =>  console.log("Started")  );  AdMobRewarded.addEventListener("rewardedVideoDidRewardUser", () =>  console.log("Rewarded"),  );  await AdMobRewarded.requestAdAsync();}componentWillUnmount() {  AdMobRewarded.removeAllListeners();}_handlePress = async () => {  await AdMobRewarded.showAdAsync();};render() {  const { loadedAd } = this.state;  return (<TouchableButton onPress={this._handlePress} title="Coins erhalten!" image="adButton" status="active" style={styles.adButton}/>    );  }};

Is there a way to request a new Ad without restarting the whole App?Thanks for every answer!

When i run react native on android im getting this error : ./gradlew app:installDebug -PreactNativeDevServerPort=8081

$
0
0

it is working in ios but come to run in android show this error.

error Failed to install the app. Make sure you have the Android development environment set up:https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong: Task 'installDebug' not found in project ':app'.

  • Try: Run gradlew tasks to get a list of available tasks. 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 4s

at makeError (/Users/sherin/CourierApp/node_modules/execa/index.js:174:9)at /Users/sherin/CourierApp/node_modules/execa/index.js:278:16at processTicksAndRejections (internal/process/task_queues.js:97:5)at async runOnAllDevices (/Users/sherin/CourierApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)at async Command.handleAction (/Users/sherin/CourierApp/node_modules/@react-native-community/cli/build/index.js:186:9)

Large file sending by using react-native-ble-plx

$
0
0

I'm trying to write in a characteristic that sends a binary file as the value, this value is large, it's 19215 bytes which is not a problem because i've divided the file into 240 bytes for each element and each time encode the element to base64 and i use the function writeCharacteristicWithResponseForDevice() in order to write that element,

the issue is i successfully wrote the whole file 19215 bytes using a loop to write each time an element, but while i tried to read the characteristic i can only read the last written element

Example:

           this.manager.writeCharacteristicWithResponseForDevice(device.id,"1111", "40E1ED56-EC4A-4DC6-A6BD-30377F186B77", base64.encode(element1)           this.manager.writeCharacteristicWithResponseForDevice(device.id,"1111", "40E1ED56-EC4A-4DC6-A6BD-30377F186B77", base64.encode(element2))            this.manager.writeCharacteristicWithResponseForDevice(device.id,"1111", "40E1ED56-EC4A-4DC6-A6BD-30377F186B77", base64.encode(element3))

when i read the Characteristic using

          device.readCharacteristicForService("1111", "40E1ED56-EC4A-4DC6-A6BD-30377F186B77")

i get as a value :

        console.log(base64.decode(characteristic.value) => element3

it should be element1+ element2 + element3

-

here is my code for writing :

  WriteIncaracteristic() {   // this.state.fileSize is calculated in another function      const nbPackages = Math.floor(this.state.fileSize/240) + 1      var fileArray = []     for (let i = 0; i <= nbPackages; i++) {      // this.state.fileContent is created in another function      fileArray.push(this.state.fileContent.slice(0, 240))      this.state.fileContent = this.Remove(this.state.fileContent, 0, 240)     }     for (let j = 0; j <= fileArray.length; j++) {       if (fileArray[j]) {       const device = this.state.myDevice           this.manager.writeCharacteristicWithResponseForDevice(device.id,"1111","40E1ED56-EC4A-4DC6-A6BD-30377F186B77", base64.encode(fileArray[j]))            .then((characteristic) => {              console.log(base64.decode(characteristic.value));              return             }) .catch((error) => {              this.createTAlert("writing", error.message  )            });     }}  }

here is the function to read characteristic:

     ReadCaracteristic() {          const device = this.state.myDevice          device.readCharacteristicForService("1111", "40E1ED56-EC4A-4DC6-A6BD-30377F186B77")          .then((characteristic) => {               console.log(base64.decode(characteristic.value));               console.log(characteristic );            return            }) .catch((error) => {               // Handle errors               this.createTAlert("Reading", error.message  )           });

}

Can anybody help please by providing a working example in how to send large package files, because the problem can be while writing, the function erases the older value maybe.

Thanks

Release apk crash when appear Toast

$
0
0

Hello. Talents.How are you?I am developing an app using Expo.Expo SDK 35.And also I am using react-native-root-toast.On expo client app, it is working well.But after releasing apk, app crashes when appear toast.I`d really appreciate if you know the reason or which stable library I can use on Expo.Thank you.

How to send reference android:drawable to a Native Module Android in React Native

$
0
0

I've a big problem with React Native and my android library for React native.

I'm developing a npm package for react native and the specific problem is that I need the next functionality:

1) On react native project the user can be add a new drawable.

2) User need send to the library the reference of the drawable like as R.drawable.my_image ( int )Sample:

//this function must be called from ReactNative in the Javascript App.js fileRNImageLibrary.loadDrawable(R.drawable.my_image).

3) In my library I need to load this Resource.

but I don't know how do this.

Any Idea? Sorry for my english.


java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created

$
0
0

After creating an app in React-Native, I imported a third party component into Android. After the integration of this component, which worked on an Android app, on the app in React-Native it gives me this error:

2020-03-30 10:07:49.005 13979-13979/? E/AndroidRuntime: FATAL EXCEPTION: main    Process: com.smartsign, PID: 13979    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartsign/com.smartsign.MainActivity}: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created        ...     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.react.devsupport.DevSupportManagerImpl" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.smartsign-LPgTscLKBMEXk1VohB6_Lw==/base.apk"],nativeLibraryDirectories=[/data/app/com.smartsign-LPgTscLKBMEXk1VohB6_Lw==/lib/x86, /data/app/com.smartsign-LPgTscLKBMEXk1VohB6_Lw==/base.apk!/lib/x86, /system/lib]]        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)        at java.lang.Class.classForName(Native Method)         at java.lang.Class.forName(Class.java:453)         at java.lang.Class.forName(Class.java:378)         at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:67)         at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:231)         at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:275)         at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:86)         at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:38)         at com.facebook.react.ReactDelegate.loadApp(ReactDelegate.java:103)         at com.facebook.react.ReactActivityDelegate.loadApp(ReactActivityDelegate.java:88)         at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:83)         at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:44)         at android.app.Activity.performCreate(Activity.java:7136)         at android.app.Activity.performCreate(Activity.java:7127)         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)         at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)         at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)         at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)         at android.os.Handler.dispatchMessage(Handler.java:106)         at android.os.Looper.loop(Looper.java:193)         at android.app.ActivityThread.main(ActivityThread.java:6669)         at java.lang.reflect.Method.invoke(Native Method)         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

How can I solve it to start the app that crashes right now when it opens?

Disable download in React native WebView

$
0
0

I am using a React Native WebViw in my app. I want to disable download of files. Mostly just documents. I cant disable storage permissions as certain features in the app need this feature.

react native maps android studio build failure

$
0
0
  • By following below steps I am able to get the react native maps working in ios simulator,
  • but for android I am getting the below issue
Could not determine the dependencies of task ':app:mergeProdReleaseAssets'.> Could not resolve all task dependencies for configuration ':app:prodReleaseRuntimeClasspath'.> Could not find com.google.android.gms:play-services-base:19.1.0.     Searched in the following locations:       - file:/Users/reyu6723huyjh/.m2/repository/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - file:/Users/reyu6723huyjh/.m2/repository/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/react-native/android/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/react-native/android/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/jsc-android/dist/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/jsc-android/dist/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar       - dl.google.com/dl/android/maven2/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - dl.google.com/dl/android/maven2/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar       - jcenter.bintray.com/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - ://jcenter.bintray.com/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar       - ://jitpack.io/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - ://jitpack.io/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar     Required by:         project :app > project :react-native-maps> Could not find com.google.android.gms:play-services-maps:19.1.0.     Searched in the following locations:       - file:/Users/reyu6723huyjh/.m2/repository/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.pom       - file:/Users/reyu6723huyjh/.m2/repository/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.jar       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/react-native/android/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.pom       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/react-native/android/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.jar       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/jsc-android/dist/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.pom       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/jsc-android/dist/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.jar       - //dl.google.com/dl/android/maven2/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.pom       - ://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.jar       - ://jcenter.bintray.com/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.pom       - ://jcenter.bintray.com/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.jar       - ://jitpack.io/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.pom       - ://jitpack.io/com/google/android/gms/play-services-maps/19.1.0/play-services-maps-19.1.0.jar     Required by:         project :app > project :react-native-maps> Could not find com.google.android.gms:play-services-base:19.1.0.     Searched in the following locations:       - file:/Users/reyu6723huyjh/.m2/repository/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - file:/Users/reyu6723huyjh/.m2/repository/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/react-native/android/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/react-native/android/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/jsc-android/dist/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - file:/Users/reyu6723huyjh/Desktop/codebase/star-3/frontendapp/sports/node_modules/jsc-android/dist/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar       - dl.google.com/dl/android/maven2/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - dl.google.com/dl/android/maven2/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar       - jcenter.bintray.com/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - jcenter.bintray.com/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar       - jitpack.io/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.pom       - jitpack.io/com/google/android/gms/play-services-base/19.1.0/play-services-base-19.1.0.jar     Required by:         project :app > project :react-native-geolocation-service > com.google.android.gms:play-services-location:17.0.0
  • when I try to sync with gradle I am getting the below issue

    ERROR: Failed to resolve: com.google.android.gms:play-services-base:19.1.0

Add Google Maven repository and sync projectShow in Project Structure dialogAffected Modules: react-native-maps

-so I googled and found the the below link and in the app build.gradle I used the below configuration, but still same issue.- i even changed react-native-maps node modules build.gradle but still no luck.- can you tell me how to fix it.providing my androidmanifest.xml, build.gradle which is present in app and android folder

build.gradle which is present in app

apply plugin: "com.android.application"import com.android.build.OutputFileproject.ext.react = [    entryFile: "index.js",    enableHermes: false,  // clean and rebuild if changing]project.ext.envConfigFiles = [        dev : ".env",        qa  : ".env.qa",        uat : ".env.uat",        prod: ".env.prod",]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 = true/** * 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 "com.seven.eleven.sports"        resValue "string", "build_config_package", "com.seven.eleven.sports"        minSdkVersion rootProject.ext.minSdkVersion        targetSdkVersion rootProject.ext.targetSdkVersion        versionCode 1        versionName "1.0"        multiDexEnabled true    }    flavorDimensions "default"    productFlavors {        dev {            // Pre-compile run ENVFILE=.env.dev            dimension "default"            applicationIdSuffix ".dev"            versionNameSuffix "-dev"            resValue "string", "app_name", "7-Track_DEV"        }        qa {            // Pre-compile run ENVFILE=.env.dev            dimension "default"            applicationIdSuffix ".qa"            versionNameSuffix "-qa"            resValue "string", "app_name", "7-Track_QA"        }        uat {            // Pre-compile run ENVFILE=.env.dev            dimension "default"            applicationIdSuffix ".uat"            versionNameSuffix "-uat"            resValue "string", "app_name", "7-Track_UAT"        }        prod {            // Pre-compile run ENVFILE=.env.prod            dimension "default"            versionNameSuffix ""            resValue "string", "app_name", "7-Track"        }    }    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             applicationIdSuffix ".dev"             resValue "string", "app_name", "7-Track_DEV"        }        release {            // Caution! In production, you need to generate your own keystore file.            // see facebook.github.io/react-native/docs/signed-apk-android.            signingConfig signingConfigs.debug            shrinkResources enableProguardInReleaseBuilds            zipAlignEnabled enableProguardInReleaseBuilds            minifyEnabled enableProguardInReleaseBuilds            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"            minifyEnabled true        }    }    // 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:            // //developer.android.com/studio/build/configure-apk-splits.html            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]            def abi = output.getFilter(OutputFile.ABI)            if (abi != null) {  // null for the universal-debug, universal-release variants                output.versionCodeOverride =                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode            }        }    }}dependencies {//     implementation(project(':react-native-maps')){//        exclude group: 'com.google.android.gms', module: 'play-services-base'//        exclude group: 'com.google.android.gms', module: 'play-services-maps'//    }//    implementation 'com.google.android.gms:play-services-base:10.0.1'//    implementation 'com.google.android.gms:play-services-maps:10.0.1'    implementation fileTree(dir: "libs", include: ["*.jar"])    implementation "com.facebook.react:react-native:+"  // From node_modules    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'    if (enableHermes) {        def hermesPath = "../../node_modules/hermes-engine/android/";        debugImplementation files(hermesPath +"hermes-debug.aar")        releaseImplementation files(hermesPath +"hermes-release.aar")    } else {        implementation jscFlavor    }}// Run this once to be able to run the application with BUCK// puts all compile dependencies into folder libs for BUCK to usetask copyDownloadableDepsToLibs(type: Copy) {    from configurations.compile    into 'libs'}apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle");applyNativeModulesAppBuildGradle(project)apply from: project(':react-native-config').projectDir.getPath() +"/dotenv.gradle"

build.gradle which is present in android

// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript {    ext {        buildToolsVersion = "28.0.3"        minSdkVersion = 16        compileSdkVersion = 28        targetSdkVersion = 28                playServicesVersion = "19.1.0"    }    repositories {        google()        jcenter()    }    dependencies {        classpath('com.android.tools.build:gradle:3.5.3')        // 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()       maven { url 'jitpack.io' }        //  maven {        //     url 'maven.google.com/'        //     name 'Google'        // }    }}**react-native-maps build.gradle files**
apply plugin: 'com.android.library'if (project.hasProperty('POM_ARTIFACT_ID')) {  apply from: 'gradle-maven-push.gradle'}def safeExtGet(prop, fallback) {  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback}android {  compileSdkVersion safeExtGet('compileSdkVersion', 28)  defaultConfig {    minSdkVersion safeExtGet('minSdkVersion', 16)    targetSdkVersion safeExtGet('targetSdkVersion', 27)  }}dependencies {  def supportLibVersion = safeExtGet('supportLibVersion', '28.0.0')  def supportLibMajorVersion = supportLibVersion.split('\\.')[0] as int  def appCompatLibName =  (supportLibMajorVersion < 20) ? "androidx.appcompat:appcompat" : "com.android.support:appcompat-v7"  implementation "$appCompatLibName:$supportLibVersion"  implementation('com.facebook.react:react-native:+') {    exclude group: 'com.android.support'  }  implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '17.0.0')}"  implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '17.0.0')}"  implementation "com.google.android.gms:play-services-location:17.0.0"  implementation 'com.google.maps.android:android-maps-utils:0.5'}

package.json

{"name": "sports","version": "0.0.1","private": true,"scripts": {"ios": "react-native run-ios","start": "react-native start","android-clean": "echo 'CLEANING ...'&& cd android/ && ./gradlew clean && cd ..","android-build-all": "build_scripts/start_build_android.sh","android": "react-native run-android --variant=devDebug --appIdSuffix=dev","android-prod": "react-native run-android --variant=prodRelease","android-qa": "react-native run-android --variant=qaRelease --appIdSuffix=qa","android-uat": "react-native run-android --variant=uatRelease --appIdSuffix=uat","ios-dev": "react-native run-ios --scheme sports","ios-qa": "react-native run-ios --scheme sportsQA","ios-uat": "react-native run-ios --scheme sportsUAT ","ios-prod": "react-native run-ios --scheme sportsPROD","test": "jest","lint": "eslint . --ext .js,.jsx,.ts,.tsx"    },"dependencies": {"@react-native-community/async-storage": "^1.8.1","@react-native-community/masked-view": "^0.1.6","@react-navigation/bottom-tabs": "^5.0.7","@react-navigation/drawer": "^5.0.7","@react-navigation/native": "^5.0.7","@react-navigation/stack": "^5.0.8","axios": "^0.19.2","axios-retry": "^3.1.2","haversine": "^1.1.1","immutable": "^4.0.0-rc.12","jwt-decode": "^2.2.0","moment": "^2.24.0","react": "16.9.0","react-devtools": "^4.4.0","react-jwt-store": "^1.7.0","react-native": "0.61.5","react-native-check-box": "^2.1.7","react-native-config": "^0.12.0","react-native-elements": "^1.2.7","react-native-geolocation-service": "^4.0.0","react-native-gesture-handler": "^1.6.1","react-native-keyboard-aware-scroll-view": "^0.9.1","react-native-lazyload": "^1.1.0","react-native-maps": "0.27.1","react-native-orientation-loading-overlay": "^0.1.6","react-native-picker-select": "^6.6.0","react-native-ratings": "^6.5.0","react-native-reanimated": "^1.7.0","react-native-safe-area-context": "^0.7.3","react-native-screens": "^2.2.0","react-native-scrolling-menu": "^0.1.1","react-native-sendgrid": "^1.0.1","react-native-sha256": "^1.3.6","react-native-splash-screen": "^3.2.0","react-native-table-component": "^1.2.1","react-native-vector-icons": "^6.6.0","react-native-webview-leaflet": "^5.0.2","react-navigation": "^4.2.1","react-navigation-stack": "^1.10.3","react-redux": "^7.2.0","react-swipeable-views-native": "^0.13.2","react-use": "^13.27.1","redux": "^4.0.5","redux-devtools-extension": "^2.13.8","redux-persist": "^6.0.0","redux-persist-transform-immutable": "^5.0.0","redux-saga": "^1.1.3","redux-saga-jwt": "^1.0.4-beta.0","redux-thunk": "^2.3.0","toggle-switch-react-native": "^2.1.0"    },"devDependencies": {"@babel/core": "^7.9.0","@babel/preset-env": "^7.9.0","@babel/runtime": "^7.8.4","@react-native-community/eslint-config": "^0.0.5","@types/jest": "^24.0.24","@types/react-native": "^0.60.25","@types/react-test-renderer": "16.9.1","@typescript-eslint/eslint-plugin": "^2.12.0","@typescript-eslint/parser": "^2.12.0","babel-core": "^6.26.3","babel-jest": "^25.1.0","babel-preset-env": "^1.7.0","eslint": "^5.16.0","jest": "^25.1.0","metro-react-native-babel-preset": "^0.56.0","react-native-obfuscating-transformer": "^1.0.0","react-test-renderer": "16.9.0","remote-redux-devtools": "^0.5.16","typescript": "^3.7.3"    },"jest": {"preset": "react-native","moduleFileExtensions": ["ts","tsx","js","jsx","json","node"        ]    }}

androidmanifest.xml,

<manifest xmlns:android="http://schemas.android.com/apk/res/android"  package="com.seven.eleven.sports"><uses-permission android:name="android.permission.INTERNET" /><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"><!-- You will only need to add this meta-data tag, but make sure it's a child of application --><meta-data     android:name="com.google.android.geo.API_KEY"     android:value=""/><!-- You will also only need to add this uses-libray tag --><uses-library android:name="org.apache.http.legacy" android:required="false"/><activity        android:name=".MainActivity"        android:label="@string/app_name"        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"        android:windowSoftInputMode="adjustResize"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /></application></manifest>

Show Interstitial Ad after splash screen in react native

$
0
0

I am developing an application in react native one of the requirements of the application in showing an interstitial ad when starting the application before it loads any component, this due to the policies of admob google, otherwise it brings penalties in the ads.

I've been trying in several ways first to put a in componentDidMount and in the constructor the react-native-admob code for interstitial, however the ad likewise takes time to load causing the component (screen) to load completely , which should not be allowed until the ad loads and closes.

Should the ad be added natively (native code for android) or is there any other way to place that ad

Running Expo/React Native in Android Device

$
0
0

I have an React Native app developed with Expo, while scanning the QR code works perfectly, when i try to run the app in a connected usb debug succesfully enabled android device with expo start --localhost --android it doesn't launch the app in the device, although it appears everything is ok:

Successfully ran adb reverse. Localhost URLs should work on the connected Android device.

Thanks it advance.

Execution failed for task ':react-native-admob:compileDebugJavaWithJavac

$
0
0

I can't run the app after installing react-native-admob. Any help would be appreciated. Thanks guys.

Is it possible to build an Android SDK and iOS SDK using React Native?

$
0
0

In my company we are building Android SDKs and iOS SDKs. The reason why we are building SDKs is because we don't want to give away our code and methods to ours customers, we just want to hide how we connect to some services.

So i would like to know if is it possible to build an Android SDK and iOS SDK using React Native?, in the end you have to compile the code in order to create Android and iOS versions.

Thanks!


How to keep react-native app as LTR (right to left)

$
0
0

I have created a simple chat application with react-native, it looks very nice when the device language is left to right, but on devices with RTL (right to left) Language it looks very bad and layout is not responsive.

So how Can I forcefully keep it as LTR(left to right) even on devices with RTL languages like persian, arabic, dari, pashto, urdo.

drawerLockMode : 'locked-closed' not working directly with createStackNavigator

$
0
0

When I specify drawerLockMode direactly with createStackNavigator it is not working.

const drawerStack = createStackNavigator({  HomeScreen: { screen: HomeScreen },}, {  headerMode: 'screen',  navigationOptions: {    drawerLockMode:'locked-closed'  }})

But when I use drawerStack variable to define navigationOptions, it is working.

drawerStack.navigationOptions = ({ navigation }) => {    drawerLockMode = 'locked-closed';    return {       drawerLockMode,    };};

Am I doing any mistake when I am directly using it inside createStackNavigator?

Update

As @bennygenel suggested, we need to user drawerLockMode in drawerNavigator instead of stackNavigator. Here is what i have done.

const drawerNavigator = createDrawerNavigator({    drawerStack: drawerStack}, {    contentComponent: DrawerComponent,    navigationOpions:{       drawerLockMode:'locked-closed'    }})

But it is not working in this way also. The only way it is working is by using the const variable created using createStackNavigator or createDrawerNavigator

How to set android push notification color and icon?

$
0
0

I am using react-native, amplify, and pinpoint.

I have followed several guides and stack overflow questions to set the android default color and icon for push notifications like this:

<meta-data    android:name="com.google.firebase.messaging.default_notification_icon"    android:resource="@drawable/ic_notification" /><meta-data    android:name="com.google.firebase.messaging.default_notification_color"    android:resource="@color/patch_coral" />

I have a file colors.xml inside of android/app/src/main/res/values/ with this content:

<resources><color name="patch_coral">#E97A6E</color></resources>

And for the icon I have drawable folders inside of android/app/src/main/res/ which contain the ic_notification.png generated in android asset studio as white icons as was instructed in several places.

I have also tested with debug and release builds to see if that would change anything; however, the push notifications still do not have the default icon or color, but it does have the app icon on the right side. Here is an example:

current android push notification example

What needs to be changed or added to get the color and icon to replace the default android color, and square icon?

Any Drag & Drop app front-end creator with code [closed]

$
0
0

I am a Laravel backend developer and just finished creating the API for my App. I have no knowledge about front-end designing.

I Just want to ask that is there any service or software where I can design the front-end (UI etc) of my app and it throws me the code? So I can integrate my API with that.Any paid/free service like that? Thanks

React Native app crashing when visiting specific screen

$
0
0

This screen works fine when testing using Expo, but crashes the app when it is bundled to apk

I'm not sure whats causing the crash here, but it works on Expo.This has been tested on both emulators and real android devices, which have the same behavior.

This is the error log from the device when visiting the screen:

04-22 10:14:11.713  7008  7008 E unknown:ReactNative: Tried to remove non-existent frame callback04-22 10:14:11.778  1731  7439 E ResolverController: No valid NAT64 prefix (101, <unspecified>/0)04-22 10:14:11.786  7008  7065 E GraphResponse: {HttpStatus: 400, errorCode: 100, subErrorCode: 33, errorType: GraphMethodException, errorMessage: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api}04-22 10:14:11.963  7008  7008 E c       : java.lang.RuntimeException: A TaskDescription's primary color should be opaque04-22 10:14:11.963  7008  7008 E CrashlyticsCore: Crashlytics must be initialized by calling Fabric.with(Context) prior to logging exceptions.04-22 10:14:12.023  1731  7449 E ResolverController: No valid NAT64 prefix (101, <unspecified>/0

And this is the respective screen:

import React, { Component } from 'react'import { View } from 'react-native'import MapView from 'react-native-maps'import { Appbar } from 'react-native-paper'import Database from './components/Database'const db = new Database()import styles from './components/allStyles'export default class MapScreen extends Component {  state = {    emergencies: [],  };  componentDidMount() {    db.mapOn(emergencies => {        this.setState(previousState => ({            emergencies: previousState.emergencies.concat(emergencies),        }))    })  }  render() {    k = 0    return (<View style={styles.absoluteFillView}><MapView          style={styles.absoluteFillView}          mapType={"satellite"}          showsUserLocation={true}          region={{            latitude: 39.625083,            longitude:  -79.956796,            latitudeDelta: 0.0025,            longitudeDelta: 0.0025,          }}>          {this.state.emergencies.map(emergency => {            if(k + 1 == this.state.emergencies.length){              color = 'red';            }            else {              color = 'orange';            }            return (<MapView.Marker                 key = {k++}                title={emergency.title}                description={emergency.description}                coordinate={{                  latitude: emergency.latitude,                  longitude: emergency.longitude,                }}                pinColor={color}              />            );          })}</MapView><Appbar.Header          dark = {true}          style={{backgroundColor:'#bdbdbd'}}><Appbar.Action           icon = 'arrow-left'          size = {24}            onPress={() =>{              this.props.navigation.navigate('Home')            }}        /></Appbar.Header></View>    );  }  componentWillUnmount(){    db.mapOff()  }}

Here are the event listener functions used in the componentDidMount() and componenWillUnmount():

mapOn = callback => {    firebase.database().ref('alerts/emergency/').on('child_added', snapshot => {        callback(this.edit(snapshot))    })}mapOff = () => {    firebase.database().ref('alerts/emergency/').off()}edit = snapshot => {    const { name, description } = snapshot.val()    const { longitude, latitude } = snapshot.val().location    const emergency = { title: name, description, longitude, latitude}    return emergency}Any help into what may be causing the issue would be very helpful.
Viewing all 28480 articles
Browse latest View live


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