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

TurboModule for android is always null

$
0
0

I am trying to create a TurboModule for android with ReactNative v0.69

Following are the steps which I followed for creating TurboModulesI enabled Hermes and newArchEnabled

project.ext.react = [    enableHermes: true]

In gradle.properties

newArchEnabled=true

I created a js folder in root of the project and create NativeCalculator.js

// @flowimport type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';import {TurboModuleRegistry} from 'react-native';export interface Spec extends TurboModule {  // your module methods go here, for example:  add(a: number, b: number): Promise<number>;}export default (TurboModuleRegistry.get<Spec>('Calculator'): ?Spec);

In app/build.gradle

apply plugin: "com.facebook.react"react {    reactRoot = rootProject.file("../node_modules/react-native/")    codegenDir = rootProject.file("../node_modules/react-native-codegen/")    jsRootDir = rootProject.file("../js/")    libraryName = "calculator"    codegenJavaPackageName = "com.firstapp.codegen"}

In java/com/firstapp/newarchitecture/modules

Created CalculatorModule.java, file

public class CalculatorModule extends NativeCalculatorSpec {    public static final String NAME = "Calculator";    public CalculatorModule(ReactApplicationContext context) {        super(context);    }    @Override    public String getName() {        return NAME;    }    @ReactMethod    public void add(double a, double b, Promise promise) {        Log.i("here123","Values are"+a+" "+b);        promise.resolve(a + b);    }}

In MainApplication.java

In getPackages method added following code

packages.add(new TurboReactPackage() {    @Nullable    @Override    public NativeModule getModule(String name, ReactApplicationContext reactContext) {        if (name.equals(CalculatorModule.NAME)) {            return new CalculatorModule(reactContext);        } else {            return null;        }    }    @Override    public ReactModuleInfoProvider getReactModuleInfoProvider() {        return () -> {            final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();            moduleInfos.put(                    CalculatorModule.NAME,                    new ReactModuleInfo(                            CalculatorModule.NAME,                            CalculatorModule.NAME,                            false, // canOverrideExistingModule                            false, // needsEagerInit                            true, // hasConstants                            false, // isCxxModule                            true // isTurboModule                    )            );            return moduleInfos;        };    }});@NonNull@Overrideprotected ReactPackageTurboModuleManagerDelegate.Builder getReactPackageTurboModuleManagerDelegateBuilder() {    return new MainApplicationTurboModuleManagerDelegate.Builder();}@Nullable@Overrideprotected JSIModulePackage getJSIModulePackage() {    return new JSIModulePackage() {        @Override        public List<JSIModuleSpec> getJSIModules(                final ReactApplicationContext reactApplicationContext,                final JavaScriptContextHolder jsContext) {            final List<JSIModuleSpec> specs = new ArrayList<>();            specs.add(new JSIModuleSpec() {                @Override                public JSIModuleType getJSIModuleType() {                    return JSIModuleType.UIManager;                }                @Override                public JSIModuleProvider<UIManager> getJSIModuleProvider() {                    final ComponentFactory componentFactory = new ComponentFactory();                    CoreComponentsRegistry.register(componentFactory);                    final ReactInstanceManager reactInstanceManager = getReactInstanceManager();                    ViewManagerRegistry viewManagerRegistry =                            new ViewManagerRegistry(                                    reactInstanceManager.getOrCreateViewManagers(                                            reactApplicationContext));                    return new FabricJSIModuleProvider(                            reactApplicationContext,                            componentFactory,                            new EmptyReactNativeConfig(),                            viewManagerRegistry);                }            });            return specs;        }    };}

In main/jni/Android.mk

include $(GENERATED_SRC_DIR)/codegen/jni/Android.mkLOCAL_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jniLOCAL_SRC_FILES += $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp)LOCAL_EXPORT_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jniLOCAL_SHARED_LIBRARIES := \.....libreact_codegen_calculator \.....

In MainApplicationModuleProvider.cpp

#include <calculator.h>std::shared_ptr<TurboModule> MainApplicationModuleProvider(    const std::string moduleName,    const JavaTurboModule::InitParams &params) {  // Here you can provide your own module provider for TurboModules coming from  // either your application or from external libraries. The approach to follow  // is similar to the following (for a library called `samplelibrary`:  //  auto module = calculator_ModuleProvider(moduleName, params);  if (module != nullptr) {     return module;  }  // return rncore_ModuleProvider(moduleName, params);  return rncore_ModuleProvider(moduleName, params);}

In App.js

import NativeCalculator from './js/NativeCalculator';

on Button press I have following code

const onPress = async () => {    console.log(NativeCalculator);    const theAnswer = await NativeCalculator?.add(4, 5);    Alert.alert('Answer', 'The answer is '+ theAnswer);  };

I tried console logging NativeCalculator but I get null

The entire source code is available here https://github.com/PritishSawant/reactnativeandroidturbomoduleV2


react-native-hsm-maps implemented but shows blank?

$
0
0

I need to implement Huawei maps in my application, the version that I installed in my package.json file is:

"@hmscore/react-native-hms-map": "^5.2.0-302"

after installation I tried to do what ever docs says so you can see my configs in different files below:

<HMSMap  mapType={MapTypes.NORMAL}  style={{height: 200}}  camera={{target: {latitude: 41, longitude: 29}, zoom: 11}}  onMapReady={(e) => console.log('HMSMap onMapReady: ', e.nativeEvent)} // btw this event never called./>

inside build.gradle file in android I add the maven { url 'https://developer.huawei.com/repo/' } inside buildscripts => repositories and allprojects => repositories, also in dependencies I add classpath 'com.huawei.agconnect:agcp:1.2.1.301'

inside build.gradle in android > app file I added apply plugin: "com.huawei.agconnect" also I added config object as below in signingConfigs. then I added implementation 'com.huawei.hms:maps:5.0.0.300' inside dependencies of this file

config {            storeFile file('***.keystore')            storePassword '*****'            keyAlias '******'            keyPassword '*******'        }

and then I added this 2 inside AndroidManifest.xml:

<meta-data android:name="com.huawei.hms.client.appid" android:value="appid=*******" /><uses-permission android:name="com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA"/>

I have other permissions which docs says as well..

and the problem is when I run the project the map doesn't show and only shows a blank space which is related to the height which is 200 inside styles. also when I log the event of onMapReady method it doesn't log. seems that map isn't ready at all. how can I debug this or understand which part of config or code is wrong?

is It possible to make react native app with odoo mark attendance functionality

$
0
0

I want to create an react native app with attendance functionality the attendance will store on odoo dashboard.Please help me TIA.

Android : Failed to open QEMU pipe 'qemud:network': Invalid argument

$
0
0

i am doing a ReactNative project and i got this error when i'm trying to access my local API (without httpS so) with ReactNative.It works on iOS but not on Android.

2022-06-25 16:03:45.642 479-479/? E/netmgr: qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:network' service: Invalid argument2022-06-25 16:03:45.642 479-479/? E/netmgr: Failed to open QEMU pipe 'qemud:network': Invalid argument2022-06-25 16:03:45.949 485-485/? E/wifi_forwarder: qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:wififorward' service: Invalid argument2022-06-25 16:03:45.950 485-485/? E/wifi_forwarder: RemoteConnection failed to initialize: RemoteConnection failed to open pipe

I think that i've tried to

  • add android:usesCleartextTraffic in my Manifest
  • Cold reboot
  • Wipe data
  • Create new avd
  • Changing my mac DNS for Google's one

Nothing changed. When i launch ENVFILE=.env.dev npx react-native run-android, i got this error.

Should i build again before launching ENVFILE=.env.dev npx react-native run-android ?

I am a little bit stuck. What should i do ?

React-Native (Android) error : Task :app:installDebug FAILED (macOs Big Sur)

$
0
0

first of all i'm using macOS Big Sur 11.6.7, my macbook is macbook pro 2013 late.I want to start learning react-native but i'm struggling to get things done to install the app on the emulator.

I want to start developing android apps first so all i did was configure android environment, not ios.

I've done everything on the Environment Setup section in react-native site but at the end, i keep getting this huge error which i don't know any clue about. I've been doing research for almost a day to handle the problem but i couldn't find any, so i decided to post it in here.

The metro app starts correctly, the emulator from android studio starts but react-native app cannot be installed and getting me this huge error :

eaidy@192 AwesomeProject % npx react-native run-androidinfo Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.Jetifier found 945 file(s) to forward-jetify. Using 4 workers...info JS server already running.info Launching emulator...info Successfully launched emulator.info Installing the app...> Task :app:installDebugInstalling APK 'app-debug.apk' on 'Resizable_API_33(AVD) - 13' for :app:debug> Task :app:installDebug FAILED39 actionable tasks: 2 executed, 37 up-to-dateUnable to install /Users/developerFiles/learning/AwesomeProject/android/app/build/outputs/apk/debug/app-debug.apkcom.android.ddmlib.InstallException: Unknown failure: Exception occurred while executing 'install':android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough spaceat android.util.ExceptionUtils.wrap(ExceptionUtils.java:34)at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:595)at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:3416)at com.android.server.pm.PackageManagerShellCommand.doRunInstall(PackageManagerShellCommand.java:1446)at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1408)at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:221)at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)at android.os.ShellCommand.exec(ShellCommand.java:38)at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:5952)at android.os.Binder.shellCommand(Binder.java:1049)at android.os.Binder.onTransact(Binder.java:877)at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4313)at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:5936)at android.os.Binder.execTransactInternal(Binder.java:1285)at android.os.Binder.execTransact(Binder.java:1244)Caused by: java.io.IOException: Requested internal only, but not enough spaceat com.android.internal.content.InstallLocationUtils.resolveInstallVolume(InstallLocationUtils.java:241)at com.android.internal.content.InstallLocationUtils.resolveInstallVolume(InstallLocationUtils.java:152)at com.android.internal.content.InstallLocationUtils.resolveInstallVolume(InstallLocationUtils.java:167)at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:803)at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:592)... 13 more        at com.android.ddmlib.internal.DeviceImpl.installRemotePackage(DeviceImpl.java:1315)        at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1141)        at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1117)        at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1106)        at com.android.build.gradle.internal.testing.ConnectedDevice.installPackage(ConnectedDevice.java:127)        at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.java:162)        at com.android.build.gradle.internal.tasks.InstallVariantTask.lambda$doTaskAction$1(InstallVariantTask.java:99)        at com.android.builder.testing.api.DeviceProvider.use(DeviceProvider.java:53)        at com.android.build.gradle.internal.tasks.InstallVariantTask.doTaskAction(InstallVariantTask.java:94)        at com.android.build.gradle.internal.tasks.NonIncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(BaseTask.kt:66)        at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)        at com.android.build.gradle.internal.tasks.NonIncrementalTask.taskAction(NonIncrementalTask.kt:97)        at jdk.internal.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)        at java.base@11.0.15/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)        at java.base@11.0.15/java.lang.reflect.Method.invoke(Method.java:566)        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)        at org.gradle.api.internal.tasks.execution.TaskExecution$2.run(TaskExecution.java:239)        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)        at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)        at org.gradle.api.internal.tasks.execution.TaskExecution.executeAction(TaskExecution.java:224)        at org.gradle.api.internal.tasks.execution.TaskExecution.executeActions(TaskExecution.java:207)        at org.gradle.api.internal.tasks.execution.TaskExecution.executeWithPreviousOutputFiles(TaskExecution.java:190)        at org.gradle.api.internal.tasks.execution.TaskExecution.execute(TaskExecution.java:168)        at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:89)        at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:40)        at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:53)        at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:50)        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:50)        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:40)        at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:68)        at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:38)        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:36)        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:41)        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:74)        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:55)        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:29)        at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:61)        at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:42)        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:60)        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:27)        at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:188)        at org.gradle.internal.execution.steps.BuildCacheStep.lambda$execute$1(BuildCacheStep.java:75)        at org.gradle.internal.Either$Right.fold(Either.java:175)        at org.gradle.internal.execution.caching.CachingState.fold(CachingState.java:59)        at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:73)        at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:48)        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:38)        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:27)        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:36)        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:22)        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:109)        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$2(SkipUpToDateStep.java:56)        at java.base@11.0.15/java.util.Optional.orElseGet(Optional.java:369)        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:56)        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:73)        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:44)        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:89)        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:50)        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:114)        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:57)        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:76)        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:50)        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:93)        at java.base@11.0.15/java.util.Optional.orElseGet(Optional.java:369)        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:93)        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)        at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:43)        at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:31)        at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:40)        at org.gradle.api.internal.tasks.execution.TaskExecution$3.withWorkspace(TaskExecution.java:284)        at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:40)        at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:30)        at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:37)        at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:27)        at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:44)        at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:33)        at org.gradle.internal.execution.impl.DefaultExecutionEngine$1.execute(DefaultExecutionEngine.java:76)        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:142)        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:131)        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:402)        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:389)        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:382)        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:368)        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)        at java.base@11.0.15/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)        at java.base@11.0.15/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)        at java.base@11.0.15/java.lang.Thread.run(Thread.java:829)FAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:installDebug'.> java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Unknown failure: Exception occurred while executing 'install':  android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space  at android.util.ExceptionUtils.wrap(ExceptionUtils.java:34)  at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:595)  at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:3416)  at com.android.server.pm.PackageManagerShellCommand.doRunInstall(PackageManagerShellCommand.java:1446)  at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1408)  at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:221)  at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)  at android.os.ShellCommand.exec(ShellCommand.java:38)  at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:5952)  at android.os.Binder.shellCommand(Binder.java:1049)  at android.os.Binder.onTransact(Binder.java:877)  at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4313)  at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:5936)  at android.os.Binder.execTransactInternal(Binder.java:1285)  at android.os.Binder.execTransact(Binder.java:1244)  Caused by: java.io.IOException: Requested internal only, but not enough space  at com.android.internal.content.InstallLocationUtils.resolveInstallVolume(InstallLocationUtils.java:241)  at com.android.internal.content.InstallLocationUtils.resolveInstallVolume(InstallLocationUtils.java:152)  at com.android.internal.content.InstallLocationUtils.resolveInstallVolume(InstallLocationUtils.java:167)  at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:803)  at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:592)  ... 13 more* 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.orgBUİLD FAILED in 18serror Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081Unable to install /Users/developerFiles/learning/AwesomeProject/android/app/build/outputs/apk/debug/app-debug.apkcom.android.ddmlib.InstallException: Unknown failure: Exception occurred while executing 'install':android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough spaceat android.util.ExceptionUtils.wrap(ExceptionUtils.java:34)

What could be possibly cause this ? How can i fix this issue ?

React Native Android app changes numbers' representation to be in Arabic/Persian

$
0
0

I'm working on a multi-language React Native application. When the user's app is in Arabic or Persian language, a font with Arabic digits will be used. And when they are in other languages (like English), a font with English digits will be used. One of our customers sent me the image below. The thing is their app is in English language but their phone's language settings is set to Persian language and so I think their device's settings is messing up the fonts in application. I expect all digits to be in English (since this is the behavior on my own Android phone with English language settings), but as you can see in the image below, all the digits before decimal points are shown in Arabic numbers. Is there a way to stop such behavior? For example once I had a problem with Android's dark theme getting applied to my application and ruining the colors but I added the following code to android/app/src/main/res/values/styles.xml and the problem was fixed.

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar"><item name="android:forceDarkAllowed">false</item><!-- Customize your theme here. --></style>

I mean, isn't there a similar solution like adding a property somewhere in AndroidManifest.xml, styles.xml, etc. to fix this issue?
Thanks in advance.

enter image description here

React Native - Error when i want to navigate

$
0
0

I have an error when i try to navigate using react.navigation.

I also have a visual bug since i've added react navigation.

Here's my code for app.js :

import React, { useState } from "react"; import {   StyleSheet,   Text,   View,   Image,   TextInput,   Button,   TouchableOpacity, } from "react-native";import { NavigationContainer } from '@react-navigation/native';import { createNativeStackNavigator } from '@react-navigation/native-stack';import HomeScreen from './HomeScreen';import RegisterScreen from './RegisterScreen';const Stack = createNativeStackNavigator(); export default function App() {   const [email, setEmail] = useState("");   const [password, setPassword] = useState("");  const link = "./Ressources/logoressources.png";  /*async function ClickLogin(){    alert(email);    l  }  async function ClickRegister(){    alert(email);  }  async function ClickMotDePasseOublie(){    alert("Fallait pas l'oublier (Veuillez l'ecrire sur un papier que vous nous remettrez la prochaine fois)");  }*/  //<Stack.Navigator> /* <Stack.Screen            name="Home"            component={HomeScreen}          />*/          //</Stack.Navigator>   return (<NavigationContainer><Stack.Navigator        screenOptions={{    headerShown: false    }}><Stack.Screen            name="Home"            component={HomeScreen}            /><Stack.Screen            name="Register"            component={RegisterScreen}        /></Stack.Navigator><HomeScreen /></NavigationContainer>   ); }

Here the code of the HomePage.js :

import React, { useState } from "react"; import RegisterScreen from './RegisterScreen'; import {   StyleSheet,   Text,   View,   Image,   TextInput,   Button,   TouchableOpacity, } from "react-native";import { NavigationContainer } from '@react-navigation/native';import { createNativeStackNavigator } from '@react-navigation/native-stack';//import HomeScreen from './HomeScreen';const Stack = createNativeStackNavigator(); const HomeScreen = ({navigation}) => {   const [email, setEmail] = useState("");   const [password, setPassword] = useState("");  const link = "./Ressources/logoressources.png";  async function ClickLogin(){    alert(email);  }  async function ClickRegister(){    navigation.navigate("Register");  }  async function ClickMotDePasseOublie(){    alert("Fallait pas l'oublier (Veuillez l'ecrire sur un papier que vous nous remettrez la prochaine fois)");  }  //<Stack.Navigator> /* <Stack.Screen            name="Home"            component={HomeScreen}          />*/          //</Stack.Navigator>   return (<View style={styles.container}><Image style={styles.image} source={require(link)} /><View style={styles.inputView}><TextInput           style={styles.TextInput}           placeholder="Email"           placeholderTextColor="#003f5c"           onChangeText={(email) => setEmail(email)}         /></View><View style={styles.inputView}><TextInput           style={styles.TextInput}           placeholder="Mot de passe"           placeholderTextColor="#003f5c"           secureTextEntry={true}           onChangeText={(password) => setPassword(password)}         /></View><View style={styles.inputViewConfirm}><TextInput           style={styles.TextInput}           placeholder="Confirmer mot de passe"           placeholderTextColor="#003f5c"           secureTextEntry={true}           onChangeText={(password) => setPassword(password)}         /></View><TouchableOpacity onPress={ClickMotDePasseOublie}><Text style={styles.forgot_button}>Mot de passe oublié ?</Text></TouchableOpacity><TouchableOpacity onPress={ClickRegister}><Text style={styles.Register_button}>Pas de compte ? Inscrivez-vous !</Text></TouchableOpacity><TouchableOpacity style={styles.loginBtn}        onPress={ClickLogin}><Text style={styles.loginText}>Se connecter</Text></TouchableOpacity></View>   ); } const styles = StyleSheet.create({   container: {     flex: 1,     backgroundColor: "#16a085",     alignItems: "center",     justifyContent: "center",   },   image: {     marginBottom: 10,     height: 200,   },   inputView: {     backgroundColor: "#A6E4E7",     borderRadius: 30,     width: "75%",     height: 45,     marginBottom: 20,     alignItems: "center",   },   inputViewConfirm: {    backgroundColor: "#A6E4E7",    borderRadius: 30,    width: "75%",    height: 45,    marginBottom: 20,    alignItems: "center",  },   TextInput: {     height: 50,     flex: 1,     marginLeft: 10,   },   forgot_button: {     height: 30,     marginBottom: 20,   },   Register_button: {    color: "#4834d4",    height: 30,    marginBottom: 10,  },   loginBtn: {     width: "80%",     borderRadius: 25,     height: 50,     alignItems: "center",     justifyContent: "center",     marginTop: 5,     backgroundColor: "#88FFDD",   }, });export default HomeScreen;

And the registerScreen Code :

import React from 'react';import { StyleSheet, Text, View } from 'react-native';const RegisterScreen = ({navigation}) =>  {    return (<View style={styles.container}><Text>Add friends here!</Text></View>    );}// ...export default RegisterScreen;

This is my error :That appear when i try to redirect the user to the RegisterScreen (by clicking "pas de compte ? Inscrivez vous")

And now a screenshot of the render of the application :

The interface should not be "duplicated" like that

Do you have a solution for me ?

I Have tryed to remove the top navigation bar to realign the interface but nothing worked.

I also verified my routes for the redirection bug, already searched answers on the internet and in the documentation but nothing got found.

Do I have to use Play App signing to generate sha_256 fingerprints for Android app links? My company releases the app through App Center

$
0
0

I've been trying to implement Android app links into my company's react native app, I've been following the documentation and I'm struggling with the part that involves adding the assetlink.json file on my website. I see mention of using Play app signing, our company doesn't release through the google play store instead we release through App Center. Hence, why my current google play console doesn't have a fingerprint.

There is also an option to generate a fingerprint with a keytool command but I don't think this is the right move since the fingerprint generated on my machine wouldn't work in production, right?

My question is do we have to use Play App signing to get the proper fingerprints to use for app links? Or is using App Center fine? If using App Center is fine then where can I find the sha_256 fingerprints to put in the assetlink.json file?


(Android, React Native) 'Ask every time' permission still return 'blocked'

$
0
0

I am using Android API 30, react native version 0.68I am using 'react-native-permissions' library

When my app is started it asks location permission, options are1.While using this app2.Ask every time3.Don't allow

I allow user 'Don't allow' for one time, so when user did 'Don't allow' twice the permission changed to 'blocked. I push user to app setting.

However at the app setting (After they choose 'Don't allow' twice for location permission dialog), user change permission to 'Ask every time', When user come back to my app, the location permission is still 'blocked'.... user must choose 'While using this app' when they did 'Don't allow' twice.

Can I change user's status even they select 'Ask every time' after they get 'blocked'?

How do I automate builds using App Center?

$
0
0

I am using App Center as CI and CD for my application. I have to configure all the branches manually against which I need to build and distribute.

What I Want

If somebody creates a feature branch from develop/master and pushes the code, then App Center should start running automatically like CircleCI etc.

Is this not possible in App Center?

Issue with foreground service android 11 and 12

$
0
0

Any one know how get the location update every seconds. when my device on foreground or background mode.I am working on Tracking app get the location in every seconds when he is waking on road or traveling whatever.

Actually my app working on version 10 not working on android 11 and 12.Also searched on google don't found exact answer.

I used this permission:

  1. Access background permission,
  2. Access Coarse permission.
  3. Access Fine Location.OR Foreground services for notification

If any one know please let tell me

Thank you

Build failed when attempting to launch react native project via Android Studio

$
0
0

I am trying to run my react native project in Android Studio via the Emulator but the following error appears when attempting to run the project:

FAILURE: Build failed with an exception.

  • What went wrong:Execution failed for task ':app:mergeDebugNativeLibs'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacadeMore than one file was found with OS independent path 'lib/x86/libc++_shared.so'

I followed the steps for setting up the development environment, https://reactnative.dev/docs/environment-setup.

I added 'org.gradle.jvmargs=-Xmx4608m' to the gradle.properties as advised from another fix but it is still not running.

The project runs perfectly on iOS, Xcode but not for Android.

I am using 'compileSdkVersion = 31' in the /android/build.gradle file.

Can someone please help here?

When I install react native app in our folder by using comand "npx react-native init Sarfaraz"

$
0
0

C:\Users\HP\AppData\Roaming\npm\node_modules\react-native-cli\index.js:302cli.init(root, projectName);^

TypeError: cli.init is not a functionat run (C:\Users\HP\AppData\Roaming\npm\node_modules\react-native-cli\index.js:302:7)at createProject (C:\Users\HP\AppData\Roaming\npm\node_modules\react-native-cli\index.js:249:3)at init (C:\Users\HP\AppData\Roaming\npm\node_modules\react-native-cli\index.js:200:5)at Object. (C:\Users\HP\AppData\Roaming\npm\node_modules\react-native-cli\index.js:153:7)at Module._compile (node:internal/modules/cjs/loader:1105:14)at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)at Module.load (node:internal/modules/cjs/loader:981:32)at Function.Module._load (node:internal/modules/cjs/loader:822:12)at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)at node:internal/main/run_main_module:17:47

How to list all Android dependencies from an Expo project?

$
0
0

As most people familiar with Expo are aware, development has been a breeze thanks to its many layers of abstraction.

However, I've hit a wall and need to break out of my Expo bubble. I don't mean ejecting or re-writing the entire app. What I mean is to start gaining awereness of what's going on under the hood. This question specifically refers to dependency management & bundling.

I'm no expert on Android development, but I do have some basics. As far as I understand, dependencies are managed in a Java-like fashion. With concepts like the Java package, and tools like Gradle.

Expo manages dependencies using a NodeJS fashion. With concepts like the package.json and tools like npm/yarn.

When the time comes to build the android binary, Expo does something with the Javascript code & bundles it along several Andriod dependencies required for the project to run.

Therefore, what I need to get is a full list of all the Android native dependencies theresulting binary will include. i.e: com.company.example:identifier:x.y.z

I've used JADX to de-compile a resulting .aab from Expo and while the result is quite insightful, it's missing a reliable manifest listing all the bundled packages. Said manifest might not even exist, as all the bundled packages will probably be included along the rest of the source code, so there's no need to list them separetly. A manifest like that would make most sense before building. It does have an Android Manifest, but that one doesn't list dependencies.

What I did though, is to cd into the de-compiled project and run the command:

grep -rh . -e '^package.\+;' | sort -u > packages.log

The output looks promising, but I'm no expert and I need to be 100% sure before telling my boss. Decompiling isn't always 100% reliable due to some code being impossible to decode.

I've also tried expo prebuild but the resulting gradle files will not list all dependencies directly. Instead they require dependencies defined in a package.json using a weird directive like so:

url(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../android"))

Not sure how to manually execute that directive, or how that gets eventually translated to native android dependencies (i.e com.facebook.react.uimanager).

Please, I need help listing all the Android dependencies for an Expo project and being 100% sure about it.

Automatic Open App When Receiving Push Notification in React Android

$
0
0

How to open automatic App when receiving Push Notification in React Android?

For example, when you receive a call on whatsapp, it opens the automatic app in the foreground.


Unable to receive push notification through expo-notifications in production build Android

$
0
0

The expo push notifications through Firebase configuration was working well for last 1.5 months until 2 days ago, the production build stopped receiving any notifications. On further analysis of this issue, I found that the exponent push token was not being generated by the getExpoPushTokenAsync() method for android platform alone. IOS still works fine. Haven’t touched the code regarding notifications for the last 1.5 months. Don’t know how to fix this as it is an important feature of the app. All the FCM configurations have been done properly. The notifications and expo token generation works in development though, when using the expo go app but just not in production. Need help ASAP!

const registerForPushNotificationsAsync = async () => {let token;if (Device.isDevice) {  const { status: existingStatus } =    await Notification.getPermissionsAsync();  let finalStatus = existingStatus;  if (existingStatus !== "granted") {    const { status } = await Notification.requestPermissionsAsync();    finalStatus = status;  }  if (finalStatus !== "granted") {    return;  }  token = (await Notification.getExpoPushTokenAsync()).data;}if (Platform.OS === "android") {  Notification.setNotificationChannelAsync("default", {    name: "default",    importance: Notification.AndroidImportance.MAX,    vibrationPattern: [0, 250, 250, 250],    lightColor: "#FF231F7C",  });}return token; }; useEffect(() => {// method to check JWT token validity before making API calllet tokenValidity = checkJwtValidity(  jwtToken,  setIsLoggedIn,  setjwtToken,  setUser);if (tokenValidity) {  registerForPushNotificationsAsync().then(async (token) => {    // on receiving of token, making an api call to send to backend so they can push the notification to    the device using the token    const response = await sendDeviceNotificationToken(jwtToken, token);    console.log(response);  });}}, []);

Android PDF font is not readable

$
0
0

I'm using react-native-html-to-pdf to convert HTML to PDF and react-native-pdf to view PDF.

For past few days, some of the Android users reported that the generated PDF is not readable. This image below is one the examples:

enter image description here

To debug this issue, we bought a new android 12 phone. First day the PDF was readable in that phone without any issue. After a while, the PDF became unreadable on the new phone also.

On the other side, there are some android phones are facing this issue "partially". In some android phones if we set the html font-weight:bold the PDF is showing perfectly. But unfortunately it's not working in all the phones.

Phones where font-weight:bold is working:

  1. Redmi
  2. Samsung

Phones where we could not find any solution:

  1. Vivo
  2. Oppo

I'm guessing it's happening maybe because of some Android update. After some digging we found out that both react-native-html-to-pdf and react-native-pdf is using WebView for generating and viewing pdf respectively. Could it be because of some Android WebView update causing this issue? I planned create an issue in those library repositories but I think both of them are not actively maintained.

Any suggestion is appreciated.

Given a stream of background locations, is there a commonly used algorithm to identify if a user stayed in one place long enough to be a visit?

Fetch HTTP Request in React Native Expo

$
0
0

I encountered an error when trying to make a HTTP request using Fetch from Android Emulator in React Native Expo.

enter image description here

enter image description here

It logs this message

enter image description here

The API is working fine in the browser.

Task 'prepareKotlinBuildScriptModel' not found in project ':app'

$
0
0

I am getting this error while gradle sync. This is react native project.enter image description here

Viewing all 29741 articles
Browse latest View live


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