Sunmi V2S - attempt to invoke interface method on null object reference
ryanmitchell opened this issue · comments
Thanks for this package - it looks great.
When I try to use it (through EAS build on Expo) I'm getting:
Attempt to invoke interface method 'void com.sunmi.peripheral.printer.SunmiPrinterService.printText' on a null object reference
Am I missing something? My code is pretty basic:
import SunmiPrinter from '@heasy/react-native-sunmi-printer';
SunmiPrinter.printerText('Hello hello hello');
I haven't used it in Expo, I can't answer it for you, it is recommended not to use Expo
Its not Expo specific - I'm using EAS build which is the same as using Android studio. Its just a different build system but it has complete parity.
Have you ever tried/tested the library on a V2S? What hardware are you using?
@ryanmitchell See the latest document, wait a moment, I will update
@ryanmitchell Please try it with v2
@ryanmitchell Is it ready to use, I'm going to close this.
Struggling to get a build as I cant target the branch - it needs to be a release
Struggling to get a build as I cant target the branch - it needs to be a release
👌
I just tested against 1.6.2 and the build now fails... is not allowed in the manifest element - see:
https://developer.android.com/guide/topics/manifest/manifest-element
Should it maybe be <original-package>
as per: https://android.googlesource.com/platform/frameworks/base/+/master/packages/PackageInstaller/AndroidManifest.xml#5
@ryanmitchell You try again.
@Surile thanks. Unfortunately I'm back to getting the null object reference error so the change doesn't seem to have worked. Do you have any other ideas?
package android:name="woyou.aidlservice.jiuiv5"
You try to put that code in AndroidManifest.xml under Android project
Same error as before - AndroidManifest.xml:37: AAPT: error: <manifest> tag is missing 'package' attribute
- this means <package>
is not valid in AndroidManifest
I saw the Chinese document, the document said that v2 and v2plus need to add this
Can you send the link to the document so I can investigate?
Thanks, I see now, it needs added to queries.
I've got it working - I'll open a PR with the config needed for expo incase anyone else needs it.
Thank you!
Thanks, I see now, it needs added to queries. I've got it working - I'll open a PR with the config needed for expo incase anyone else needs it.
Ok, thank you
I think the best thing might be to add something to the docs:
For Expo users, you need to add a config plugin as follows:
const { withAndroidManifest } = require("@expo/config-plugins")
module.exports = function androiManifestPlugin(config) {
return withAndroidManifest(config, async config => {
let androidManifest = config.modResults.manifest
androidManifest.queries.push({
'package': {
'$': {
'android:name': 'woyou.aidlservice.jiuiv5'
}
}
});
return config
})
}
Add this to a file called android-manifest.plugin.js in your app root, then add a reference to this file your expo.plugins array in app.json... eg.
"plugins": [
"./android-manifest.plugin.js"
]
Hello guys,
I see that you have solved this issue of V2s for EAS, but what about Android build? Is there any opportunity to make it work?
Thanks
Hello guys,
I see that you have solved this issue of V2s for EAS, but what about Android build? Is there any opportunity to make it work?
Thanks
it should be ok
Yes, it works now. Thanks
Hey @ryanmitchell we are trying to use this lib with Sunmi V2s
But got this error as @MnaveedS said
Can you please share with us your Gradle files and other stuff to make this works with V2s
I use expo, so dont have grade files to share. My comment above shows how I set it up to work.
Im having the same issue. Tried multiple versions of React-native. V2s and not using EAS or Expo.
Attempt to invoke interface method 'void com.sunmi.peripheral.printer.SunmiPrinterService.printText' on a null object reference