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

Problem with install React Native App - Don't reload content from WordPress site

$
0
0

I download TownHub React Native App and follow all instruction from documentation, demo test on my phone work nice read here, and after that test success started I will start CTH App to test and when I enter in NPM Console npx react-native run-android after 2 min, the app will start on my phone but when I get loader logo then I think that app needs to load content from my website template same TownHub it says me this error: PS. I connect API Key to WP site and change every single code and sitedetails.js file.

Logo loader

Error top screen

Error bottom screen

When I open developer mode same from node.js console and click on debug I get this in chrome:

React Native JS code runs as a web worker inside this tab.Press Ctrl⇧J to open Developer Tools. Enable Pause On Caught Exceptions for a better debugging experience.You may also install the standalone version of React Developer Tools to inspect the React component hierarchy, their props, and state.Status: Debugger session #0 active.

And Screenshot from mobile:

Error after debug 1

Error after debug 2

Can someone explain to me what kind of error is this? How to resolve it? All documentation can be found here.

Best regards all.


__fbBatchedBridgeConfig is not set, cannot invoke native modules React Ntive with Expo

$
0
0

Idk why but when i run the app on android emulator or even in my device it works, i can build apk share with friends and such but when i try to use it on web it gives me this problem, not that it makes any difference in my app but i wanna make it responsive on many devices and with chrome dev tools thats a lot easier. The error is pointin on webpack/bootsrap but i dont have a folder in my project named "webpack" should i install something? I have latest expo-cli v3.23.2.

React Native access strings.xml from inside javascript code

$
0
0

Is there a way to access the current values from android/app/src/main/res/values/strings.xml from inside Javascript code? I want to place different endpoint URLs for each build, but I'm failing even to detect the type of build inside react-native code without having to resort to the __DEV__ variable (which can be turned off from the dev menu)

react native application on emulator stuck on white screen

$
0
0

on android only and only in the emulator, if I run my react native app, the app does not launch and get stuck on a white screen. The bundler in the terminal does not receive any connections requests.

It used to work and it works when I run on a device using the same command (react-native run-android)

I'm on react native 0.57.8

enter image description here

enter image description here

Here are the logs I get from react-native log-android:

    02-26 17:12:21.527  6544  6544 D ReactNative: ReactInstanceManager.ctor()    02-26 17:12:21.606  6544  6544 D ReactNative: ReactInstanceManager.createReactContextInBackground()    02-26 17:12:21.606  6544  6544 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()    02-26 17:12:21.629  6544  6544 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()    02-26 17:12:21.629  6544  6544 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()    02-26 17:12:21.629  6544  6544 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()    02-26 17:12:21.665  6544  6604 D ReactNative: ReactInstanceManager.createReactContext()    02-26 17:12:21.727  6544  6604 D ReactNative: Initializing React Xplat Bridge.    02-26 17:12:21.729  6544  6604 D ReactNative: Initializing React Xplat Bridge before initializeBridge    02-26 17:12:21.735  6544  6604 D ReactNative: Initializing React Xplat Bridge after initializeBridge    02-26 17:12:21.735  6544  6604 D ReactNative: CatalystInstanceImpl.runJSBundle()

I even tried reverting to older code version via git to version that I know worked, but that still fails, so I think there might be a configuration issue with my machine and the emulator, but I'm unsure what.

Any idea what might be causing this issue?

Failed to apply plugin [class 'org.gradle.api.plugins.BasePlugin']

$
0
0

Cannot start development.Error is:FAILURE: Build failed with an exception.

  • Where:Build file '/home/nurassyl/laifin-form-mobile/android/app/build.gradle' line: 1

  • What went wrong:A problem occurred evaluating project ':app'.

Failed to apply plugin [class 'org.gradle.api.plugins.BasePlugin']Could not create service of type OutputFilesRepository using ExecutionGradleServices.createOutputFilesRepository().

  • Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

One Signal Google Play Services Library Error React-Native

$
0
0

I recently came across a problem with my app.

I had installed OneSignal, it worked. And some updates after adding the onesignal, stopped working. I don't know exactly what I did wrong or which module is conflicting with the onesignal, I've been on this problem for days and I still can't solve it. Need help.

enter image description here

My package.json:

{"name": "smartial","version": "0.0.1","private": true,"scripts": {"android": "react-native run-android","ios": "react-native run-ios","start": "react-native start","test": "jest","lint": "eslint .","android-linux": "npx react-native run-android --terminal \"$PWD/shkonsole\""  },"dependencies": {"@react-native-community/google-signin": "^4.0.3","react-native-onesignal": "^3.7.3","@sentry/react-native": "^1.4.1","react-native-code-push": "^6.2.1","react-native-google-places": "^3.1.2","@react-native-community/datetimepicker": "^2.4.2","@react-native-community/masked-view": "^0.1.10","@react-navigation/material-bottom-tabs": "^5.2.12","@react-navigation/native": "^5.4.3","@react-navigation/stack": "^5.4.0","react-native-gesture-handler": "^1.6.1","native-base": "^2.13.12","react-native-paper": "^3.10.1","react-native-safe-area-context": "^2.0.3","react-native-reanimated": "^1.9.0","react-native-screens": "^2.8.0","apisauce": "^1.1.1","react-native-config": "^1.2.1","react-native-easy-app": "^1.7.3","react-native-vector-icons": "^6.6.0","@thallyssonklein/border-layout-react-native": "^1.0.14","recoil": "github:eveningkid/Recoil#react-native","react": "16.13.1","react-native": "0.63.2"  },"devDependencies": {"@babel/core": "^7.10.0","@babel/runtime": "^7.10.0","@bam.tech/react-native-make": "^3.0.0","@react-native-community/eslint-config": "^1.1.0","babel-jest": "^26.0.1","eslint": "^7.1.0","jest": "^26.0.1","metro-react-native-babel-preset": "^0.59.0","react-test-renderer": "16.11.0"  },"jest": {"preset": "react-native"  }}

My android/build.gradle:

buildscript {    ext {        buildToolsVersion = "28.0.3"        minSdkVersion = 16        compileSdkVersion = 28        targetSdkVersion = 28        googlePlayServicesAuthVersion = "16.0.1"    }    repositories {        google()        jcenter()    }    dependencies {        classpath('com.android.tools.build:gradle:3.6.3')        classpath 'com.google.gms:google-services:4.1.0'        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {        mavenLocal()        maven {            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm            url("$rootDir/../node_modules/react-native/android")        }        maven {            // Android JSC is installed from npm            url("$rootDir/../node_modules/jsc-android/dist")        }        google()        jcenter()        maven { url 'https://www.jitpack.io' }    }}

My android/app/build.gradle:

apply plugin: "com.android.application"import com.android.build.OutputFileproject.ext.react = [    enableHermes: false,  // clean and rebuild if changing]apply from: "../../node_modules/react-native/react.gradle"def enableSeparateBuildPerCPUArchitecture = falsedef enableProguardInReleaseBuilds = falsedef jscFlavor = 'org.webkit:android-jsc:+'def enableHermes = project.ext.react.get("enableHermes", false);android {    compileSdkVersion rootProject.ext.compileSdkVersion    compileOptions {        sourceCompatibility JavaVersion.VERSION_1_8        targetCompatibility JavaVersion.VERSION_1_8    }    defaultConfig {        applicationId "com.smartial"        minSdkVersion rootProject.ext.minSdkVersion        targetSdkVersion rootProject.ext.targetSdkVersion        versionCode 24        versionName "3.0.9"        multiDexEnabled true    }    splits {        abi {            reset()            enable enableSeparateBuildPerCPUArchitecture            universalApk false  // If true, also generate a universal APK            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"        }    }    signingConfigs {        debug {            storeFile file('debug.keystore')            storePassword 'android'            keyAlias 'androiddebugkey'            keyPassword 'android'        }        release {            storeFile file('smartial-app.jks')            storePassword KEYSTORE_PASSWORD            keyAlias KEY_ALIAS            keyPassword KEY_PASSWORD        }    }    buildTypes {        debug {            signingConfig signingConfigs.debug        }        release {            // Caution! In production, you need to generate your own keystore file.            // see https://facebook.github.io/react-native/docs/signed-apk-android.            signingConfig signingConfigs.release            minifyEnabled enableProguardInReleaseBuilds            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"        }    }    packagingOptions {        pickFirst "lib/armeabi-v7a/libc++_shared.so"        pickFirst "lib/arm64-v8a/libc++_shared.so"        pickFirst "lib/x86/libc++_shared.so"        pickFirst "lib/x86_64/libc++_shared.so"    }    // applicationVariants are e.g. debug, release    applicationVariants.all { variant ->        variant.outputs.each { output ->            // For each separate APK per architecture, set a unique version code as described here:            // https://developer.android.com/studio/build/configure-apk-splits.html            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]            def abi = output.getFilter(OutputFile.ABI)            if (abi != null) {  // null for the universal-debug, universal-release variants                output.versionCodeOverride =                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode            }        }    }}dependencies {    implementation fileTree(dir: "libs", include: ["*.jar"])    // implementation 'com.google.android.gms:play-services-auth:18.0.0'    // implementation "com.google.android.gms:play-services-base:16.0.1"    // implementation "com.google.firebase:firebase-core:16.0.6"    // implementation "com.google.firebase:firebase-messaging:17.3.4"    //noinspection GradleDynamicVersion    implementation "com.facebook.react:react-native:+"  // From node_modules    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"    compile 'com.android.support:multidex:1.0.1' //enter the latest version    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {      exclude group:'com.facebook.fbjni'    }    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {        exclude group:'com.facebook.flipper'    }    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {        exclude group:'com.facebook.flipper'    }    if (enableHermes) {        def hermesPath = "../../node_modules/hermes-engine/android/";        debugImplementation files(hermesPath +"hermes-debug.aar")        releaseImplementation files(hermesPath +"hermes-release.aar")    } else {        implementation jscFlavor    }    implementation project(':react-native-config')    compile project(':react-native-onesignal') // I just added this line }task copyDownloadableDepsToLibs(type: Copy) {    from configurations.compile    into 'libs'}apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"apply from: project(':react-native-config').projectDir.getPath() +"/dotenv.gradle"apply plugin: 'com.google.gms.google-services' // <--- this should be the last line

My src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"  package="com.smartial"><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/><application      android:name=".MainApplication"      android:label="@string/app_name"      android:icon="@mipmap/ic_launcher"      android:allowBackup="false"      android:theme="@style/AppTheme"><activity        android:name=".MainActivity"        android:label="@string/app_name"        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"        android:launchMode="singleTask"        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>

My src/debug/AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/><uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/><application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" /></manifest>

Some observations:

  • I checked the onesignal setup and followed all the steps again, nothing changed.
  • I checked all the issues of this error, questions in the stackoverflow, I tried all the small solutions I could, nothing changed.
  • I tried to remove the device directly on the onesignal panel and nothing changed.
  • I ran both an avd and a real device, nothing has changed.
  • I'm always running on debug, not on release.

React-Native: border is jagged in Android

$
0
0

I am building an application in React-Native. I used below code to make my view rounded and give radius to it. It's work perfectly on iOS. But I used the same code in Android borderRadius be jaggedgged.

<View     style={        height: 100,        width: 100,                                    borderRadius: 50,             backgroundColor: 'lightgray',        marginBottom: 0,        justifyContent: 'center',        alignItems: 'center',        borderWidth: 1,        borderColor: 'lightgray',            }/>

enter image description here

Any Solutions?

Can't prevent screenshot in android apk (release)

$
0
0

I'm able to prevent screenshot by setting the FLAG_SECURE.

However, FLAG_SECURE doesn't prevent screenshot after building it to APK and run it.

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 "MyAppName";    }    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);    }}

Any idea why? I'm running it on the same device Samsung Android 7.

Update:

It happens intermittently. Sometimes it blocks sometimes it allows screenshot.


Does react native have a third-party library to restart or shut down Android TV?

$
0
0

issue

hello,Now there is a function to control Android TV shutdown and restart according to TV app,but I couldn't find the library associated with it.At the same time, I am a pure front-end engineer,I don't know much about Android.Do you need to design native Android development?

Operating environment/version

development:react-native v0.63.2run: Android TV

Expected effect

Android TV can be turned off by functions such as buttons.

Final,Thank you for your reply.

Expo SDK 38: Facebook install tracking and Branch.io AAID tracking are broken for Android after migration

$
0
0

After migrating from Expo SDK 37 to 38 a month ago, we have no AAID (Android Advertising ID) in the Branch.io event tracking and no Android install tracking on Facebook anymore.

The migration included the package upgrades:

  • expo-branch 2.1.0 => 2.2.1
  • expo-facebook 8.1.0 => 8.2.1

I have not found anything on the breaking changes that might be related to this. Also no other users describing this problem. It might have nothing to do with the SDK update and is caused by the new native release.

Any ideas?

facebook dashboard

React-Native modules for Android int value returned late?

$
0
0

I have a native Android app that now has a React-Native part to it.

In short, i have a list view in native Android/Java. When i tap a row, i start a new Activity which leads to the React-Native code.

The components make an API call, but before it does it, my code goes through the React Native module to get a value from the User Preferences in the Java/Android settings for the header so that it can make the proper API call.

The React Native API call in /actions/index.js:

export const toggleBlocked = (user_id) =>async dispatch => {  try {    let headers = await getHeaders();    const response = await fetch('http://my.domain.com/api/get_data?user_id=`${user_id}`', { headers, method: 'GET' });    if (response.status == 200) {      // do stuff    } else {                  ToastAndroid.show("Looks like the response wasnt good :(", ToastAndroid.LONG, ToastAndroid.CENTER);    }  } catch (error) {    ToastAndroid.show("An Error Occurred :(", ToastAndroid.LONG, ToastAndroid.CENTER);  }};function getHeaders() {  let userId = UserService.getUserId()  console.log("2. React-Native | getHeaders... user_id is "+ userId)  return (    new Headers({      Cookie: `abcxyz=${userId}`,      user_id: userId,"User-Agent": "android","Content-Type": "application/json",      charset: "utf-8","app-version": "9.1.23",      Accept: "application/json"    })  )}

Back in native Android/Java, i have my modules and packages set up. Here is UserServiceModule.java:

    @ReactMethod    public int getUserId() {        SharedPreferences settings = mContext.getSharedPreferences(Constants.SettingsPreference, Context.MODE_PRIVATE);        int userId = settings.getUserId();        Log.d(TAG, "1. Java/Android code. UserID is "+ userId);        return userId;    }

When i run the code, user_id is always null. I even expected my logs to show in order (see the numbered logs), but they're reverse??

"1. Java/Android code. UserID is 123""2. React-Native | getHeaders... user_id is 123"

Any insights would be great please. Thanks.

UPDATE / SOLUTIONHere is the updated changes to get things working correctly:

@ReactMethodpublic void getUserId(final Promise promise) {    SharedPreferences settings = mContext.getSharedPreferences(Constants.SettingsPreference, Context.MODE_PRIVATE);    int userId = settings.getUserId();    Log.d(TAG, "1. Java/Android code. UserID is "+ userId);    promise.resolve(Integer.toString(userId));}

React Native - android wont compile after adding react-native-firebase

$
0
0

My react native android was compiling fine until I added react-native-firebase as per the docs (ios compiles fine).

  • React Native 0.63.2 and react-native-firebase 8.3.0 latest versionsand followed docs very carefully. OSX 10.15.6
  • Deleted/cleared/reinstalled gradle and android gradle/build dirs etc.
  • java JRE v8.202 /Library/Internet Plug-Ins/JavaAppletPlugin.plugin
  • java JRE v8.202 /Library/Java/JavaVirtualMachines
  • Note that JAVA_HOME path set to /Applications/AndroidStudio.app/Contents/jre/jd/Contents/Home

Error:

> Task :react-native-firebase_app:compileDebugJavaWithJavac FAILEDFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':react-native-firebase_app:compileDebugJavaWithJavac'.> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

ReactNative in app purchase in multi device

$
0
0

I am developing an application which allows user can buy a product using In app purchase of Apple/Google.

My app has no login function.

User can buy product by Apple ID or Google ID.

https://github.com/dooboolab/react-native-iap

We are using this library.

For example: I have a product -> Product A (Auto‑Renewable Subscriptions)

If user buy this product, in my app, it will be displayed as " BOUGHT A "

Device A: using apple id/google id example@example.com buy product A

Then after that Device A will displayed as "BOUGHT A"Device B: the same apple id/google id example@example.comI want in device B also "BOUGHT A" because device b also use example@example.com

Can I do it?

I don't want to save apple id or google id in back-end server.

Cannot build android with app:assembleAndroidTest - More than one file was found with OS independent path 'targetInvocationEspresso.json'

$
0
0

I've follow and setup exact like this guide for Android: https://github.com/wix/Detox/blob/master/docs/Introduction.Android.mdthis is my detox configuration in package.json :

"detox": {"configurations": {"android": {"binaryPath": "android/app/build/outputs/apk/release/app-release.apk","build": "cd android && ./gradlew app:assembleRelease app:assembleAndroidTest -DtestBuildType=release && cd ..","type": "android.emulator","name": "Pixel_3a_XL_API_30"      }    },"test-runner": "jest","behavior": {"init": {"launchApp": false      },"cleanup": {"shutdownDevice": false      }    }  }

and i'm using this commandline to build android:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ && rm -rf android/app/src/main/res/raw/* && detox build -c android

After build, Android throw this exception:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/  && rm -rf android/app/src/main/res/raw/* && detox build -c androidwarn The following packages use deprecated "rnpm" config that will stop working from next release:  - react-native-orientation: https://github.com/yamill/react-native-orientation#readme  - react-native-wheel-datepicker: https://github.com/pinguinjkeke/react-native-wheel-datepicker#readmePlease notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.Loading dependency graph...warn The following packages use deprecated "rnpm" config that will stop working from next release:  - react-native-orientation: https://github.com/yamill/react-native-orientation#readme  - react-native-wheel-datepicker: https://github.com/pinguinjkeke/react-native-wheel-datepicker#readmePlease notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.Loading dependency graph, done.Loading dependency graph...info Writing bundle output to:, android/app/src/main/assets/index.android.bundleinfo Done writing bundle outputinfo Copying 618 asset filesinfo Done copying assetszsh: sure you want to delete all 16 files in /Users/baopn/Documents/bitbucket/academy-mobile/android/app/src/main/res/raw [yn]? ydetox[31002] INFO:  [build.js] cd android && ./gradlew app:assembleRelease app:assembleAndroidTest -DtestBuildType=release && cd ..Configuration on demand is an incubating feature.> Configure project :appregisterResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)> Configure project :react-native-wheel-datepickerWARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html> Configure project :react-native-orientationWARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html> Configure project :react-native-firebasereact-native-firebase: using React Native prebuilt binary from /Users/baopn/Documents/bitbucket/academy-mobile/node_modules/react-native/android> Task :app:processReleaseGoogleServicesParsing json file: /Users/baopn/Documents/bitbucket/academy-mobile/android/app/google-services.json> Task :app:processReleaseManifest/Users/baopn/Documents/bitbucket/academy-mobile/android/app/src/main/AndroidManifest.xml:15:9-25:20 Warning:        provider#cl.json.RNShareFileProvider@android:authorities was tagged at AndroidManifest.xml:15 to replace other declarations but no other declaration present/Users/baopn/Documents/bitbucket/academy-mobile/android/app/src/main/AndroidManifest.xml Warning:        meta-data#android.support.FILE_PROVIDER_PATHS@android:resource was tagged at AndroidManifest.xml:0 to replace other declarations but no other declaration present/Users/baopn/Documents/bitbucket/academy-mobile/android/app/src/main/AndroidManifest.xml:24:9-31:50 Warning:        activity#com.google.firebase.auth.internal.FederatedSignInActivity@android:launchMode was tagged at AndroidManifest.xml:24 to replace other declarations but no other declaration present> Task :app:transformResourcesWithMergeJavaResForReleaseAndroidTest FAILEDFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:transformResourcesWithMergeJavaResForReleaseAndroidTest'.> More than one file was found with OS independent path 'targetInvocationEspresso.json'* 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.orgDeprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warningsBUILD FAILED in 17s541 actionable tasks: 10 executed, 531 up-to-datedetox[31002] ERROR: [cli.js] Error: Command failed: cd android && ./gradlew app:assembleRelease app:assembleAndroidTest -DtestBuildType=release && cd ..

running a react native project on android

$
0
0

I've followed exactly the official tutorial on how to configure RN environment this one, every thing seems to be good, but when i created a simple project and tried to run it by react-native run-android i got this error

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 4 workers...info Starting JS server...info Installing the app...> Task :app:mergeDebugResources FAILEDDeprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings7 actionable tasks: 2 executed, 5 up-to-dateFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:mergeDebugResources'.> Multiple task action failures occurred:> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> AAPT2 aapt2-3.5.3-5435860-linux Daemon #0: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> AAPT2 aapt2-3.5.3-5435860-linux Daemon #1: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> AAPT2 aapt2-3.5.3-5435860-linux Daemon #3: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> AAPT2 aapt2-3.5.3-5435860-linux Daemon #2: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> AAPT2 aapt2-3.5.3-5435860-linux Daemon #4: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> AAPT2 aapt2-3.5.3-5435860-linux Daemon #5: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> AAPT2 aapt2-3.5.3-5435860-linux Daemon #7: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> AAPT2 aapt2-3.5.3-5435860-linux Daemon #6: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa* 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 8serror 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=8081

I did some research and all i found is that the linux os is not compatible, but in my case i have a 64 bit linux, here is my lcpu result

Architecture:        x86_64CPU op-mode(s):      32-bit, 64-bitByte Order:          Little EndianCPU(s):              4On-line CPU(s) list: 0-3Thread(s) per core:  2Core(s) per socket:  2Socket(s):           1NUMA node(s):        1Vendor ID:           GenuineIntelCPU family:          6Model:               142Model name:          Intel(R) Core(TM) i5-7300U CPU @ 2.60GHzStepping:            9CPU MHz:             2625.481CPU max MHz:         3500.0000CPU min MHz:         400.0000BogoMIPS:            5399.81Virtualization:      VT-xL1d cache:           32KL1i cache:           32KL2 cache:            256KL3 cache:            3072KNUMA node0 CPU(s):   0-3

Knowing that my laptop is a company laptop, does that may be the problem ? i have the sudo access though


React Native - Build successful but no APK output

$
0
0

I'm trying to build my react native app but when I run ./gradlew bundleDebug or ./gradlew bundleRelease it says BUILD SUCCESSFUL but there is no APK in build/outputs/apk directory.How can I build a universal APK from my react native app?

React Native - Overlay in Camera

Connect with server using self-singed certificate using Android

$
0
0

I prepare library for React Native application to connect with some external server. This server required to use self-signed certificate and encrypted key to prepare connection. I have worked source typed in TypeScript which use node-fetch. However React Native not support this library and all alternatives (react-native-fetch, react-native-pinch, reat-native-ssl-pinning, axios) what I found not worked for me so I decide to type native module for Android in Java.

In node-fetch my code looks like that:

    const options = {    cert: "<My self signed certificate content from .crt file>",    key: "<My encrypted key content from .key file>",    passphrase: "<Password to this .key>",    rejectUnauthorized: false,    keepAlive: false,    };    const sslAgent = new https.Agent(options);    const requestInit = {"GET",        headers: {            Accept: 'application/json',        },        agent: sslAgent    };    const response = await fetch("<Https request address>", requestInit);    console.log(response);

And in my android implementation:

CertificateFactory cf = CertificateFactory.getInstance("X.509");        ByteArrayInputStream byteInput = new ByteArrayInputStream("<My self signed certificate content from .crt file>".getBytes());        InputStream caInput = new BufferedInputStream(byteInput);        Certificate ca = cf.generateCertificate(caInput);        String keyStoreType = KeyStore.getDefaultType();        KeyStore keyStore = KeyStore.getInstance(keyStoreType);        ByteArrayInputStream byteKeyInput = new ByteArrayInputStream("<My encrypted key content from .key file>".getBytes());        InputStream keyInput = new BufferedInputStream(byteKeyInput);        keyStore.load(keyInput, "<Password to this .key>",.toCharArray());        keyStore.setCertificateEntry("ca", ca);        String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();        TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);        tmf.init(keyStore);        SSLContext context = SSLContext.getInstance("TLS");        context.init(null, tmf.getTrustManagers(), null);        URL url = new URL("<Https request address>");        HttpsURLConnection urlConnection =                (HttpsURLConnection)url.openConnection();        urlConnection.setRequestMethod("GET");        urlConnection.setSSLSocketFactory(context.getSocketFactory());        if (urlConnection.getResponseCode() == HttpsURLConnection.HTTP_OK) {            BufferedReader in = new BufferedReader(new InputStreamReader(                    urlConnection.getInputStream()));            String inputLine;            StringBuffer response = new StringBuffer();            while ((inputLine = in.readLine()) != null) {                response.append(inputLine);            }            in.close();            // print result            System.out.println(response.toString());        }

I get error "Wrong version of key store'. My encrypted key start with mark:

-----BEGIN RSA PRIVATE KEY-----Proc-Type: 4,ENCRYPTEDDEK-Info: DES-EDE3-CBC,7523FD34DC781ED5

So I suspect that is a PKCS1 type. I'm dead end and I don't have any idea how to should be implemented. Can you help me implement this correctly?

com.android.ddmlib.InstallException: Failed to establish session react-native

$
0
0

I am trying to run react-native android app in my nexus5 emulator

adb devicesList of devices attachedemulator-5554   device

started packager react-native start

running app - react-native run-android

Installing APK 'app-debug.apk' on 'reactnative(AVD) - 6.0'Unable to install examples/android/app/build/outputs/apk/app-debug.apk

com.android.ddmlib.InstallException: Failed to establish session        at com.android.ddmlib.Device.installPackages(Device.java:894)        at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:113)        at com.android.builder.testing.ConnectedDevice$installPackages$0.call(Unknown Source)        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)        at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.groovy:119)        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)        at java.lang.reflect.Method.invoke(Method.java:483)        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:226)

Camera Preview in Expo is Distorted

$
0
0

I'm using Camera that comes from expo package and I'm having trouble with camera preview distortion. The preview makes images appear wider in landscape view and thinner in portrait view. Most of the solutions I have found are not using expo-camera.

Relevant Code:

camera.page.js:

import React from 'react';import { View, Text } from 'react-native';import { Camera } from 'expo-camera';import * as Permissions from 'expo-permissions'import { Platform } from 'react-native';import styles from './styles';import Toolbar from './toolbar.component';const DESIRED_RATIO = "18:9";export default class CameraPage extends React.Component {    camera = null;    state = {        hasCameraPermission: null,    };    async componentDidMount() {        const camera = await Permissions.askAsync(Permissions.CAMERA);        const audio = await Permissions.askAsync(Permissions.AUDIO_RECORDING);        const hasCameraPermission = (camera.status === 'granted'&& audio.status === 'granted');        this.setState({ hasCameraPermission });    };    render() {        const { hasCameraPermission } = this.state;        if (hasCameraPermission === null) {            return <View />;        } else if (hasCameraPermission === false) {            return <Text>Access to camera has been denied.</Text>;        }        return (<React.Fragment><View><Camera                ref={camera => this.camera = camera}                style={styles.preview}                /></View><Toolbar/></React.Fragment>        );    };};

styles.js:

import { StyleSheet, Dimensions } from 'react-native';const { width: winWidth, height: winHeight } = Dimensions.get('window');export default StyleSheet.create({    preview: {        height: winHeight,        width: winWidth,        position: 'absolute',        left: 0,        top: 0,        right: 0,        bottom: 0,        paddingBottom: 1000,    },    alignCenter: {        flex: 1,        alignItems: 'center',        justifyContent: 'center',    },    bottomToolbar: {        width: winWidth,        position: 'absolute',        height: 100,        bottom: 0,    },    captureBtn: {        width: 60,        height: 60,        borderWidth: 2,        borderRadius: 60,        borderColor: "#FFFFFF",    },    captureBtnActive: {        width: 80,        height: 80,    },    captureBtnInternal: {        width: 76,        height: 76,        borderWidth: 2,        borderRadius: 76,        backgroundColor: "red",        borderColor: "transparent",    },});

What can I do to fix this?

Viewing all 29573 articles
Browse latest View live


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