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

'installDebug' not found in root project 'android' React Native

$
0
0

I am trying to run my project on the android simulator. When I run react-native run-android I am getting the following:

FAILURE: Build failed with an exception.* What went wrong: Task 'installDebug' not found in root project 'android'.* 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.BUILD FAILED

If I run ./gradlew tasks I get:

Build Setup tasks-----------------init - Initializes a new Gradle build. [incubating]wrapper - Generates Gradle wrapper files. [incubating]Help tasks----------buildEnvironment - Displays all buildscript dependencies declared in root project 'android'.components - Displays the components produced by root project 'android'. [incubating]dependencies - Displays all dependencies declared in root project 'android'.dependencyInsight - Displays the insight into a specific dependency in root project 'android'.help - Displays a help message.model - Displays the configuration model of root project 'android'. [incubating]projects - Displays the sub-projects of root project 'android'.properties - Displays the properties of root project 'android'.tasks - Displays the tasks runnable from root project 'android'.

Any idea why I don't have a installDebug task in my project? How do I get it back?


Problem with the grandlew in react native

$
0
0

I'm trying to run a project with react native, on my phone and an emulator on my computer, but when I try to run it, it gives me an error, I try a lot of settings, I deleted everything and restarted, but don't go.

the commands I use are 'react-native init mobile' and 'npx react-native run-android'

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.Jetifier found 960 file(s) to forward-jetify. Using 4 workers...info Starting JS server.../bin/sh: 1: /usr/Android/Sdk/platform-tools/adb: not foundinfo Launching emulator...error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.info Installing the app...FAILURE: Build failed with an exception.* What went wrong:Could not open settings remapped class cache for bu0a3j1xsz4iz85rf4a8d6zv6 (/home/rafhael/.gradle/caches/6.0.1/scripts-remapped/settings_512c6m6kiv64e15o075gpnqxu/bu0a3j1xsz4iz85rf4a8d6zv6/settings27b7120d8bed45e60dd0b95b8e5ecea0).> Could not open settings generic class cache for settings file '/home/rafhael/mobile/mobile/android/settings.gradle' (/home/rafhael/.gradle/caches/6.0.1/scripts/bu0a3j1xsz4iz85rf4a8d6zv6/settings/settings27b7120d8bed45e60dd0b95b8e5ecea0).> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' null* 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 710mserror Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081FAILURE: Build failed with an exception.* What went wrong:Could not open settings remapped class cache for bu0a3j1xsz4iz85rf4a8d6zv6 (/home/rafhael/.gradle/caches/6.0.1/scripts-remapped/settings_512c6m6kiv64e15o075gpnqxu/bu0a3j1xsz4iz85rf4a8d6zv6/settings27b7120d8bed45e60dd0b95b8e5ecea0).> Could not open settings generic class cache for settings file '/home/rafhael/mobile/mobile/android/settings.gradle' (/home/rafhael/.gradle/caches/6.0.1/scripts/bu0a3j1xsz4iz85rf4a8d6zv6/settings/settings27b7120d8bed45e60dd0b95b8e5ecea0).> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' null* 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 710ms    at makeError (/home/rafhael/mobile/mobile/node_modules/execa/index.js:174:9)    at /home/rafhael/mobile/mobile/node_modules/execa/index.js:278:16    at processTicksAndRejections (internal/process/task_queues.js:97:5)    at async runOnAllDevices (/home/rafhael/mobile/mobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)    at async Command.handleAction (/home/rafhael/mobile/mobile/node_modules/@react-native-community/cli/build/index.js:186:9)

This is my error, if someone can help me, i'm appreciate.

gradle error in android build react native

$
0
0

[x] submitting bug

[x] Android platform react-native

[x] ubuntu 16.04 LTS

I am having issue in creating build by command react-native run-android

Here i am pasted error:

$ react-native run-android Scanning folders for symlinks in /home/pct3/webroot/Hello/node_modules (39ms) JS server already running. Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

BUILD FAILED in 12s 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

Your help will save my day, if you need any extra information let me know.

Github link: Issue

React Native App crash after dispatch Action

$
0
0

React Native App crash after dispatch Action

This error appears only at the Customer and the Sales Manager in Germany, but I can’t get this error in Belarus, in Belarus work all correctly, it may be due to something like fbt or i18n packages.

Handler on press button:

const openEditScene = useCallback(    () => dispatch(goToTrackedItemScene(trackedItemId)),    [trackedItemId, dispatch],  );

Action:

export const goToTrackedItemScene = createAction<*, string>(  GO_TO_TRACKED_ITEM_SCENE,);export type GoToTrackedItemIdActionType = ActionType<  typeof goToTrackedItemScene,>;

Error from Firebase crashlytics:

Fatal Exception: com.facebook.react.common.JavascriptException: Can't find variable: Crashlytics, stack:<unknown>@1532:368touchableHandlePress@793:2602touchableHandlePress@-1_performSideEffectsForTransition@673:9675_performSideEffectsForTransition@-1_receiveSignal@673:8357_receiveSignal@-1touchableHandleResponderRelease@673:5645touchableHandleResponderRelease@-1E@574:1233z@574:1376U@574:1430D@574:1721H@574:2497forEach@-1j@574:2297<unknown>@574:13831Ue@574:81479Me@574:13499Fe@574:13672receiveTouches@574:14441value@517:3518<unknown>@517:822value@517:2772value@517:794value@-1       at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)       at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)       at java.lang.reflect.Method.invoke(Method.java)       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)       at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)       at android.os.Handler.handleCallback(Handler.java:883)       at android.os.Handler.dispatchMessage(Handler.java:100)       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)       at android.os.Looper.loop(Looper.java:237)       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)       at java.lang.Thread.run(Thread.java:919)

package.json:

{"name": "Synergeto","version": "1.0.1","private": true,"scripts": {"prestart": "bash scripts/i18n.sh manifest","upgrade": "react-native upgrade","android": "react-native run-android","ios": "react-native run-ios","start": "react-native start","pretest": "bash scripts/i18n.sh manifest","test": "jest --passWithNoTests","flow": "flow","postinstall": "rm -rf node_modules/react-redux node_modules/react && git checkout -f -- :/node_modules :/mobile/node_modules","make-i18n": "bash scripts/i18n.sh manifest && bash scripts/i18n.sh collect && bash scripts/i18n.sh translate","postversion": "react-native-version --never-amend"  },"dependencies": {"@react-native-community/async-storage": "^1.5.1","@react-native-community/geolocation": "^2.0.2","@synergeto/core": "^0.0.1","buffer": "^5.2.1","expo-barcode-scanner": "^5.0.1","expo-image-picker": "^5.0.2","expo-localization": "^5.0.1","expo-location": "^5.0.1","expo-secure-store": "^5.0.1","fbt": "0.14.0","formik": "^1.5.8","instabug-reactnative": "^9.1.1","mime": "^2.4.4","ramda": "^0.26.1","react": "^16.8.6","react-native": "^0.60.3","react-native-app-settings": "^2.0.1","react-native-background-timer": "^2.2.0-alpha.0","react-native-bottom-action-sheet": "prscX/react-native-bottom-action-sheet","react-native-navigation": "^3.0.0-alpha.2","react-native-unimodules": "^0.4.2","react-native-webview": "^6.3.1","react-redux": "^7.1.0","redux": "^4.0.4","redux-actions": "^2.6.5","redux-saga": "^1.0.5","sort-by-distance": "^1.1.0","whatwg-url": "^7.0.0","yup": "^0.27.0"  },"devDependencies": {"@babel/core": "^7.5.5","@babel/register": "^7.5.5","@babel/runtime": "^7.5.5","@synergeto/eslint-config": "1.0.0","babel-eslint": "^10.0.2","babel-jest": "^24.8.0","babel-plugin-fbt": "^0.9.1","babel-plugin-fbt-runtime": "^0.9.1","babel-plugin-transform-inline-environment-variables": "^0.4.3","dotenv": "^8.0.0","dotenv-expand": "^5.1.0","enzyme": "^3.10.0","enzyme-adapter-react-16": "^1.14.0","flow-bin": "^0.103.0","jest": "^24.8.0","metro-react-native-babel-preset": "^0.55.0","react-native-version": "^3.1.0"  },"workspaces": {"nohoist": ["**/@react-native-community/async-storage","**/@react-native-community/async-storage/**","**/expo-barcode-scanner","**/expo-barcode-scanner/**","**/expo-image-picker","**/expo-image-picker/**","**/expo-localization","**/expo-localization/**","**/expo-location","**/expo-location/**","**/expo-secure-store","**/expo-secure-store/**","**/formik","**/formik/**","**/react-native","**/react-native/**","**/react-native-app-settings","**/react-native-app-settings/**","**/react-native-background-timer","**/react-native-background-timer/**","**/react-native-bottom-action-sheet","**/react-native-bottom-action-sheet/**","**/react-native-navigation","**/react-native-navigation/**","**/react-native-unimodules","**/react-native-unimodules/**","**/react-native-webview","**/react-native-webview/**"    ]  }}

Could not determine the dependencies of task ':app:mergeDebugAssets'

$
0
0

When I run react-native run-android on my project,I get an build error of gradle. I already uninstalled react-native-ftp with npm uninstall --save react-native-ftp, removed that dependency of node_modules, clear ./gradle cached files. But the error continuous..

In my environment windows this project works normally.

What's happing?

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081FAILURE: Build failed with an exception.* What went wrong:Could not determine the dependencies of task ':app:mergeDebugAssets'.> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.> Could not resolve project :react-native-ftp.     Required by:         project :app> Unable to find a matching configuration of project :react-native-ftp:          - None of the consumable configurations have attributes.* 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 2s    at makeError (/home/leroto/leroto-workspace/svm/frontend/node_modules/execa/index.js:174:9)    at /home/leroto/leroto-workspace/svm/frontend/node_modules/execa/index.js:278:16    at processTicksAndRejections (internal/process/task_queues.js:97:5)    at async runOnAllDevices (/home/leroto/leroto-workspace/svm/frontend/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)    at async Command.handleAction (/home/leroto/leroto-workspace/svm/frontend/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)

React Native: I am getting error while trying to get image from cloud firestore

$
0
0

I am getting source.uri should not be an empty string. How can i solve this?

I am using google cloud firestore to store all the images there and render it in my app, then this error shows up and i have no idea how to fix it, please help me solve this.

Here is my code:

import React from 'react';import {  TouchableOpacity,  Image,  View,  Text} from 'react-native';import storage from '@react-native-firebase/storage';import styles from '../styles/Android.style';class Catalog extends React.Component {  constructor(props) {    super(props)    this.state = {      image : ''    }  }  retrieveImages = async () => {    const url = await storage()      .ref('/catalogs/web_hi_res_512.png')      .getDownloadURL();    this.setState({image : url})  }  componentDidMount() {    this.retrieveImages()  }  render() {    return (<View style={styles.homeContainer}><TouchableOpacity style={styles.catalogItem}><View><Image            source={{uri: this.state.image}}            style={styles.catalogImage}          /></View><View style={styles.descriptionContainer}><Text style={styles.descriptionPrice}>Ini teks</Text><Text style={styles.descriptionAddress}>Ini deskripsi</Text></View></TouchableOpacity></View>    );  }}export default Catalog;

react native scrollview not scrolling on android

$
0
0

I have the following component:

export default class StoreComponent extends Component {  render() {    return (<View style={styles.container}><ScrollView contentContainerStyle={styles.scroll}><StoreCarouselComponent /><StoreDiscountComponent /><StoreDetailsComponent /></ScrollView></View>    );  }}

with this style

import { StyleSheet, Dimensions, } from 'react-native';const styles = StyleSheet.create({  container: {    flex: 1,    backgroundColor: '#ffffff',  },  scroll: {    flex: 1,    flexDirection: 'row',    justifyContent: 'center'  },  image: {    width: Dimensions.get('window').width,    height: 350,  },  box: {    width: Dimensions.get('window').width - 30,    position: 'absolute',    shadowColor: '#000000',    shadowOpacity: 0.34,    shadowRadius: 5,    shadowOffset: {      width: 0,      height: 10    },    elevation: 10,    borderTopLeftRadius: 10,    borderTopRightRadius: 10,    borderBottomLeftRadius: 10,    borderBottomRightRadius: 10,    borderColor: 'lightgrey',    backgroundColor: '#ffffff',    padding: 10,    marginTop: 410,  },  boxDiscount: {    width: Dimensions.get('window').width - 30,    position: 'absolute',    shadowColor: '#000000',    shadowOpacity: 0.34,    shadowRadius: 5,    shadowOffset: {      width: 0,      height: 10    },    elevation: 10,    borderTopLeftRadius: 10,    borderTopRightRadius: 10,    borderBottomLeftRadius: 10,    borderBottomRightRadius: 10,    borderColor: 'lightgrey',    backgroundColor: '#253241',    padding: 10,    marginTop: 320,  },  title: {    fontSize: 30  },  distance: {    fontSize: 20,    color: '#767676'  },  distanceElement: {    fontSize: 20,    color: '#44D9E6'  },  address: {    fontSize: 20,    color: '#767676'  },  category: {    fontSize: 20,    color: '#767676',  },  categoryElement: {    fontSize: 20,    color: '#44D9E6',  },  hr: {    borderBottomColor: 'lightgrey',    borderBottomWidth: 1,  },  icons: {    flex: 1,    flexDirection: 'row',    justifyContent: 'center',  }});export default styles;

my scrollview works on ios but on android don't and I don't understand why

here a an image of the app and as you can see I need to scroll on android:

enter image description here

React Native (android) - Download file

$
0
0

Need to download a pdf file when user clicks download button in my android app.

I have base64 string of my pdf, file name available, which I fetched from api.

Now how do I download this pdf ?

Read that we can use RN Fetch Blob, so I tried below code,

let pdfLocation = dirs.DocumentDir +'/'+ fileName +'.pdf';console.log("writing file to - "+ pdfLocation);RNFetchBlob.fs.writeFile(pdfLocation, base64PDFString, 'base64').then((res: any) => {  console.log("file written res -"+ res);})

From the console logs, I can see the file is written in the specified location, but if I navigate to that location in my android simulator, I can't see any files stored there.

enter image description here

Am I missing anything here ?


apk file debugging - React Native

$
0
0

I have a React Native App. It works fine in iOS and android.
Hence i have built the bundle for both. ios works fine.
Now my team has created the apk file and when they run it they are getting the below error:

enter image description here

I don't know which part of my code is causing this issue. How can I debug this apk and find out where is the error source?

I have watched a couple of videos on this so I know first I need to decode the apk file.I did that successfully. I have my AndroidManifest.xml (changed to "debuggable:true"), got my Smali files, java files, etc.

Then I opened all that in Android Studio. I placed few breakpoints in my java files. Well it did not stop in any of those BPs LOL!!

Android studio error:

E/unknown:ReactNative: Exception in native call java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String at com.facebook.react.bridge.ReadableNativeArray.getString(Unknown Source:21) at com.facebook.react.bridge.JavaMethodWrapper$5.extractArgument(Unknown Source:0) at com.facebook.react.bridge.JavaMethodWrapper$5.extractArgument(Unknown Source:0) at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:162) at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:23) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0) at android.os.Looper.loop(Looper.java:193) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37) at java.lang.Thread.run(Thread.java:764)

This is so so confusing!! How do I backtrack this error? I can understand my react native javascript errors but this is so confusing. Need some guidance Pleaseee help!!!

Does React Native compile JavaScript into Java for Android?

$
0
0

When I develop hybrid apps with React Native. Does the JavaScript code I write transform into Java-Code or Java-Bytecode for the Dalvik/ART Runtime when I create an Android-App from my React Native code? Or are just the UI components compiled into native UI components? Or does a library like the Fetch API compile the JavaScript code into Java-Code or Java-Bytecode?

Images for Multiple Screen Densities on React Native

$
0
0

React Native Docs told:

You can also use the @2x and @3x suffixes to provide images for different screen densities. If you have the following file structure:

.├── button.js└── img├── check.png├── check@2x.png└── check@3x.png

the bundler will bundle and serve the image corresponding to device's screen density.

And Android App Bundle Docs told,

Google Play then uses the app bundle to generate the various APKs that are served to users, such as the base APK, dynamic feature APKs, configuration APKs, and (for devices that do not support split APKs) multi-APKs. AAB Result

I have multiple images that support different screen densities (img.png, img@2x.png, etc). If I build application in .aab format, did my different-screen-densities-images will be separated and placed on different asset pack based on screen densities?

How to solve this Firebase auth/rejected-credential

$
0
0

This is my code that im doing auth. I've used @react-native-firebase/auth for this. I've downloaded google-services.json file and placed in the android folder.

Now if I run the code and after entering the Phone Number It is throwing error that:

[Error: [auth/rejected-credential] The request contains malformed or mismatching credentials [ App ID does not match requested project. ]]

How to solve this?

handleSendCode = () => {    // Request to send OTP    if (this.validatePhoneNumber()) {      auth()        .signInWithPhoneNumber(this.state.phone)        .then(confirmResult => {          this.setState({ confirmResult })        })        .catch(error => {          alert(error.message)          console.log(error)        })    } else {      alert('Invalid Phone Number')    }  }

Stuck on splash screen on first launch but if we don't kill app and launch app again the app works fine. (react-native) Android

$
0
0

I have upgraded code to react-native 0.59.9 from 0.53.3. I think I may have missed some essential steps and getting launch issues. Please check and help me to make app work fine.

React Native Navigation version: 4.0.6

React Native version: 0.59.9

Platform(s) (iOS, Android, or both?): Android.

Device info: Device and Simulator Both (All Android versions).


MainActivity.java

public class MainActivity extends NavigationActivity {static Backbonebits b;public void addDefaultSplashLayout() {LinearLayout splash = new LinearLayout(this);Drawable splash_screen_bitmap = ContextCompat.getDrawable(getApplicationContext(),R.drawable.splashscreen);splash.setBackground(splash_screen_bitmap);    setContentView(splash);}@overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);MobileAds.initialize(this, new OnInitializationCompleteListener() {@overridepublic void onInitializationComplete(InitializationStatus initializationStatus) {}});b = new Backbonebits(this);}}

MainApplication.java

public class MainApplication extends NavigationApplication {private static CallbackManager mCallbackManager = CallbackManager.Factory.create();protected static CallbackManager getCallbackManager() {    return mCallbackManager;} @Override protected ReactGateway createReactGateway() {     ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {         @Override         protected String getJSMainModuleName() {             return "index";         }     };     return new ReactGateway(this, isDebug(), host); } @Override public boolean isDebug() {     return BuildConfig.DEBUG; }protected List<ReactPackage> getPackages() {  return Arrays.<ReactPackage>asList(        new MainReactPackage(),        new FBSDKPackage(mCallbackManager),  );} @Override public List<ReactPackage> createAdditionalReactPackages() {     return getPackages(); }}

App.js

import React, { Component } from 'react';import {Platform} from 'react-native';import { Navigation } from 'react-native-navigation'import TermsOfUseController from "./app/routes/TermsOfUseController"import Utility from './app/config/Utility';const registerScreen = (name, component, styles) => {component.navigatorStyle = {...defaultNavigatorStyles,...styles};Navigation.registerComponent(name, () => component)}function registerAllScreens() {registerScreen('MyApp.LoginController', LoginController, {})}registerAllScreens();User.loggedInUser((user) => {User.addSignOutListner()var screenName = 'MyApp.LoginController';if (user) {if (user.id != 0 && user.id != undefined) {Utility.isFirstTimeLaunch = truescreenName = 'MyApp.HomeScreenController'; // User Already logged in}else {Utility.isFirstTimeLaunch = truescreenName = 'MyApp.LoginController'; // Not Logged in}}});Navigation.events().registerAppLaunchedListener(() => {Navigation.setRoot({  root: {    stack: {      children: [{        component: {          name: screenName,          passProps: { ...Navigation }        }      }],      options: {        topBar: {          visible: false        },      }    }  }});});});

Push notifications not getting grouped (like Whatsapp)

$
0
0

I am using FCM Cloud Messaging framework to send and receive push messages for both Android and ios. To send messages from my server I call FCM v1 API. I use FCM SDK app in my native app (react native based) to generate device registration token, etc.I am trying to find ways where the push messages show grouped in device system tray like on Whatsapp i.e. messages containing a particular unique id should be grouped under one category e.g. all messages for a particular stock ticker showing under one group, etc.When searching for possible solutions I came across various links such as:

React Native - Android - FCM - Display group notification like What's app also allowing multiple grouped notifications

Group fcm notifications like whatsapp but allowing multiple group notifications

But none of those helped. For example sending "tag" field replaces previous message when new one is received with the same value. Moreover when app is closed none of the message handling functions of native app are executing on the device so I believe this should be purely a server side functionality. On FCM docs page there is no reference to grouping of messages.

https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages

Any suggestions on how to implement this ?

React Native Integrating with existing Android app flash back

$
0
0

I will try my best to expound my question and provide enough information to show the details.At first,paste the error logs(FATAL EXCEPTION: AsyncTask #1java.lang.RuntimeException: An error occured while executing doInBackground()):

FATAL EXCEPTION: AsyncTask #1 java.lang.RuntimeException: An error occured while executing doInBackground()                                                                                          at android.os.AsyncTask$3.done(AsyncTask.java:299)                                                                                          at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)                                                                                          at java.util.concurrent.FutureTask.setException(FutureTask.java:219)                                                                                          at java.util.concurrent.FutureTask.run(FutureTask.java:239)                                                                                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)                                                                                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)                                                                                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)                                                                                          at java.lang.Thread.run(Thread.java:841)                                                                                       Caused by: java.lang.IllegalAccessError: tried to access method android.support.v4.net.ConnectivityManagerCompat.<init>:(Lcom/facebook/react/bridge/ReactApplicationContext;)V from class com.facebook.react.modules.netinfo.NetInfoModule                                                                                          at com.facebook.react.modules.netinfo.NetInfoModule.<init>(NetInfoModule.java:55)                                                                                          at com.facebook.react.shell.MainReactPackage.createNativeModules(MainReactPackage.java:67)                                                                                          at com.facebook.react.ReactInstanceManagerImpl.processPackage(ReactInstanceManagerImpl.java:751)                                                                                          at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:688)                                                                                          at com.facebook.react.ReactInstanceManagerImpl.access$600(ReactInstanceManagerImpl.java:84)                                                                                          at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:177)                                                                                          at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:162)                                                                                          at android.os.AsyncTask$2.call(AsyncTask.java:287)                                                                                          at java.util.concurrent.FutureTask.run(FutureTask.java:234)                                                                                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)                                                                                           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)                                                                                           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)                                                                                           at java.lang.Thread.run(Thread.java:841)

My project structure:

project structrue

android part

android dependencies:

dependencies {    ...    compile 'com.facebook.react:react-native:0.20.0'}

 AndroidManifest.xml:

<application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:supportsRtl="true"        android:theme="@style/AppTheme"><activity android:name=".MainActivity"><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><uses-permission android:name="android.permission.INTERNET"/>

MainActivity.java:

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {    private ReactRootView mReactRootView;    private ReactInstanceManager mReactInstanceManager;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        mReactRootView = new ReactRootView(this);        mReactInstanceManager = ReactInstanceManager.builder()                .setApplication(getApplication())                .setBundleAssetName("index.android.bundle")                .setJSMainModuleName("index.android")                .addPackage(new MainReactPackage())                .setUseDeveloperSupport(BuildConfig.DEBUG)                .setInitialLifecycleState(LifecycleState.RESUMED)                .build();        mReactRootView.startReactApplication(mReactInstanceManager, "AndroidToRn03", null);        setContentView(mReactRootView);    }    ...}

package.json:

{"name": "androidtorn03","version": "1.0.0","description": "","main": "index.android.js","scripts": {"test": "echo \"Error: no test specified\"&& exit 1","start": "node node_modules/react-native/local-cli/cli.js start"  },"author": "","license": "ISC","dependencies": {"react-native": "^0.26.2"  }}

 then, index.android.js:

import React from 'react';import {  AppRegistry,  StyleSheet,  Text,  View} from 'react-native';class AndroidToRn03 extends React.Component {  render() {    return (<View style={styles.container}><Text style={styles.hello}>React Native....</Text></View>    )  }}var styles = StyleSheet.create({  container: {    flex: 1,    justifyContent: 'center',  },  hello: {    fontSize: 20,    textAlign: 'center',    margin: 10,  },});AppRegistry.registerComponent('AndroidToRn03', () => AndroidToRn03);

I have tried many times according to the docs on facebook's website, but all failed and the app flash back at the time of opening. I need your help ! Would you mind taking a while to help me ?


Android app crashes on release build but works in debug build - React-Native

$
0
0

i know this is a common problem but the error i am seeing is different here's the error

06-13 15:37:51.081  1690  3926 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.lawyr/.MainActivity bnds=[849,682][1056,960] (has extras)} from uid 10020 on display 006-13 15:37:51.137  1690  1782 I ActivityManager: Start proc 13071:com.lawyr/u0a88 for activity com.lawyr/.MainActivity06-13 15:37:51.285 13071 13071 D SoLoader: adding application source: com.facebook.soloader.DirectorySoSource[root = /data/app/com.lawyr-1/lib/x86 flags = 0]06-13 15:37:51.290 13071 13071 D SoLoader: adding backup source from : com.facebook.soloader.ApkSoSource[root = /data/data/com.lawyr/lib-main flags = 1]06-13 15:37:51.293 13071 13071 D SoLoader: Preparing SO source: com.facebook.soloader.DirectorySoSource[root = /data/app/com.lawyr-1/lib/x86 flags = 0]06-13 15:37:51.294 13071 13071 D SoLoader: Preparing SO source: com.facebook.soloader.ApkSoSource[root = /data/data/com.lawyr/lib-main flags = 1]06-13 15:37:51.297 13071 13071 V fb-UnpackingSoSource: locked dso store /data/user/0/com.lawyr/lib-main06-13 15:37:51.299 13071 13071 I fb-UnpackingSoSource: dso store is up-to-date: /data/user/0/com.lawyr/lib-main06-13 15:37:51.299 13071 13071 V fb-UnpackingSoSource: releasing dso store lock for /data/user/0/com.lawyr/lib-main06-13 15:37:51.337 13071 13071 E EmbeddedLoader:    at com.lawyr.MainApplication.onCreate(MainApplication.java:86)06-13 15:37:51.338 13071 13071 E AndroidRuntime: Process: com.lawyr, PID: 1307106-13 15:37:51.338 13071 13071 E AndroidRuntime:    at com.lawyr.MainApplication.onCreate(MainApplication.java:86)06-13 15:37:51.340  1690  2045 W ActivityManager:   Force finishing activity com.lawyr/.MainActivity06-13 15:37:51.850  1690  1703 W ActivityManager: Activity pause timeout for ActivityRecord{30dba1e u0 com.lawyr/.MainActivity t51 f}06-13 15:37:51.853  1690  1703 I WindowManager: Failed to capture screenshot of Token{cc192ff ActivityRecord{30dba1e u0 com.lawyr/.MainActivity t51 f}} appWin=Window{ad21564 u0 Starting com.lawyr} drawState=4

i did build release and the app crashes on launch i tried build it with debug and run without error.

Android Studio Custom AVD with similar Hardware Profile has Different Dimensions

$
0
0

The Google Pixel AVD which has a 5" screen and a resolution of 1920x1080 has a width of 411 and a height of 731. I create a new hardware profile with the same screen size and dimensions but this has a width of 360 and a height of 640. I'm calling Dimensions.get('screen') from 'react-native' to get the height and width.

Because of the disparity, the app also scales improperly on my custom hardware profile. What could be the reason for the disparity?

How to get and accumulate my smartphone's notifications in real-time

$
0
0

I want to get my smartphone notifications in real-time and save it at my databaseso that I can see it later.

Is there a way to access notification data?

I am familiar with React-Native. So it would be great if there is a way to solve it with RN.

Android ReactNative java.lang.UnsatisfiedLinkError:could find DSO to load: libreactnativejni.so

$
0
0

I have been trying to add ReactNative to my existing android application. I followed the instructions from this link. I could add it but the app gets crashed once I open the react native activity. I have started server using

adb reverse tcp:8081 tcp:8081

and started react-native using

react-native start

I get a dialogue that the js files are loading. But finally end up with a crash. Following is the error that is being printed in logcat:

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:213)    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:178)    at com.facebook.react.bridge.JSCJavaScriptExecutor.<clinit>(JSCJavaScriptExecutor.java:19)    at com.facebook.react.ReactInstanceManager.onJSBundleLoadedFromServer(ReactInstanceManager.java:413)    at com.facebook.react.ReactInstanceManager.createReactContextInBackground(ReactInstanceManager.java:236)

I am completely lost as I am unable to figure out the cause for this issue.

Thanks in advance.

React Native Android Fetch failing on connection to local API

$
0
0

I'm using the fetch API in my react-native Android app to make requests to a local API. I usually query said API from react web apps at http://localhost:8163.

I'm testing my app on my physical device in debugger mode. I read somewhere that react-native can't query localhost the same way a web app can. Apparently you have to use http://10.0.2.2:[PORT_NUMBER_HERE]/ which is an alias for `http://127.0.0.1:[PORT_NUMBER_HERE] according to the the Android emulator docks. I'm not sure if this is what I'm supposed to be doing for testing on a physical device.

My fetch code looks like the following:

fetchToken() {    fetch('http://10.0.2.2:8163/extension/auth', {        method: 'GET',        headers: {'Accept': 'application/json','Content-type': 'application/json'        }    })    .then((response)) => console.log('successful fetchToken response: ', response.json()))    .catch((error) => console.log('fetchToken error: ', error))    .done();}

The request always hangs for a while and then reaches the catch block with the unhelpful error TypeError: Network request failed(...). Checking the logs for my local API, they don't register the request at all.

So I have no idea if I'm querying my local API correctly to get the resource that I want, and if I am, I don't know why the fetch is failing.

Viewing all 28476 articles
Browse latest View live


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