chariotsolutions phonegap-nfc plugin rebooting on scan - android

I am using PhoneGap build and the chariotsolutions NFC plugin to scan NFC cards, and it was working. However, it started failing after PhoneGap build went down. I can only guess that PhoneGap build is now using a newer version of the plugin. A clean build still makes it crash internally on scan of a card.
I created a new Cordova project with the latest build using the cordova CLI, and installed the chariotsolutions plugin. It is still failing with only the bear bones project, which is outside of PhoneGap build now.
Hardware and software: Android Nexus 7 running Android 4.4.2
Cordova version 3.3
Bear bones project code contains only this onDeviceReady:
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
console.log('v0.0.3');
document.addEventListener('resume', app.resume, false);
document.addEventListener('pause', app.pause, false);
// Read NDEF formatted NFC Tags
nfc.addNdefListener (
function (nfcEvent) {
console.log('nfcEvent '+JSON.stringify(nfcEvent));
var tag = nfcEvent.tag,
ndefMessage = tag.ndefMessage;
// dump the raw json of the message
// note: real code will need to decode
// the payload from each record
console.log(JSON.stringify(ndefMessage));
// assuming the first record in the message has
// a payload that can be converted to a string.
console.log(nfc.bytesToString(ndefMessage[0].payload).substring(3));
},
function () { // success callback
console.log("Waiting for NDEF tag");
},
function (error) { // error callback
console.log("Error adding NDEF listener " + JSON.stringify(error));
}
);
},
ADB output on launch of the app:
I/ActivityManager( 512): Start proc com.test.myapp for activity com.test.myapp/.myappname: pid=17325 uid=10037 gids={50037, 3003}
I/CordovaLog(17325): Changing log level to DEBUG(3)
I/CordovaLog(17325): Found start page location: index.html
D/Whitelist(17325): Unlimited access to network resources
D/CordovaActivity(17325): CordovaActivity.onCreate()
V/WebViewChromium(17325): Binding Chromium to the background looper Looper (main, tid 1) {4211c938}
I/chromium(17325): [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
I/BrowserProcessMain(17325): Initializing chromium process, renderers=0
W/chromium(17325): [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
D/libEGL (17325): loaded /system/lib/egl/libEGL_tegra.so
D/libEGL (17325): loaded /system/lib/egl/libGLESv1_CM_tegra.so
D/libEGL (17325): loaded /system/lib/egl/libGLESv2_tegra.so
D/CordovaWebView(17325): CordovaWebView is running on device made by: asus
D/JsMessageQueue(17325): Set native->JS mode to 2
D/CordovaActivity(17325): CordovaActivity.init()
D/CordovaWebView(17325): >>> loadUrl(file:///android_asset/www/index.html)
D/PluginManager(17325): init()
D/CordovaWebView(17325): >>> loadUrlNow()
I/CordovaLog(17325): Changing log level to DEBUG(3)
I/CordovaLog(17325): Found start page location: index.html
D/Whitelist(17325): Unlimited access to network resources
D/CordovaActivity(17325): Resuming the App
D/CordovaActivity(17325): CB-3064: The errorUrl is null
D/SoftKeyboardDetect(17325): Ignore this event
D/OpenGLRenderer(17325): Enabling debug mode 0
D/SoftKeyboardDetect(17325): Ignore this event
I/ActivityManager( 512): Displayed com.test.myapp/.myappname: +813ms
D/AndroidRuntime(17309): Shutting down VM
D/dalvikvm(17309): GC_CONCURRENT freed 97K, 15% free 589K/688K, paused 0ms+2ms, total 5ms
D/CordovaActivity(17325): onMessage(onPageStarted,file:///android_asset/www/index.html)
D/CordovaLog(17325): file:///android_asset/www/index.html: Line 25 : Viewport target-densitydpi is not supported.
I/chromium(17325): [INFO:CONSOLE(25)] "Viewport target-densitydpi is not supported.", source: file:///android_asset/www/index.html (25)
D/CordovaWebViewClient(17325): onPageFinished(file:///android_asset/www/index.html)
D/CordovaActivity(17325): onMessage(onPageFinished,file:///android_asset/www/index.html)
D/CordovaActivity(17325): onMessage(spinner,stop)
D/CordovaNetworkManager(17325): Connection Type: wifi
I/chromium(17325): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
I/chromium(17325): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
D/CordovaNetworkManager(17325): Connection Type: wifi
D/CordovaActivity(17325): onMessage(networkconnection,wifi)
D/CordovaLog(17325): file:///android_asset/www/js/index.js: Line 58 : onDeviceReady v0.0.3
I/chromium(17325): [INFO:CONSOLE(58)] "onDeviceReady v0.0.3", source: file:///android_asset/www/js/index.js (58)
D/NfcPlugin(17325): execute registerNdef
D/CordovaLog(17325): file:///android_asset/www/js/index.js: Line 83 : Waiting for NDEF tag
I/chromium(17325): [INFO:CONSOLE(83)] "Waiting for NDEF tag", source: file:///android_asset/www/js/index.js (83)
D/NfcPlugin(17325): execute init
D/NfcPlugin(17325): Enabling plugin Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.test.myapp/.myappname }
D/NfcDispatcher( 769): Set Foreground Dispatch
D/NfcPlugin(17325): parseMessage Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.test.myapp/.myappname }
D/NfcPlugin(17325): action android.intent.action.MAIN
D/CordovaLog(17325): file:///android_asset/www/plugins/com.chariotsolutions.nfc.plugin/www/phonegap-nfc.js: Line 18 : Initialized the NfcPlugin
I/chromium(17325): [INFO:CONSOLE(18)] "Initialized the NfcPlugin", source: file:///android_asset/www/plugins/com.chariotsolutions.nfc.plugin/www/phonegap-nfc.js (18)
D/CordovaActivity(17325): onMessage(spinner,stop)
ADB output when I scan a card. Seems to pause the app at matched single TECH for some reason, and then reloads Cordova running the onDeviceReady again.
D/NativeNfcTag( 769): Check NDEF Failed - status = 255
D/NativeNfcTag( 769): Check NDEF Failed - status = 255
D/NfcDispatcher( 769): dispatch tag: TAG: Tech [android.nfc.tech.MifareClassic, android.nfc.tech.NfcA, android.nfc.tech.NdefFormatable] message: null
I/ActivityManager( 512): START u0 {flg=0x10008000 cmp=com.android.nfc/.NfcRootActivity (has extras)} from pid 769
D/dalvikvm( 512): GC_FOR_ALLOC freed 564K, 15% free 18611K/21744K, paused 145ms, total 145ms
D/dalvikvm( 512): GC_FOR_ALLOC freed 283K, 15% free 18573K/21744K, paused 144ms, total 144ms
I/NfcDispatcher( 769): matched single TECH
D/CordovaActivity(17325): Paused the application!
D/CordovaWebView(17325): Handle the pause
D/NfcPlugin(17325): onPause Intent { }
D/NfcPlugin(17325): stopNfc
D/NfcDispatcher( 769): Set Foreground Dispatch
D/CordovaLog(17325): file:///android_asset/www/js/index.js: Line 48 : -- pause event fired --
I/chromium(17325): [INFO:CONSOLE(48)] "-- pause event fired -- ", source: file:///android_asset/www/js/index.js (48)
I/ActivityManager( 512): START u0 {act=android.nfc.action.TECH_DISCOVERED cmp=com.widgapp.NFC_ReTAG_FREE/com.widgapp.NFC_ReTag_dispatch_other (has extras)} from pid 769
V/receiver Tag discovered: (15520): TAG: Tech [android.nfc.tech.MifareClassic, android.nfc.tech.NfcA, android.nfc.tech.NdefFormatable] mifare tagid: 8A0924F9
I/ActivityManager( 512): START u0 {flg=0x4000000 cmp=com.widgapp.NFC_ReTAG_FREE/.automode (has extras)} from pid 15520
D/NfcDispatcher( 769): Set Foreground Dispatch
D/NfcDispatcher( 769): Set Foreground Dispatch
D/dalvikvm(15520): GC_CONCURRENT freed 224K, 4% free 7810K/8072K, paused 4ms+3ms, total 42ms
W/InputMethodManagerService( 512): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#429d7908 attribute=null, token = android.os.BinderProxy#427e6bf8
I/CordovaLog(17325): Changing log level to DEBUG(3)
I/CordovaLog(17325): Found start page location: index.html
D/Whitelist(17325): Unlimited access to network resources
D/CordovaActivity(17325): Resuming the App
D/CordovaActivity(17325): CB-3064: The errorUrl is null
D/NfcPlugin(17325): onResume Intent { }
D/NfcDispatcher( 769): Set Foreground Dispatch
D/CordovaLog(17325): file:///android_asset/www/js/index.js: Line 41 : -- resume event fired --
I/chromium(17325): [INFO:CONSOLE(41)] "-- resume event fired -- ", source: file:///android_asset/www/js/index.js (41)
D/NativeNfcTag( 769): Tag lost, restarting polling loop
D/dalvikvm(15037): GC_CONCURRENT freed 475K, 7% free 8271K/8824K, paused 3ms+4ms, total 40ms
D/dalvikvm(15037): WAIT_FOR_CONCURRENT_GC blocked 30ms
D/Finsky (15037): [1] 5.onFinished: Installation state replication succeeded.
Any help would be appreciated.

The reason it's not working is because the application is looking for an NDEF tag, but you're scanning a non-NDEF tag.
D/NativeNfcTag( 769): Check NDEF Failed - status = 255
D/NativeNfcTag( 769): Check NDEF Failed - status = 255
D/NfcDispatcher( 769): dispatch tag: TAG: Tech [android.nfc.tech.MifareClassic, android.nfc.tech.NfcA, android.nfc.tech.NdefFormatable] message: null
To read a non-NDEF tag, you'll need to add nfc.addNdefFormatableListener or nfc.addTagDiscoveredListener. You can use one event handler, e.g. app.onNFC, for multiple tag types.
You could also use NXP Tag Writer to write a message to the tag, which will also format it as NDEF.
Note that devices with the Broadcom NFC chipset won't read Mifare Classic tags, so you might get errors about non-NDEF messages even when reading a NDEF message on a Mifare Classic tag.
My Nexus 7 (original version) has the NXP NFC chipset. Your code worked, after I removed console.log('nfcEvent '+JSON.stringify(nfcEvent));. The event can't be stringified because of circular references. I think the second generation Nexus 7 uses the Broadcom NFC chipset.

Related

Android M API 23 emulator Unfortunately, browser has stopped

I am trying to launch browser on Android M Emulator. It keeps on crashing on every launch.
10-14 13:34:12.934: I/ActivityManager(1294): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 pkg=com.android.browser cmp=com.android.browser/.BrowserActivity bnds=[372,692][460,800] (has extras)} from uid 10007 on display 0
10-14 13:34:13.046: I/ActivityManager(1294): Start proc 5514:com.android.browser/u0a17 for activity com.android.browser/.BrowserActivity
10-14 13:34:13.131: W/System(5514): ClassLoader referenced unknown path: /system/app/Browser/lib/x86
10-14 13:34:13.451: E/chromium(5514): [ERROR:browser_main_loop.cc(698)] GLSurface::InitializeOneOff failed
10-14 13:34:13.591: D/WebViewTimersControl(5514): onBrowserActivityResume
10-14 13:34:13.591: D/WebViewTimersControl(5514): Resuming webview timers, view=com.android.browser.BrowserWebView{2900a61 VFEDHVC.. ......I. 0,0-0,0}
10-14 13:34:13.861: I/ActivityManager(1294): Displayed com.android.browser/.BrowserActivity: +833ms
10-14 13:34:14.377: A/DEBUG(962): pid: 5514, tid: 5559, name: GpuThread >>> com.android.browser <<<
10-14 13:34:14.500: I/WindowState(1294): WIN DEATH: Window{bd73c76 u0 com.android.browser/com.android.browser.BrowserActivity}
10-14 13:34:14.556: I/ActivityManager(1294): Process com.android.browser (pid 5514) has died
10-14 13:34:14.560: W/ActivityManager(1294): Force removing ActivityRecord{1b3e625 u0 com.android.browser/.BrowserActivity t25}: app died, no saved state
Settings -> Apps -> Browser. then goto permission and enable storage permission to be enabled.because the storage permission is closed default.Just open it!
Edit the Android Virtual Device settings inside you AVD manager that you are using and try starting your emulator with the "Use Host GPU" option enabled, this will help to fix your error with the browser.
For downloading files with the browser make sure you also add enough size to your SD Card option. After editing both settings, start Android and goto: Settings -> Apps -> Browser.
(If needed force to stop the browser) then goto permission and enable storage permission to be enabled. This will fix your error with the browser when downloading files.

Debugging on phone

I have an app that I have been using for a long while now. It's open source and fell out of development. I started modifying it when it broke and it worked fine on my Epic Touch. I recently picked up the Sprint Note 2 and installed it. It forced closed on me. I decided "OK lets see whats going on and why its FCing". I ran it in an emulator 4.1.2 and it worked fine. When I tried to debug it in eclipse using the real phone my logcat showed problems and never loaded:
D/dalvikvm( 1032): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 1032): Note: class Landroid/app/ActivityManagerNative; has 153 ulemented (abstract) methods
D/AndroidRuntime( 1032): Calling main entry com.android.commands.pm.Pm
W/zipro (30332): Unable to open zip '/data/local/tmp/BalanceWidget.apk': Permission denied
D/asset (30332): failed to open Zip archive '/data/local/tmp/BalanceWidget'
I/ApplicationPolicy( 2487): isApplicationInstallationEnabled
W/zipro (30332): Unable to open zip '/data/local/tmp/BalanceWidget.apk': Permission denied
D/asset (30332): failed to open Zip archive '/data/local/tmp/BalanceWidget'
D/dalvikvm( 2487): WAIT_FOR_CONCURRENT_GC blocked 0ms
W/DefContainer(30332): Failed to parse package
W/PackageManager( 2487): verifying app can be installed or not
W/DefContainer(30332): Failed to parse package
D/dalvikvm( 2487): GC_EXPLICIT freed 329K, 14% free 44856K/51591K, paused 4ms, total 96ms
D/AndroidRuntime( 1032): Shutting down VM
D/dalvikvm( 1032): GC_CONCURRENT freed 128K, 87% free 568K/4096K, paused 0ms, total 2ms
D/jdwp ( 1032): Got wake-up signal, bailing out of select
I tried wiping the cache, chmoding the folders, but nothing worked. I changed to a different project to see if it was that project but it did the same thing.
Does anyone have any ideas on what the problem could be and how to fix it?
My phone:
Rooted Stock Sprint Note 2
L900VPALJC
OS Running - Android 4.1.1
Thanks

whats the significance of /dev/log/main and /dev/log/system in android logcat?

I usually get these two lines when i type adb lolcat in command line
--------- beginning of /dev/log/main
D/dalvikvm( 2586): GC_CONCURRENT freed 651K, 7% free 12236K/13063K, paused 7ms+4ms
D/dalvikvm( 2586): GREF has increased to 201
W/AudioHardwareALSA( 2071): badstate and do recovery.....
--------- beginning of /dev/log/system
I/ActivityManager( 2159): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.mms/.ui.ConversationList bnds=[909,207][1011,300]} from pid 2586
What is the significance of these two things in logcat output, anything important it signifies ?Thank You
http://elinux.org/Android_Logging_System says:
The system log was created to keep system messages in a separate buffer (outside of '/dev/log/main') so that a single verbose application couldn't overrun system messages and cause them to be lost.
you can write a log directly by write to /dev/log/main as below:
$ printf "\5TagName\0Your Text Log\n" > /dev/log/main
the \5 means ANDROID_LOG_WARN for other log level use these:
typedef enum android_LogPriority {
ANDROID_LOG_UNKNOWN = 0,
ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
ANDROID_LOG_VERBOSE,
ANDROID_LOG_DEBUG,
ANDROID_LOG_INFO,
ANDROID_LOG_WARN,
ANDROID_LOG_ERROR,
ANDROID_LOG_FATAL,
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
} android_LogPriority;
for more information see below source files log, logd_write, writev, logprint and android.googlesource.com

INSTALL_FAILED_DEXOPT error when installing stock ICS Launcher on Samsung Galaxy S3

I have a Samsung Galaxy S3 and I've built the stock AOSP ICS Launcher2 app. I then tried to install the apk via "adb install" but I get an "INSTALL_FAILED_DEXOPT" error when I do that. The device logcat is as follows:
D/AndroidRuntime( 5431):
D/AndroidRuntime( 5431): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 5431): CheckJNI is OFF
D/AndroidRuntime( 5431): setted country_code = France
D/AndroidRuntime( 5431): setted countryiso_code = FR
D/AndroidRuntime( 5431): setted sales_code = XEF
D/AndroidRuntime( 5431): readGMSProperty: start
D/AndroidRuntime( 5431): readGMSProperty: already setted!!
D/AndroidRuntime( 5431): readGMSProperty: end
D/LibQmg_native( 5431): register_android_app_LibQmg
D/AndroidRuntime( 5431): Calling main entry com.android.commands.pm.Pm
W/PackageManager( 2093): verifying app can be installed or not
I/ApplicationPolicy( 2093): isApplicationInstallationEnabled
D/dalvikvm( 2093): GC_CONCURRENT freed 7885K, 31% free 32346K/46791K, paused 2ms+6ms
D/dalvikvm( 2093): GC_CONCURRENT freed 1834K, 31% free 32555K/46791K, paused 3ms+5ms
E/PackageManager( 2093): Package XXX.XXXXXXX.XXXXXXXX has mismatched uid: 10130 on disk, 10131 in settings
I/PackageManager( 2093): Running dexopt on: XXX.XXXXXXX.XXXXXXXX
I/PackageManager( 2093): Linking native library dir for |XXXX|XXX|XXXXXXXXXXXXXXXXXXXXXX.XXX
W/dalvikvm( 5442): DexOptZ: zip archive '/data/app/com.android.launcher-1.apk' does not include classes.dex
W/installd( 1907): DexInv: --- END '/data/app/com.android.launcher-1.apk' --- status=0xff00, process failed
E/installd( 1907): dexopt failed on '/data/dalvik-cache/data#app#com.android.launcher-1.apk#classes.dex' res = 65280
W/PackageManager( 2093): Package couldn't be installed in /data/app/com.android.launcher-1.apk
What could I have done wrong?
Thanks.
You need to increase the Android emulator's memory capacity, there are 2 ways for that:
1- Right click the root of your Android Project, go to "Run As" then go to "Run Configurations..." locate the "Android Application" node in the tree at the left, then select your project and go to the "Target" tab on the right side of the window look down for the "Additional Emulator Command Line Options" field (sometimes you'll need to make the window larger) and finally paste "-partition-size 1024" there. Click Apply and then Run to use your emulator.
2- Go to Eclipse's Preferences, then Select “Launch” Add “-partition-size 1024” on the “Default emulator option” field, then click “Apply” and use your emulator as usual.

Which port android app is using

My wifi works through proxy, so I am using rooted phone with asproxy to connect to the internet.
most of the apps use standard ports (that's my belief), but some uses special ports like play.google.com uses 5228 to connect.
is there a way to know which port my other apps are using (probably to listen) example mighty text so i can configure them in asproxy. I have tried logcat but i doesnot give much details.
logcat extract:
W/com.Alsu.ASProxy( 757): Network connected, starting
> D/WifiWatchdogService( 251): (android.server.ServerThread) wi-fi
> (.f....) does not require the watchdog D/Tethering( 251):
> MasterInitialState.processMessage what=3 D/GTalkService( 2257): #####
> Network broadcast (connected=true) type=WIFI, state=CONNECTED
> I/MediaUploader( 6574): No need to wake up D/GTalkService( 2257):
> [GTalkConnection.1] ### networkStateChanged: active and curr network
> type/state are the same(1/CONNECTED), ignore D/CMStats ( 6594):
> CONNECTIVITY_ACTION: noConnectivity = false D/CMStats ( 6594):
> CONNECTIVITY_ACTION: starting service D/CMStats ( 6594): User has not
> opted in -- skipping reporting.
> **V/texty ( 5190): Data connection is ON.** D/dalvikvm( 370): GC_CONCURRENT freed 390K, 45% free 3913K/7047K, external 133K/513K,
> paused 4ms+6ms W/KeyCharacterMap( 370): Can't open keycharmap file
> W/KeyCharacterMap( 370): Error loading keycharmap file
> '/system/usr/keychars/europa_keypad0.kcm.bin'.
> hw.keyboards.0.devname='europa_keypad0'

Categories

Resources