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

Possible Unhandled Promise Rejection (id:0) Error: network error in react native

$
0
0

Possible Unhandled Promise Rejection (id:0) Error: network error in react native

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

   class AlbumList extends Component {
    state = {albums: []};  
   componentWillMount() {
    axios.get('https://rallycoding.herokuapp.com/api/music_albums')
    .then(response=>this.setState({albums: response.data}));
}
renderAlbums() {
return this.state.albums.map(album => <Text>{album.title}</Text>);
}    

render() {
    console.log(this.state);
return(
<View>
  {this.renderAlbums()}
</View>
);
}
};

export default AlbumList;

// I can't load my data from the given link, also in debugging mode there's only //one state created which has empty values and no other data can be visible in //console so help me in fetching the data

Here is screenshot of error I'm getting

enter image description here


Android auto change riyal symbol in React Native

$
0
0

I am trying to render riyal symbol in my react native project (saudi arabia currency). What i am dong is: <Text>﷼</Text> And the symbol that i expect it will render on my app is: Riyal symbol

On IOS it renders exactly like what i expected but on Android it renders other currency which is like the following image: enter image description here

React Native: error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found

$
0
0

I am trying to get Facebook Login for my React Native Android project and when I try to build it with react-native run-android I am getting this error.

I thought at first it was an issue with my Gradle version as React Native comes with Gradle 2.14 installed and I since upgraded to Gradle 4.4.

I went back through the Facebook installation guide multiple times and I am still getting this error. I also triple checked my code to make sure I am not using any bad font/fontWeight/fontStyle. The only thing I can think of is the Facebook button that comes from the standard component has unsupported styles in there? I am not sure.

Any help would be greatly appreciated. I've been at this longer than I want to admit!

MainActivity.java file

package com.myproj;

import android.content.Intent;
import com.facebook.react.ReactActivity;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.FacebookSdk;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "myproj";
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
    }
}

MainApplication.java file

package com.myproj;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;





import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

   private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

   protected static CallbackManager getCallbackManager() {
     return mCallbackManager;
   }

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }


    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new FBSDKPackage(mCallbackManager)
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    AppEventsLogger.activateApp(this);

  }

}

myProj/android/build.gradle file

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



buildscript {
    repositories {
        jcenter()


    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'

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

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

    }
}

ERRORS I am getting:

> Configure project :app 
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018

> Configure project :react-native-fbsdk 
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018
WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values-v26/values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values-v26/values-v26.xml:13:5-16:13: AAPT: error: resource android:attr/colorError not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values-v26/values-v26.xml:17:5-93: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/fontStyle not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/font not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/fontWeight not found.

error: failed linking references.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to process resources, see aapt output above for details.

Total side confusion as well - Facebook tells you in the RN set up guides to target SDK 23 or 6.0 But then the target SDK inside the node_modules folder for react-native-fbsdk is higher thus giving me the warnings

react-native how to detect current installed app ABI?

$
0
0

I have an update function,and i found if already installed arm64-v8a variant then it can't update use armeabi-v7a variant apk.So I need a way to detect.

Moving Node, Android and others away from user and appdata

$
0
0

Hi guys I have a very important question.

I am developing with React / React Native / NodeJS / JavaScript... and I have files that are saved on my computer that need to be there for the programms to run.

I am talking about the user-folder and user%appdata%-folder structure. I noticed that I have millions of files and folders that get autogenerated laying in there. Now the problem is that I need them to be just on my C:/ drive - they cant be in my user folder.

If I click on User Folder files like: .android, .AndroidStudio3.2, .expo, .node-gyp, .react-native-cli

and in the AppData Folder files like: roaming/npm and npm-cache and others

all of these files need to be on my C drive and not in user. I want to reinstall everything on my pc so when I install Node and AndroidStudio and Expo ... I will take a folder in my C drive.

  1. The thing is is it even possible to tell all of the programms where to install and where to generate files?

  2. Do some files need to be in the user folder to work properly? I think I read it somewhere that node or npm should be there because otherwise you will need admin right for everything or something like this.

  3. Even when I tell Node and Android Studio to be on C:// Drive I have the presumption that they will still generate all files I dont want into user folder and appdata folder.

  4. Will my projects that I am developing with RN break after I change the paths?

  5. Do I have to adjust all Paths in Enviroment Variables?

If anyone knows something please let me know.

Slow performance after switching to HEREMap premium SDK

$
0
0

I am facing performance issues with HEREMap Premium Android SDK in my react-native project. Previously I was using free version of HEREMap, and my map view was performing very well. But once I switched to Premium SDK, view rendering became very slow.

Following were the only changes I did for premium SDK integration,

  1. Invoke setIsolatedDiskCacheRootPath api before MapEngine.getInstance().init
  2. Update licence key information in app/src/main/AndroidManifest.xml

Am I missing something? please help.

React native run-android error while preverifying

$
0
0

I tried to run react native project using react-native run-android command, but there is an error showing at 98% and the process ends with an error. Please check the below errors.

Unexpected error while performing partial evaluation:
Class       = [com/airbnb/android/react/maps/AirMapView]
Method      = [fitToElements(Z)V]
Exception   = [java.lang.IllegalArgumentException] (Can't find common super class of 
[java/util/Iterator] (with 2 known super classes) and [com/google/android/gms/maps/model/LatLngBounds] (with 1 known super classes))
Unexpected error while preverifying:
Class       = [com/airbnb/android/react/maps/AirMapView]
Method      = [fitToElements(Z)V]
Exception   = [java.lang.IllegalArgumentException] (Can't find common super class of [java/util/Iterator] (with 2 known super classes) and [com/google/android/gms/maps/model/LatLngBounds] (with 1 known super classes))

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForDebug'.
> java.io.IOException: java.lang.IllegalArgumentException: Can't find common super class of [java/util/Iterator] (with 2 known super classes) and [com/google/android/gms/maps/model/LatLngBounds] (with 1 known super classes)

I have no idea how to resolve the above issue. I think the problem is with react-native-maps library. Please check below details

build.gradle

dependencies {
    implementation project(':@react-native-community_async-storage')
    implementation project(':@react-native-community_netinfo')
    implementation project(':react-native-gesture-handler')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules

    implementation "com.android.support:multidex:1.0.3"
    implementation project(":react-native-image-zoom")
    implementation project(":react-native-photo-view")
    implementation project(":react-native-vector-icons")
    implementation project(":react-native-video")
    implementation (project(":react-native-fcm")) {
        exclude group: "com.google.firebase"
    }
    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 project(":react-native-image-picker")
    implementation project(":react-native-fcm")
    implementation project(":react-native-svg")
    implementation ('com.google.firebase:firebase-messaging:10.2.1') {
        force = true;
    }

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

package.json

"react": "16.9.0",
"react-native": "0.61.5",
"react-native-camera": "^3.16.0",
"react-native-maps": "^0.26.1",

Where am I going wrong? I really stuck in here. Does anyone know the solution, it will be very much effective.

Running Emulator with expo and Android Studio and getting : "Error running adb: This computer is not authorized to debug the device"

$
0
0

(1) I enabled USB debugging on the emulator as I do not have an android. (2) I updated all of my drivers. (3) Yarn is running as it should, (4) expo is starting and (5) the emulator is connecting and and running Android.

But I continue to get the error below after clicking "Run on Android Device/Emulator" in expo and the emulator will not display the React-Native code for the app:

""Couldn't start project on Android: Error running adb: This computer is not authorized to debug the device. Please follow the instructions here to enable USB debugging: https://developer.android.com/studio/run/device.html#developer-device-options. If you are using Genymotion go to Settings -> ADB, select "Use custom Android SDK tools", and point it at your Android SDK directory.""

I'm not using Genymotion.

Any help is appreciated!


ScrollView pagingEnabled scrolls to the last Index when using arrow keys

$
0
0

I am building an Android TV application. I have tried many carousel packages but nothing fits my needs. So I decided to make my own using ScrollView. The only requirements I had were, the image should be full screen and the keyboard (Arrow keys on D-Pad) should function as expected. I have horizontal activated. Using the pagingEnabled works as expected but only if I swipe. If I press the left and right arrow keys on the keyboard or D-Pad, it scrolls to the last page instead of the next page. Here is where I have gone so far (Full Code):


import React, { Component } from 'react';
import { StyleSheet, View, Text, Image, ScrollView, ImageBackground } from 'react-native';
import {Dimensions } from "react-native";
export default class MovieScreen extends Component {

    constructor(props) {
        super(props);
        this.state = {
            width: 100,
            height: 75,
            index: 0,
            testIndex: 1,
            activeSlide: 0,
            entries: [
                {
                    "albumId": 1,
                    "id": 1,
                    "title": "accusamus beatae ad facilis cum similique qui sunt",
                    "url": "https://via.placeholder.com/600/92c952",
                    "thumbnailUrl": "https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png"
                },
                {
                    "albumId": 1,
                    "id": 1,
                    "title": "accusamus beatae ad facilis cum similique qui sunt",
                    "url": "https://via.placeholder.com/600/92c952",
                    "thumbnailUrl": "https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png"
                },
                {
                    "albumId": 1,
                    "id": 1,
                    "title": "accusamus beatae ad facilis cum similique qui sunt",
                    "url": "https://via.placeholder.com/600/92c952",
                    "thumbnailUrl": "https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png"
                },
                {
                    "albumId": 1,
                    "id": 1,
                    "title": "accusamus beatae ad facilis cum similique qui sunt",
                    "url": "https://via.placeholder.com/600/92c952",
                    "thumbnailUrl": "https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png"
                },
                {
                    "albumId": 1,
                    "id": 1,
                    "title": "accusamus beatae ad facilis cum similique qui sunt",
                    "url": "https://via.placeholder.com/600/92c952",
                    "thumbnailUrl": "https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png"
                },
                {
                    "albumId": 1,
                    "id": 1,
                    "title": "accusamus beatae ad facilis cum similique qui sunt",
                    "url": "https://via.placeholder.com/600/92c952",
                    "thumbnailUrl": "https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png"
                },
                {
                    "albumId": 1,
                    "id": 1,
                    "title": "accusamus beatae ad facilis cum similique qui sunt",
                    "url": "https://via.placeholder.com/600/92c952",
                    "thumbnailUrl": "https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png"
                },
                {
                    "albumId": 1,
                    "id": 1,
                    "title": "accusamus beatae ad facilis cum similique qui sunt",
                    "url": "https://via.placeholder.com/600/92c952",
                    "thumbnailUrl": "https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png"
                },
                {
                    "albumId": 1,
                    "id": 1,
                    "title": "accusamus beatae ad facilis cum similique qui sunt",
                    "url": "https://via.placeholder.com/600/92c952",
                    "thumbnailUrl": "https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png"
                },
                {
                    "albumId": 1,
                    "id": 1,
                    "title": "accusamus beatae ad facilis cum similique qui sunt",
                    "url": "https://via.placeholder.com/600/92c952",
                    "thumbnailUrl": "https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png"
                },

            ]
        }
    }


    render() {

        const { width: viewportWidth, height: viewportHeight } = Dimensions.get('window');


        return (

            <View>
                <ScrollView horizontal={true} style={styles.scrollBox} pagingEnabled
                            >

                    {
                        this.state.entries.map((e, index) => {
                            return (

                                <View key={index}>
                                    <ImageBackground source={{uri: 'https://www.ecopetit.cat/wpic/mpic/4-41961_1080p-fox-wallpaper-hd.png'}} style={{ width: viewportWidth, height: viewportHeight }}>
                                        <Text>test</Text>
                                    </ImageBackground>
                                </View>

                            )
                        })
                    }

                </ScrollView>
            </View>


        );
    }
}

const { width: viewportWidth, height: viewportHeight } = Dimensions.get('window');

const styles = StyleSheet.create({
    imageCard: {
        width: viewportWidth,
        height: viewportHeight
    },
})


As shown here, I am using pagingEnabled on the ScrollView but the keyboard arrow keys goes to the last page.

how to fix webview has been removed from react native it can now be install and imported from react-native-webview insted of react native

$
0
0

enter image description hereimport React, { Component } from 'react';

import { Text, Button, View, ScrollView } from "react-native";

import Chart from "react-native-f2chart";

import { WebView, } from 'react-native';

import { Container, Title } from "../components";

import { basePie, labelPie } from "./scripts";

type Props = {}; class PieChartScreen extends PureComponent {

render() {

return (

  <ScrollView>

    <Container>

      <View>

        <Title title="基础饼图" />

        <View style={{ height: 250 }}>

          <Chart initScript={basePie} webView={WebView} />

        </View>
      </View>

      <View>
        <Title title="带文本饼图" />

<Chart initScript={labelPie} webView={WebView} />

        </View>

      </View>

      <View style={{ height: 20 }} />

    </Container>

  </ScrollView>

);

}

}

export default PieChartScreen;

Flutter vs React Native vs Java vs Kotlin [closed]

$
0
0

I would love to learn android development, which of Flutter, React Native, Java and Kotlin would you recommend and why? I have a good background in node.js

RNFetchBlob download not working on android 9

$
0
0

My code to download the file as below

RNFetchBlob.config({
    path : path,
    background: true,
    cacheable:false,
    timeout: 1000 * 60 * 15 //15 minutes
})
.fetch('GET', forFile.url, {//some headers ..})
.then((res) => {
    Realm.open({
        schema: [
            ScheduleSchema,
            PlaylistSchema,
            FileSchema
        ],
        schemaVersion: schema_version
    }).then(realm => {
        realm.write(() => {
            localPath = Platform.OS === 'android' ? 'file://' + res.path() : `playlists/${playlistName}/${getFileName(forFile)}`
            forFile.file_local_path = localPath
            console.log('The file saved to ', res.path() + 'for remote url' +forFile.url)

        })
    }).catch((error) => {
        alert("realm open error on file download service", error);
        console.log(error);
        reject(error)
    })
    resolve(forFile);
}).catch((error)=>{
    console.log("file download error " + error);
    showToastMessage(I18n.t("ErrorMessage.ErrorInFileDownload"))
})

This code works fine for Android 7 but not on Android 9.

Error from Android Studio Logcat as below

java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close()
        at okhttp3.internal.connection.Transmitter.newExchange(Transmitter.java:164)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
        at com.RNFetchBlob.RNFetchBlobReq$2.intercept(RNFetchBlobReq.java:385)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:221)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:172)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)

Expokit - Splash Screen not showing on Android after upgrading to SDK 36 from SDK 32

$
0
0

I am currently working on a project that is ejected to Expokit and some weeks ago we upgraded SDK version from 32 to SDK 36, and since then, in Android devices, the Splash Screen from configuration options in app.json is not showing up anymore.

What we see first is the Splash image from splash_background.xml that is showing properly and after that everything we see is the color of backgroundColor from app.json.

The only thing that takes the changes is the backgroundColor inside the splash object (app.json). Also we are using AppLoading from expo, but changing or removing it doesn't affect anything.

This is happening just on Android, otherwise on iOS devices everything looks pretty good.

Environment

    - "react": "~16.9.0",
    - "react-native": "0.61.4",
    - "expo": "~36.0.0",
    - "expokit": "36.0.0",

app.json

"sdkVersion": "36.0.0",
    "androidStatusBarColor": "#002C61",
    "androidStatusBar": {},
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "cover",
      "backgroundColor": "#bc0229"
    },

splash_background.xml

<?xml version="1.0" encoding="utf-8"?>enter code here
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">

        <item android:drawable="@color/splashBackground"/>

        <item><bitmap android:gravity="center" android:src="@drawable/splash" /></item>

    </layer-list>

ERROR: extensionSupplier.get "compileSdkVersion" must not be null when ejecting expo

$
0
0

I ejected my expo app to add native code. I got an error in /node_modules/expo-gl-cpp/android/build.gradle

the error is : ERROR: extensionSupplier.get()!!.compileSdkVersion must not be null

and i the build.gradle of the expo-gl-cpp i have this code :

 def ndkDir = android.hasProperty('plugin') ? android.plugin.ndkFolder :
  plugins.getPlugin('com.android.library').hasProperty('sdkHandler') ?
      plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder() :
      android.ndkDirectory.absolutePath

About my configuration :

Android SDK location : /Users/khaled/Library/Android/sdk

Android NDK location : /Users/khaled/Library/Android/sdk/ndk/21.0.6113669

JDK location : /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home

Android Gradle Plugin Version : 3.5.3

Gradle Version : 5.4.1

React Native - Android TV - DPad Functionality

$
0
0

I have published a react native application to google play store for android tv.

For tv, I have received notification for:

Missing DPad functionality Your app requires user interaction for menus or app navigation. Please make sure that all menus and app navigation are fully functional using a DPad. Please refer to our DPAD Control and Hardware Declaration documentation.

How do we enable d-pad navigation for react-native android apps?

If you need any more info, just let me know.


After importing react-native-firebase/firestore in to my app, I get the build error 'Could not find com.google.firebase:firebase-bom:21.3.0.'

$
0
0

I have just added react-native-firebase/firestore v6.2.0 to my React Native app. It was previously building fine whilst using the auth and messaging modules.

Now when I build the app I get the error:

> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.google.firebase:firebase-bom:21.3.0.
     Searched in the following locations:
       ...
     Required by:
         project :app > project :@react-native-firebase_messaging
         project :app > project :@react-native-firebase_app
         project :app > project :@react-native-firebase_auth

I'm not sure what this file is or why it would have been removed.

Any help much appreciated!

React native Amplify AWS package conflicting firebase

$
0
0

In my react native project I earlier added aws amplify for push notification. After that I wanted to do analytics, so I added firebase to it. After that, my android app build but stops as soon as it launches.

I get error as

java.lang.RuntimeException: Unable to instantiate service com.amazonaws.amplify.pushnotification.RNPushNotificationMessagingService: java.lang.ClassNotFoundException: Didn't find class "com.amazonaws.amplify.pushnotification.RNPushNotificationMessagingService

Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/messaging/FirebaseMessagingService; at java.lang.VMClassLoader.findLoadedClass(Native Method) at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738) at java.lang.ClassLoader.loadClass(ClassLoader.java:363) ... 10 more Caused by: java.lang.ClassNotFoundException: com.google.firebase.messaging.FirebaseMessagingService

My 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"

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

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

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

    defaultConfig {
        applicationId "com.project”
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 2
        versionName "1.1"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        manifestPlaceholders = [
                appAuthRedirectScheme: 'com.project’
        ]
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            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 {
    implementation project(':react-native-firebase')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-reanimated')
    implementation project(':@react-native-community_netinfo')
    compile project(':react-native-charts-wrapper')
    compile project(':rn-fetch-blob')
    compile project(':react-native-wheel-picker')
    compile project(':react-native-vector-icons')
    compile project(':react-native-pdf')
    compile project(':react-native-app-auth')
    compile project(':@aws-amplify_pushnotification')
    implementation (project(':react-native-device-info')){
        exclude group: "com.google.android.gms" 
        exclude group: "com.android.support"
    }
    implementation project(':react-native-wheel-picker')
    implementation project(':react-native-vector-icons')
    implementation project(':amazon-cognito-identity-js')
    implementation project(':@aws-amplify_pushnotification')
    implementation project(':react-native-app-auth')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.firebase:firebase-core:16.0.9"
}

// 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 plugin: 'com.google.gms.google-services'
//com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

Get device screen height in React Native when Full Screen Gesture feature is enabled and the device have a Notch

$
0
0

I need to get the real screen height of devices that have enabled the Full Screen Gesture feature and have a notch.

The thing is that both of this device features can be modified by users, I mean enabling/disabling Full Screen Gesture and enabling the notch hiding.

I've tried using functions of "Dimensions" class of React Native without results.

How can I detect if these features are enabled on the current device to properly adapt the height of the screen?

Example of Full Screen Gesture in Xiamomi Redmi 7

TVEventHandler not found for Android TV

$
0
0

I am trying to build an application for android tv and I wanted to use the remote movements. I first checked if there was a package which could help me with this but I could not find one.

Then I moved on to the official documentation listed here

I am trying to use this code:

var TVEventHandler = require('TVEventHandler');

class Game2048 extends React.Component {
  _tvEventHandler: any;

  _enableTVEventHandler() {
    this._tvEventHandler = new TVEventHandler();
    this._tvEventHandler.enable(this, function(cmp, evt) {
      if (evt && evt.eventType === 'right') {
        cmp.setState({board: cmp.state.board.move(2)});
      } else if(evt && evt.eventType === 'up') {
        cmp.setState({board: cmp.state.board.move(1)});
      } else if(evt && evt.eventType === 'left') {
        cmp.setState({board: cmp.state.board.move(0)});
      } else if(evt && evt.eventType === 'down') {
        cmp.setState({board: cmp.state.board.move(3)});
      } else if(evt && evt.eventType === 'playPause') {
        cmp.restartGame();
      }
    });
  }

  _disableTVEventHandler() {
    if (this._tvEventHandler) {
      this._tvEventHandler.disable();
      delete this._tvEventHandler;
    }
  }

  componentDidMount() {
    this._enableTVEventHandler();
  }

  componentWillUnmount() {
    this._disableTVEventHandler();
  }

But the var TVEventHandler = require('TVEventHandler'); says no module was found called TVEventHandler. And I tried to import it manually from react-native/Libraries/Components/AppleTV and that gives me an error stating that the component may not have been exported error. I am not sure what I am doing wrong here. I did everything the Doc asks

Event from event.nativeEvent.data logs as setImmediate$0.4162155499933975$1

$
0
0

I am trying to pass token and other user details from React Web application to React Native application with Webview (react-native).

When I do

window.postMessage(JSON.stringify(reactNativeObj), '*');

and log the event in React native application with

console.log( "On Message", event.nativeEvent.data );

It is printing the log as

On Message: setImmediate$0.4162155499933975$1

It should print my object instead.

I have tried almost everything and re-read the document https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage but couldn't make it work.

Any help would be appreciated.

Viewing all 29506 articles
Browse latest View live


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