Barcode scanning broken - android

Since the recent update for Codename one any barcode scanning seems to be broken.
On android the camera appears and scans the code but nothing happens when it returns to the app (that is none of the 3 callback functions are triggered).
On iOS the camera window doesn't even appear.
I'm using this library since it doesn't rely on an installed scanning app:
https://github.com/littlemonkeyltd/QRScanner
I had thought the inbuilt scanning functionality may have been removed and passed to this library, so I tried to include that too:
https://github.com/codenameone/cn1-codescan
However it still isn't working on Android. IOS refuses to build with the cn1-codescan library included.
Pretty sure this was all working last week, or the week before.
my code looks like this:
Log.p("Scanning QR code");
QRScanner.scanQRCode(new ScanResult() {
public void scanCompleted(String contents, String formatName, byte[] rawBytes) {
Log.p("QR result:"+contents);
QRResult(contents, formatName, rawBytes);
}
public void scanCanceled() {
Log.p("scan canceled");
}
public void scanError(int errorCode, String message) {
Log.p("error during scan: " + message);
scanFailed();
}
});
edit:
Here are the android build hints added to codenameone_setting.properties when I add the libraries in:
codename1.arg.android.xapplication=<activity android\:name\="com.dm.zbar.android.scanner.ZBarScannerActivity" android\:screenOrientation\="landscape" android\:label\="#string/app_name" />
codename1.arg.android.xpermissions=<uses-permission android\:name\="android.permission.CAMERA"/><uses-feature android\:name\="android.hardware.camera" android\:required\="false"/>
codename1.arg.android.proguardKeep=\ -keep class net.sourceforge.zbar.** {*;}

If you build against the "latest" barcode scanning should work. I'm assuming that you built against 3.5 and not the latest. It's possible that the regression in barcode scanning got into 3.5, this we verified that barcode/qr code scanning works with the latest on the build servers.

Related

Android printing with Brother SDK via WiFi throws ERROR_WRONG_LABEL despite selecting correct labelNameIndex

I've been trying to print with Brother Print SDK 3.5.1 on Android 8.1.0. I keep getting ERROR_WRONG_LABEL.
This is the code I use
void printPdf() {
// Specify printer
final Printer printer = new Printer();
PrinterInfo settings = printer.getPrinterInfo();
settings.printerModel = PrinterInfo.Model.QL_810W;
settings.port = PrinterInfo.Port.NET;
settings.ipAddress = "192.168.1.73";
settings.workPath = "storage/emulated/0/Download/";
// Print Settings
settings.labelNameIndex = LabelInfo.QL700.W62RB.ordinal();
settings.printMode = PrinterInfo.PrintMode.FIT_TO_PAGE;
settings.orientation = PrinterInfo.Orientation.PORTRAIT;
settings.isAutoCut = true;
printer.setPrinterInfo(settings);
// Connect, then print
new Thread(new Runnable() {
#Override
public void run() {
if (printer.startCommunication()) {
PrinterStatus result = printer.printPdfFile("/storage/emulated/0/Download/hello world red.pdf", 1);
if (result.errorCode != PrinterInfo.ErrorCode.ERROR_NONE) {
Log.d("TAG", "ERROR - " + result.errorCode);
}
printer.endCommunication();
}
}
}).start();
}
My printer model is QL-810W and I use the black and red W62 roll.
I've tried the Sample Application, where setting W62RB in labelNameIndex prints fine.
Changing the roll for different one with different width didn't help.
I've also tried iterating over numbers 0 to 50 and using them as labelNameIndex.
Based on this thread, I thought that the issue may be in specifying the workPath attribute. Setting workPath to getContext().getCacheDir().getPath() results in ERROR_OUT_OF_MEMORY instead of ERROR_WRONG_LABEL. Not specifying workPath and adding <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> to AndroidManifest.xml results in ERROR_WRONG_LABEL
EDIT
I've modified the Brother Sample app and uploaded it to GitHub. The app now launches Activity_PrintPdf.java by default where I inserted my printing code with hardcoded values at the beginning of onCreate method - this works fine and prints the PDF file as expected.
Then I created a new Empty Activity project in Android Studio, copy pasted the library, added the imports to build.gradle and copy pasted the permissions into AndroidManifest.xml. Then I copy pasted the printing code at the beginning of onCreate method in MainActivity.java. Running the app results in ERROR_WRONG_LABEL.
This is the modified working example app and this is the one that results in the error. I want to use the code as native module that I call from my React Native app, so it's important that I manage to set up the printing code from scratch rather than modifying the existing example app.
EDIT 2
I've inspected the library with a debugger: when executing printer.setPrinterInfo(mPrinterInfo) the library internally calls private boolean createWorkPath(String dirPath) of Printer object. On return from this method, the debugger shows Source code doesn't match the bytecode and seems to forget the created directory. This also internally sets mResult.errorCode = ErrorCode.ERROR_WORKPATH_NOT_SET. However, instead of rising any error here the code just silently proceeds, which later results in ERROR_WRONG_LABEL when trying to print. Running the same code snipper in the modified Sample app works fine.
I'd be grateful if you could help or suggest what to try next.
Thank you!
I've now fixed the issue, which was that the Brother library silently failed to create a temporarily folder and instead of reporting an error, it continued and failed later to read the label information. Based on this thread, it is now required to specify runtime file read and write permissions as opposed to the compile-time ones in AndroidManifest.xml.
Adding
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},1);
at the beginning of onCreate before the printing code fixed the issue.

AppsFlyer SDK Integration Test failed on app, but non-organic test data is reflected on the Dashboard

Trying to integrate the AppsFlyer SDK for Android, I've followed all the steps indicated in the AppsFlyer guide. Initially, the dependency that was stated is:
implementation 'com.appsflyer:af-android-sdk:4+#aar'
But for some reason, it wasn't pointing to the latest version on it's own, making the init() version not visible. And so I instead went ahead and adjusted it to version 4.8.15 (currently the latest version), which worked as expected in the guide.
After adding the required permissions (with the optional permission) and the BroadcastReceiver (I don't have any other receivers for the referrer so I only used the SingleInstallBroadcastReceiver), I implemented the initialization on the app's Application class like so:
public class MyApp extends Application {
private static final String AF_DEV_KEY = "DEV_KEY_FROM_CONSOLE_HERE";
#Override
public void onCreate() {
super.onCreate()
initAppsFlyer();
}
public void initAppsFlyer() {
final AppsFlyerConversionListener listener = new AppsFlyerConversionListener() {
#Override
public void onInstallConversionDataLoaded(Map<String, String> conversionData) {
}
#Override
public void onInstallConversionFailure(String errorMessage) {
}
#Override
public void onAppOpenAttribution(Map<String, String> attributionData) {
}
#Override
public void onAttributionFailure(String errorMessage) {
}
};
AppsFlyerLib.getInstance().init(AF_DEV_KEY, listener, this);
AppsFlyerLib.getInstance().startTracking(this);
}
}
The manifest is pointing to the MyApp application class for sure. So that's it. The initial setup is complete. Time for the SDK Integration test as per the guide.
So I installed the app directly from Android Studio to my device, downloaded SDK Integration test app, whitelisted the device, and selected the name of the app as mentioned in the test guide. Every step followed accordingly.
Clicked on SDK Integration Testing...
Checking configuration...
Testing your app..
*app opens*
*closes*
*opens again*
Testing your app..
Checking configuration...
..
X Oops..
This app can not be monitored. Please make sure that:
You are using a supported AppsFlyer SDK version.
AppsFyler's BroadcastReceiver is configured.
startTracking() is placed in the MainActivity
It's the latest version. So it should work.
Copy pasted the receiver. Tried removing it and then re-run the test, it showed the missing receiver error. Pasted it back in.
I'm calling startTracking() in the actual application class. But what the heck. I gave it a try, called it in the MainActivity.onCreate() same result.
I have no idea what is causing the failure in the test. Not much to go on from as well since there's no details on how to debug it further. However, I checked the Dashboard, and there it is. Non-Organic install data counted.
Now I'm confused. Is there an issue with the integration or with the SDK integration test app?

Xamarin Forms QR code scanner blank screen

I have a Xamarin Forms 2.0 application that uses ZXing.Net.Mobile and ZXing.Net.Mobile.Forms version 2.0.3.1. I'm trying to build a simple QR code scanner, but whenever I launch the ZXingScannerPage on Android I can see the default overlay (with the text and the red line) but I don't see the output of the camera so I can't actually scan anything. I have already listed the Camera permission in my AndroidManifest:
<uses-permission android:name="android.permission.CAMERA" />
I tried the sample code from the readme: https://github.com/Redth/ZXing.Net.Mobile as well as from their Samples/Forms project. I now have this code:
private async void OnScanQrClicked(object sender, EventArgs e)
{
_scannerPage = new ZXingScannerPage();
_scannerPage.OnScanResult += HandleScanResult;
await Navigation.PushAsync(_scannerPage);
}
private void HandleScanResult(Result result)
{
_scannerPage.IsScanning = false;
Device.BeginInvokeOnMainThread(() =>
{
Navigation.PopAsync();
DisplayAlert("Scanned code", result.Text, "OK");
});
}
Some more specs: I'm running Android 5.1 on a Moto G (v1).
Why am I not seeing the output of the camera?
I fixed it by getting rid of ZXing.Net.Mobile.Forms and downgrading ZXing.Net.Mobile from 2.0 to 1.5. I had to change my implementation, but that was relatively easy.
Another thing people may look at in the future (I didn't try it) is adding the flashlight permission: https://github.com/Redth/ZXing.Net.Mobile/issues/227.

Chartboost Interstitial won't show Ads on Unity

Lately, I have been trying to add static interstitial ads into my Unity game. For some reason, I could not get the system to show anything, or even react to me. After trying to work with the base Chartboost plugin, I tried to match a tutorial that I was following and purchased Prime31's Chartboost plugin and have been using that. However, neither the base plugin, nor Prime31's plugin, seem to be allowing me to show any ads. The code is pretty much done inside a single object, and it seems simple enough.
public class Advertisement : MonoBehaviour {
public string chartboostAppID = "5461129ec909a61e38b1505b";
public string chartboostAppSignature = "672b3b34e3e358e7a003789ddc36bd2bc49ea3b5";
// Use this for initialization
void Start () {
DontDestroyOnLoad(this.gameObject);
ChartboostAndroid.init (chartboostAppID, chartboostAppSignature, true);
ChartboostAndroid.cacheInterstitial(null);
}
void OnLevelWasLoaded(int level) {
ChartboostAndroid.cacheInterstitial(null);
if(Application.loadedLevelName == "Network Lobby") {
showAds();
}
}
public static void showAds() {
Debug.Log("Showing ad");
ChartboostAndroid.showInterstitial(null);
}
}
As you can see, it's pretty straightforward. This object is created at the game's splash screen, which appears only once, and it's never destroyed until the program ends. The goal is, whenever I enter the lobby scene, I want to see an ad before going to the lobby's menus. As it is, I do see the log printing "Showing ad", so I know the function is being called. However, nothing appears. Do I need to disable the GUI system first? Is there a step I'm missing?
I have already performed the following steps:
I have created and registered the app with chartboost, as well as double and triple checked the AppID and App Signature.
I have created a publishing campaign and registered it to the app.
I double-checked the orientation and confirmed that it's correct.
I registered this specific device as a test device.
The tutorial showed a call to ChartBoostAndroid.OnStart(), but there was no function like that for me to call. Perhaps that is from an older version?
I emailed Chartboost support and have not heard from them yet. I do not have that much time on this project, so if anyone can offer help, I'd appreciate it.

Weird behaviour in Barcode Scanner (Android)

I am developing an Android application and I am currently having some troubles running Barcode Scanner (Zxing). I'm using Zxing as a "library project" in Eclipse.
I built Zxing core project with Ant, created my Zxing android project by importing sources in Eclipse and ticking the "Is Library" box. (That project uses the "core.jar" in its dependencies.)
Then I have my main project, which uses the Zxing library project, that project, uses the "core.jar" too.
So, here is the problem, when I run my application and start my Barcode Scanner Intent,
here is what I see on the screen :
http://imageshack.us/photo/my-images/52/screenbarcodescanner.png/
(I am sorry but I don't have enough reputation to post my screen here)
The strange thing is that it seems to recognize some things when I put my hand in front of the camera or some barcode, QR Code (it doesn't scan, but there are some green dots appearing on the red line, you know, it is a bit hard to aim the code without seeing anything on the screen ;) )
Finally, here is the way I am calling the Intent and managing the result, the basic way, as it is written on the Zxing Google code page :
#Override
public void onClick(View sender)
{
if(sender.equals(_scan_button))
{
startActivityForResult(new Intent("com.google.zxing.client.android.SCAN"), 0);
}
// ...
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
//String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
// ...handle the result
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}
I don't actually provide the code format to the Intent because I want it to scan any code format.
Last thing I can say, is that, before doing this with Zxing as a library project, I was using just as a "project dependency", that way, Zxing apk was installed on my phone if not installed, before running the main project. All was working very well, now it is embedded,...I'm stuck and I don't really why or what I am missing.
Thank you for your answers !
You're mixed up here. If you integrate by Intent, you do not need any code from Barcode Scanner. In the project, all you may need is the small bit of integration code you find in android-integration. This ought to solve your problem.

Categories

Resources