-
Notifications
You must be signed in to change notification settings - Fork 10
Description
"react-native": "0.71.3"
Test Android device is Google Pixel 6 (Android 13)
I don't have the c72 device yet, but I want to test it can be work first.
I use sample code will show the error.
If click fun scanSingleTag show error:
Attempt to invoke virtual method 'java.lang.String com.rscja.deviceapi.entity.UHFTAGInfo.getEPC()' on a null object reference
on a null object reference means it can be work ? Or just because I don't have the c72 device for testing ?
Here is part of the code from sample code:
import C72RfidScanner from 'c72-rfid-scanner';
useEffect(() => {
const scanner = C72RfidScanner;
scanner.initializeReader();
scanner.powerListener(powerListener);
scanner.tagListener(tagListener);
return () => scanner.deInitializeReader();
}, []);
const scanSingleTag = async () => {
try {
let result = await C72RfidScanner.readSingleTag();
showAlert('SUCCESS', `The result is ${result}`);
console.log(result);
} catch (error) {
// show object is null error
console.log(error.message);
showAlert('FAILED', error.message);
}
};
return (
<View style={{marginVertical: 20}}>
<Button
style={{margin: 10}}
onPress={() => scanSingleTag()}
title="Read Single Tag"
/>
</View>
);
Here is what I try step flow:
Step1:
Can't install the package.
npm install c72-rfid-scanner --save
It will show error
ERESOLVE unable to resolve dependency tree
Step2:
If use yarn
yarn add c72-rfid-scanner
build the project on Android will show error
Plugin with id 'maven' not found.
then change the code apply plugin: 'maven'
to apply plugin: 'maven-publish'
on node_modules/c72-rfid-scanner/android/build.gradle
build the project will show error
A problem occurred configuring project ':c72-rfid-scanner'.
> Configuration with name 'compile' not found.
Step3:
then paste the code subprojects on android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
}
repositories {
google()
mavenCentral()
}
subprojects { subproject ->
if(project['name'] == 'c72-rfid-scanner'){
project.configurations { compile { } }
}
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.facebook.react:react-native-gradle-plugin")
}
}
build project will show error
Could not find method mavenDeployer() for arguments
Step4:
commented out the code on node_modules/c72-rfid-scanner/android/build.grade
task installArchives(type: Upload) {
configuration = configurations.archives
repositories.mavenDeployer {
// Deploy to react-native-event-bridge/maven, ready to publish to npm
repository url: "file://${projectDir}/../android/maven"
configureReactNativePom pom
}
}
then build the project successfully and test the code.