I am developing an app in which I am implementing google text recognition.
This is the link that I am following :
https://developers.google.com/ml-kit/vision/text-recognition/android
I have done everything described there but still I am getting error.
This is what I have in my gradle file:
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.1.0'
I have these lines too in my manifest file:
<uses-permission android:name="android.permission.INTERNET"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="ocr" />
I am performing a click on a button OCR and then I am calling below lines of code:
InputImage inputImage = InputImage.fromBitmap(bitmap, 0);
TextRecognition.getClient().process(inputImage).addOnSuccessListener(new OnSuccessListener<Text>() {
#Override
public void onSuccess(Text text) {
string = text.getText();
success = true;
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
e.printStackTrace();
success = false;
}
});
Error is thrown as soon as I Click on OCR button.
Following is the stack trace:
W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found.
E/LibraryVersion: Failed to get app version for libraryName: text-recognition
I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0
D/TextNativeHandle: Cannot load feature, fall back to load dynamite module.
W/scanner.camsca: Unsupported class loader
W/scanner.camsca: Skipping duplicate class check due to unsupported classloader
I/DynamiteModule: Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:1
Selected remote version of com.google.android.gms.vision.ocr, version >= 1
V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
I/DynamiteLoaderV2: [71] VisionOcr.optional
W/scanner.camsca: Unsupported class loader
I/native: start_ocr_856638336_langid.cc:33 StartOcr with label: latin_script_gmvapi_android
jni_helper.cc:115 Loading model config /data/user/0/com.scanner.camscan/cache/vision/ocr/data/models/semanticlift_rpn_lstm_engine_tfmini.bincfg
I/native: region_proposal_text_detector.cc:1976 Compute manager Max in flight region detector: 1
common_util.h:39 Removing Thread Pool: ocr_region
tensor_detector_client.cc:1643 Compute manager Max in flight detector: 1
I/native: common_util.h:35 Resizing Thread Pool: ocr_det to 4
I/native: tfmini_model_interface.cc:124 Loaded weights from /data/user/0/com.scanner.camscan/cache/vision/ocr/data/models/tfmini_rpn_detector_space_to_depth_gray_quantized_v2_model.data
timer.cc:71 PhotoOcrEngine::Init (detector): 3.72583 ms (elapsed)
assist_recognizer.cc:94 Initializing nugget matcher with /data/user/0/com.scanner.camscan/cache/vision/ocr/data/models/nugget_stats_1.0.dat
I/native: timer.cc:71 PhotoOcrEngine::Init (assist recognizer): 0.262136 ms (elapsed)
I/native: timer.cc:71 LanguageIdMutator: 4.42141 ms (elapsed)
timer.cc:71 BeamSearch::Init (mutator): 4.58203 ms (elapsed)
I/native: common_util.h:35 Resizing Thread Pool: ocr_segm to 4
I/native: tfmini_model_interface.cc:102 Loaded fp16 weights from /data/user/0/com.scanner.camscan/cache/vision/ocr/data/models/tfmini_latin_conv_model.data_fp16
I/native: tfmini_model_interface.cc:102 Loaded fp16 weights from /data/user/0/com.scanner.camscan/cache/vision/ocr/data/models/tfmini_latin_lstm_model.data_fp16
timer.cc:71 PhotoOcrEngine::Init (recognizer): 8.83693 ms (elapsed)
timer.cc:71 Init: 13.0749 ms (elapsed)
I/native: start_ocr_856638336_langid.cc:42 StartOcr success
How can I rectify this error.
Thank you
I have faced a similar problem before.
These are not actual errors. They are just warnings and messages. You can ignore them.
What I guess is, you are putting true in the boolean variable success on onSuccess and false on onFailure and performing further actions based on its value.
Just directly call further methods from onSuccess after string = text.getText();
I have a .NET standard library which is used for the data access layer of my Xamarin Android app.
I have added a reference to the library however when attempting to use part of the library that is making web requests using System.Net.Http the app hangs and I get the following output.
03-01 16:13:22.914 D/Mono ( 1874): Image addref
System.Net.Http[0x7e2f1c7180] -> System.Net.Http.dll[0x7e2f4a2000]: 2
03-01 16:13:22.914 D/Mono ( 1874): Prepared to set up assembly
System.Net.Http' (System.Net.Http.dll)
03-01 16:13:22.914 D/Mono ( 1874): Assembly System.Net.Http[0x7e2f1c7180]
added to domain RootDomain, ref_count=1
03-01 16:13:22.917 D/Mono ( 1874): AOT: image 'System.Net.Http.dll.so'
not found: dlopen failed: library "/data/app/TestRecipeApp.TestRecipeApp-
1/lib/arm64/libaot-System.Net.Http.dll.so" not found
03-01 16:13:22.919 D/Mono ( 1874): AOT: image '/usr/local/lib/mono/aot-
cache/arm64/System.Net.Http.dll.so' not found: dlopen failed: library
"/data/app/TestRecipeApp.TestRecipeApp-1/lib/arm64/libaot-
System.Net.Http.dll.so" not found
03-01 16:13:22.920 D/Mono ( 1874): Config attempting to parse:
'System.Net.Http.dll.config'.
03-01 16:13:22.920 D/Mono ( 1874): Config attempting to parse:
'/usr/local/etc/mono/assemblies/System.Net.Http/System.Net.Http.config'.
03-01 16:13:22.920 D/Mono ( 1874): Assembly Ref addref
netstandard[0x7e2f594c00] -> System.Net.Http[0x7e2f1c7180]: 2
03-01 16:13:22.920 D/Mono ( 1874): Assembly Ref addref
System.Net.Http[0x7e2f1c7180] -> mscorlib[0x7e46b94000]: 14
Loaded assembly: System.Net.Http.dll [External]
Any suggestions would be much appreicxtated as this has taken a whole day of development time and I've still not found a solution.
When db.createUser is called below. The app hangs and does not proceed any further until it eventually crashes. I have tested the createUser function in a console application and it works fine so the problem doesn't seem to be in the class library itself.
class UserPresenter
{
ILoginView loginView;
DatabaseApi db;
public UserPresenter(ILoginView view)
{
this.loginView = view;
db = new DatabaseApi();
}
public void createUser(string email, string password)
{
Android.Util.Log.Error("myError", "In create user");
bool success = db.createUser(email, password);
Console.WriteLine("Success: " + success);
}
}
Cheers.
Migrated our application from 6.2 to 7.0, the mobile web app works great on the phone as well as manually calling the HTTP js adapters. However when exported the apk to a phone, the application starts up but when invoking an adapter for data a 403 error is returned:
{"status":403,"invocationContext":null}
and the only server log:
"POST /SFMobileStudent/authorization/v1/clients/instance HTTP/1.1" 403 64 "-" "WLNativeAPI(bullhead; MMB29Q; Nexus 5X; SDK 23; Android 6.0.1)"
The adapter is doesn't have any security on it either
securityTest="wl_unprotected"
Not sure what we are missing, is there added/required security for 7.0?
Not a whole lot there but you can see the traffic from the device (comcast) to the server. I don't know what any of it means, just sort of repeats. tcpdump packet capture:
removed
LogCat
I/chromium(29279): [INFO:CONSOLE(1082)] "processMessage failed: Message: F09 WLAuthorizationManagerPlugin170261306 {"wlFailureStatus":"UNEXPECTED_ERROR","status":403,"responseText":"\n\n403 Forbidden</title>\n</head>\nForbidden</h1>\nYou don't have permission to access /SFMobileStudent/authorization/v1/clients/instance\non this server.</p>\n\nIBM_HTTP_Server at mobilet.sfcollege.edu Port 443</address>\n</body></html>\n","statusText":"Unexpected errorCode occurred. Please try again."}", source: file:///android_asset/www/default/worklight/cordova.js (1082)
More logCat
W/PluginManager(11209): THREAD WARNING: exec() call to WLAuthorizationManagerPlugin.getClientInstanceIdHeader blocked the main thread for 170ms. Plugin should use CordovaInterface.getThreadPool().
D/dalvikvm(11035): GC_EXPLICIT freed 153K, 39% free 8875K/14500K, paused 2ms+3ms, total 49ms
I/ConvCursor(11035): ConversationCursor caching complete pos=18
E/ThermalDaemon( 356): set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
E/ThermalDaemon( 356): set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
D/dalvikvm(11209): Trying to load lib /data/app-lib/com.SFStudent-1/libauthjni.so 0x41d12ef8
D/dalvikvm(11209): Shared lib '/data/app-lib/com.SFStudent-1/libauthjni.so' already loaded in same CL 0x41d12ef8
D/WifiStateMachine( 917): handleMessage: E msg.what=151572
D/WifiStateMachine( 917): processMsg: ConnectedState
D/WifiStateMachine( 917): processMsg: L2ConnectedState
D/WifiStateMachine( 917): handleMessage: X
D/WifiWatchdogStateMachine( 917): Fetch RSSI succeed, rssi=-68 mrssi=-68 txbad=245 txgood=47234
D/WifiWatchdogStateMachine( 917): Incremental loss=0/6 Current loss=0% volume=10.06
D/WifiWatchdogStateMachine( 917): Cache updated: loss[-68]=0% volume=27.82
D/dalvikvm(11209): GC_CONCURRENT freed 2032K, 45% free 8070K/14500K, paused 4ms+2ms, total 57ms
D/dalvikvm(11209): WAIT_FOR_CONCURRENT_GC blocked 8ms
W/PluginManager(11209): THREAD WARNING: exec() call to WLAuthorizationManagerPlugin.deleteAllAuthData blocked the main thread for 27ms. Plugin should use CordovaInterface.getThreadPool().
W/PluginManager(11209): THREAD WARNING: exec() call to WLAuthorizationManagerPlugin.getClientInstanceIdHeader blocked the main thread for 97ms. Plugin should use CordovaInterface.getThreadPool().
D/dalvikvm(11209): Trying to load lib /data/app-lib/com.SFStudent-1/libauthjni.so 0x41d12ef8
D/dalvikvm(11209): Shared lib '/data/app-lib/com.SFStudent-1/libauthjni.so' already loaded in same CL 0x41d12ef8
E/NONE (11209): [/apps/services/api/SFStudent/android/query] failure. state: 403, response: undefined
I/chromium(11209): [INFO:CONSOLE(301)] "Error in Error callbackId: WLAuthorizationManagerPlugin1867260175 : ReferenceError: deferred is not defined", source: file:///android_asset/www/default/worklight/cordova.js (301)
I/chromium(11209): [INFO:CONSOLE(1080)] "processMessage failed: Error: ReferenceError: deferred is not defined", source: file:///android_asset/www/default/worklight/cordova.js (1080)
I/chromium(11209): [INFO:CONSOLE(1081)] "processMessage failed: Stack: ReferenceError: deferred is not defined
I/chromium(11209): at Object.InitializeService.WL.Client.invokeProcedure.onFailure (eval at (file:///android_asset/www/default/js/libs/jquery/jquery-min.js:4:14070), :15:8)
I/chromium(11209): at Object.options.onFailure (file:///android_asset/www/default/worklight/worklight.js:8806:29)
I/chromium(11209): at Object.onInvokeProcedureFailure [as onFailure] (file:///android_asset/www/default/worklight/worklight.js:8718:14)
I/chromium(11209): at klass.window.WLJSX.Ajax.WLRequest.WLJSX.Class.create.onFailure (file:///android_asset/www/default/worklight/worklight.js:3651:26)
I/chromium(11209): at klass.window.WLJSX.Ajax.WLRequest.WLJSX.Class.create.onWlFailure (file:///android_asset/www/default/worklight/worklight.js:3600:12)
I/chromium(11209): at Object. (file:///android_asset/www/default/worklight/worklight.js:3440:27)
I/chromium(11209): at Object. (file:///android_asset/www/default/worklight/wljq.js:1202:33)
I/chromium(11209): at fire (file:///android_asset/www/default/worklight/wljq.js:1047:30)
I/chromium(11209): at Object.self.fireWith [as rejectWith] (file:///android_asset/www/default/worklight/wljq.js:1158:7)
I/chromium(11209): at Object.deferred.(anonymous function) [as reject] (file:///android_asset/www/default/worklight/wljq.js:1247:34)", source: file:///android_asset/www/default/worklight/cordova.js (1081)
I/chromium(11209): [INFO:CONSOLE(1082)] "processMessage failed: Message: F09 WLAuthorizationManagerPlugin1867260175 {"wlFailureStatus":"UNEXPECTED_ERROR","status":403,"responseText":"/*-secure-\n{\"reason\":\"App authenticity security check failed\"}*/","statusText":"Unexpected errorCode occurred. Please try again."}", source: file:///android_asset/www/default/worklight/cordova.js (1082)
Resolved. There is a new tag within the application-descriptor:
directUpdateAuthenticityPublicKey
Updated, exported the application with the keystore and all now works. Thanks for the help.
The issue:
http://www-01.ibm.com/support/docview.wss?uid=swg21970348
I have an application on Google Play that streams music from a radio station built with the latest cordova (5.4) and I am using some of the basic plugins such as:
device plugin
crosswalk webview plugin
dialogs plugin
...
files plugin
media plugin
On Android 5.0+ the streaming works fine but recently when I upgraded my nexus on android 6.0 the streaming stopped. I updated media and file plugin to the latest versions (2.0.0 and 4.0.0 respectively), as cordova stated in their blog that these versions support the new permission checking on Android 6 but still the streaming is not working. The log gives me this:
11-24 23:53:35.347 15184-15184/com.uni.app E/chromium: [ERROR:xwalk_autofill_client.cc(170)] Not implemented reached in virtual void xwalk::XWalkAutofillClient::OnFirstUserGestureObserved()
11-24 23:53:40.395 15184-15235/com.uni.app D/MediaPlayer: setSubtitleAnchor in MediaPlayer
11-24 23:53:40.410 15184-15235/com.uni.app W/MediaPlayer: Stream has no duration and is therefore not seekable.
11-24 23:53:40.410 15184-15235/com.uni.app E/MediaPlayer: error (-2147483648, 0)
11-24 23:53:40.410 15184-15235/com.uni.app D/AudioPlayer: Send a onStatus update for the new seek
11-24 23:53:40.410 15184-15235/com.uni.app W/CordovaPlugin: Attempted to send a second callback for ID: Media951412725 Result was: {"action":"status","status":{"id":"d5334ff7-5511-ea09-b2ef-2900789941a9","msgType":3,"value":0}}
11-24 23:53:40.411 15184-15235/com.uni.app E/MediaPlayer: start called in state 0
11-24 23:53:40.411 15184-15235/com.uni.app E/MediaPlayer: error (-38, 0)
11-24 23:53:40.412 15184-15235/com.uni.app W/CordovaPlugin: Attempted to send a second callback for ID: Media951412725 Result was: {"action":"status","status":{"id":"d5334ff7-5511-ea09-b2ef-2900789941a9","msgType":1,"value":2}}
11-24 23:53:40.412 15184-15235/com.uni.app E/MediaPlayer: Attempt to call getDuration without a valid mediaplayer
11-24 23:53:40.412 15184-15235/com.uni.app E/MediaPlayer: error (-38, 0)
11-24 23:53:40.412 15184-15235/com.uni.app W/CordovaPlugin: Attempted to send a second callback for ID: Media951412725 Result was: {"action":"status","status":{"id":"d5334ff7-5511-ea09-b2ef-2900789941a9","msgType":2,"value":314586.9375}}
11-24 23:53:40.413 15184-15235/com.uni.app E/MediaPlayer: Error (-2147483648,0)
11-24 23:53:40.413 15184-15235/com.uni.app D/AudioPlayer: on completion is calling stopped
11-24 23:53:40.414 15184-15235/com.uni.app W/CordovaPlugin: Attempted to send a second callback for ID: Media951412725 Result was: {"action":"status","status":{"id":"d5334ff7-5511-ea09-b2ef-2900789941a9","msgType":1,"value":4}}
11-24 23:53:40.414 15184-15235/com.uni.app E/MediaPlayer: Error (-38,0)
11-24 23:53:40.414 15184-15235/com.uni.app D/AudioPlayer: on completion is calling stopped
11-24 23:53:40.414 15184-15235/com.uni.app E/MediaPlayer: Error (-38,0)
11-24 23:53:40.414 15184-15235/com.uni.app D/AudioPlayer: on completion is calling stopped
11-24 23:53:53.476 15184-15184/com.uni.app E/chromium: [ERROR:xwalk_autofill_client.cc(170)] Not implemented reached in virtual void xwalk::XWalkAutofillClient::OnFirstUserGestureObserved()
11-24 23:53:58.409 15184-15232/com.uni.app E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaed05f70
11-24 23:53:58.419 15184-15184/com.uni.app W/ScreenOrientationListener: Removing an inexistent observer!
11-24 23:53:58.419 15184-15184/com.uni.app E/chromium: [ERROR:runtime_javascript_dialog_manager.cc(69)] Not implemented reached in virtual void xwalk::RuntimeJavaScriptDialogManager::ResetDialogState(content::WebContents*)
11-24 23:53:58.453 15184-15184/com.uni.app D/AudioPlayer: renaming /storage/emulated/0/tmprecording.3gp to /storage/emulated/0/http://IPADDRESS:PORT/;
11-24 23:53:58.454 15184-15184/com.uni.app E/AudioPlayer: FAILED renaming /storage/emulated/0/tmprecording.3gp to /storage/emulated/0/http://IPADDRESS:PORT/;
11-24 23:53:58.465 15184-15197/com.uni.app E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb3978f90
IPADDRESS:PORT is a real http://ipaddress:port URL stream which works fine.
I now it has to do with the permissions but still no luck on finding exactly what. Going on app-info and on new permissions menu I see that the app uses Microphone, Phone and Storage permissions which are all enabled. I searched a lot and couldn't be able to find something similar.
Any help is appreciated
I found the problem, just comment this line on AudioPlayer.java
public void onPrepared(MediaPlayer player) {
// Listen for playback completion
this.player.setOnCompletionListener(this);
// seek to any location received while not prepared
//this.seekToPlaying(this.seekOnPrepared);
// If start playing after prepared
if (!this.prepareOnly) {
this.player.start();
this.setState(STATE.MEDIA_RUNNING);
this.seekOnPrepared = 0; //reset only when played
} else {
this.setState(STATE.MEDIA_STARTING);
}
// Save off duration
this.duration = getDurationInSeconds();
// reset prepare only flag
this.prepareOnly = true;
// Send status notification to JavaScript
sendStatusChange(MEDIA_DURATION, null, this.duration);
}
Checked on Github in the official repo and found this
Tried on a new sample app and worked fine on my Android 6.0 device. The solution is close to what luckakashi suggested with some extra commenting.
Seems something wrong from Crosswalk, have you try if you remove the Crosswalk plugin? And is your Android 6.0 device 64-bit?
I followed all steps as given in the Push Notifications training module, as well as in this Stack Overflow question: IBM Worklight - Push Notifications feature does not work in Android emulator
When I send a message using the PushBackendEmulator or by calling the PushAdapter procedure from URL it says message sent successfully, but the notification is not received in either device or emulator and there is no error in LogCat.
I am using a device running Android OS 4.3 and AVD running Android OS 4.0.3.
I am trying this with the Push Notification Getting Started training module sample.
In application-descriptor.xml, I have set:
<pushSender key="AIzaSyDXNiXutgh9XhX8eB8AFa2-00jbyVWM2zI" senderId="470484369549"/>
senderID is the project number:
and the key is taken from Google APIs Console : by Create new Server Key option
When I run the App on device and execute push adapter to send push message then the Eclipse Studio console gives below exceptions:
[2013-12-27 06:18:12] Invoking procedure: 'submitNotification' of adapter 'PushAdapter'
[2013-12-27 06:18:12] Server host: localhost
[2013-12-27 06:18:12] Server port: 8080
[2013-12-27 06:18:12] Parameters: ["aahad","this is example"]
[2013-12-27 06:18:12] Procedure invocation finished
[2013-12-27 06:18:13] FWLSE0094E: Error while attempting to invoke GCM service (for sender key starting with 'AIzaSyDX'), sending will not resume until server is restarted or application re-deployed
[2013-12-27 06:18:13] FWLSE0093E: Failed to invoke Google GCM push service.
com.worklight.integration.notification.gcm.GCMSender.sendNoRetry(GCMSender.java:225)
com.worklight.integration.notification.gcm.GCMSender.sendAndVerify(GCMSender.java:127)
com.worklight.integration.notification.gcm.GCMMediator.sendOrWait(GCMMediator.java:135)
com.worklight.integration.notification.gcm.GCMMediator.sendNotification(GCMMediator.java:124)
com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
[2013-12-27 06:18:13] FWLSE0094E: Error while attempting to invoke GCM service (for sender key starting with 'AIzaSyDX'), sending will not resume until server is restarted or application re-deployed
[2013-12-27 06:18:13] FWLSE0094E: Error while attempting to invoke GCM service (for sender key starting with 'AIzaSyDX'), sending will not resume until server is restarted or application re-deployed
[2013-12-27 06:18:13] FWLSE0094E: Error while attempting to invoke GCM service (for sender key starting with 'AIzaSyDX'), sending will not resume until server is restarted or application re-deployed
[2013-12-27 06:18:13] FWLSE0094E: Error while attempting to invoke GCM service (for sender key starting with 'AIzaSyDX'), sending will not resume until server is restarted or application re-deployed
[2013-12-27 06:18:13] FWLSE0093E: Failed to invoke Google GCM push service.
com.worklight.integration.notification.gcm.GCMSender.sendNoRetry(GCMSender.java:225)
com.worklight.integration.notification.gcm.GCMSender.sendAndVerify(GCMSender.java:127)
com.worklight.integration.notification.gcm.GCMMediator.sendOrWait(GCMMediator.java:135)
com.worklight.integration.notification.gcm.GCMMediator.sendNotification(GCMMediator.java:124)
com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
and LogCat shows:
12-27 17:26:47.750: D/Cordova(5639): onPageFinished(file:///data/data/com.PushApplication/files/www/default/PushApplication.html)
12-27 17:26:47.750: D/DroidGap(5639): onMessage(onNativeReady,null)
12-27 17:26:47.750: D/DroidGap(5639): onMessage(onPageFinished,file:///data/data/com.PushApplication/files/www/default/PushApplication.html)
12-27 17:26:47.850: D/CordovaNetworkManager(5639): Connection Type: wifi
12-27 17:26:47.850: D/CordovaNetworkManager(5639): Connection Type: wifi
12-27 17:26:47.850: D/DroidGap(5639): onMessage(networkconnection,wifi)
12-27 17:26:47.860: D/DroidGap(5639): onMessage(spinner,stop)
12-27 17:26:47.860: D/PushApplication(5639): ondeviceready event dispatched
12-27 17:26:47.870: D/PushApplication(5639): wlclient init started
12-27 17:26:47.870: D/PushApplication(5639): Read cookies: null
12-27 17:26:47.880: D/PushApplication(5639): CookieMgr read cookies: {}
12-27 17:26:48.870: D/DroidGap(5639): onMessage(spinner,stop)
12-27 17:26:49.220: D/PushApplication(5639): Request [http://192.168.48.69:8080/apps/services/api/PushApplication/android/init]
12-27 17:26:49.490: D/PushApplication(5639): Request [http://192.168.48.69:8080/apps/services/api/PushApplication/android/init]
12-27 17:26:49.640: D/PushApplication(5639): Clearing notification subscriptions.
12-27 17:26:49.640: D/PushApplication(5639): Send new server notification token id.
12-27 17:26:49.640: W/WLDroidGap(5639): unregisterReceivers:Receiver not registered: com.worklight.androidgap.plugin.Push$1#420ee688
12-27 17:26:49.640: W/WLDroidGap(5639): unregisterReceivers:Receiver not registered: com.worklight.androidgap.plugin.Push$3#420eebb8
12-27 17:26:49.680: D/dalvikvm(5639): GC_FOR_ALLOC freed 334K, 5% free 7765K/8164K, paused 15ms, total 16ms
12-27 17:26:49.680: D/WLDroidGap(5639): Registering at the GCM server.
12-27 17:26:49.680: V/GCMRegistrar(5639): Registering receiver
12-27 17:26:49.680: D/GCMRegistrar(5639): resetting backoff for com.PushApplication
12-27 17:26:49.690: D/PushApplication(5639): response [http://192.168.48.69:8080/apps/services/api/PushApplication/android/init] success: /*-secure-
12-27 17:26:49.690: D/PushApplication(5639): {"userPrefs":{},"WL-Authentication-Success":{"wl_remoteDisableRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null"},"wl_antiXSRFRealm":{"userId":"ce6ll85omecut37aatqrfojfj5","attributes":{},"isUserAuthenticated":1,"displayName":"ce6ll85omecut37aatqrfojfj5"},"wl_deviceNoProvisioningRealm":{"userId":"b65b4d32-93aa-4d2d-89ab-bff0a8c7c9af","attributes":{"mobileClientData":"com.worklight.core.auth.impl.MobileClientData#2c70f885"},"isUserAuthenticated":1,"displayName":"b65b4d32-93aa-4d2d-89ab-bff0a8c7c9af"},"wl_anonymousUserRealm":{"userId":"5125bfe6-d34c-4dce-b5cd-e6c76d902536","attributes":{},"isUserAuthenticated":1,"displayName":"5125bfe6-d34c-4dce-b5cd-e6c76d902536"}},"notificationSubscriptionState":{},"gadgetProps":{"directUpdate":{"updateUnpackedSize":1019860,"availableSkins":["default"],"checksum":695958230,"updateSize":290361},"ENVIRONMENT":"android"},"userInfo":{"wl_authenticityRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null},"wl_remoteDisableRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null"},"PushAppRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null},"wl_antiXSRFRealm":{"userId":"ce6ll85omecut37aatqrfojfj5","attributes":{},"isUserAuthenticated":1,"displayName":"ce6ll85omecut37aatqrfojfj5"},"wl_deviceAutoProvisioningRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null},"wl_deviceNoProvisioningRealm":{"userId":"b65b4d32-93aa-4d2d-89ab-bff0a8c7c9af","attributes":{"mobileClientData":"com.worklight.core.auth.impl.MobileClientData#2c70f885"},"isUserAuthenticated":1,"displayName":"b65b4d32-93aa-4d2d-89ab-bff0a8c7c9af"},"myserver":{"userId":"5125bfe6-d34c-4dce-b5cd-e6c76d902536","attributes":{},"isUserAuthenticated":1,"displayName":"5125bfe6-d34c-4dce-b5cd-e6c76d902536"},"wl_anonymousUserRealm":{"userId":"5125bfe6-d34c-4dce-b5cd-e6c76d902536","attributes":{},"isUserAuthenticated":1,"displayName":"5125bfe6-d34c-4dce-b5cd-e6c76d902536"}}}*/
12-27 17:26:49.690: D/PushApplication(5639): wlclient connect success
12-27 17:26:49.690: D/PushApplication(5639): before: app init onSuccess
12-27 17:26:49.700: D/PushApplication(5639): after: app init onSuccess
12-27 17:26:49.700: D/PushApplication(5639): wlclient init success
12-27 17:26:49.700: V/GCMRegistrar(5639): Registering app com.PushApplication of senders 470484369549
12-27 17:26:50.190: V/GCMBroadcastReceiver(5639): onReceive: com.google.android.c2dm.intent.REGISTRATION
12-27 17:26:50.190: V/GCMBroadcastReceiver(5639): GCM IntentService class: com.PushApplication.GCMIntentService
12-27 17:26:50.200: V/GCMBaseIntentService(5639): Acquiring wakelock
12-27 17:26:50.200: V/GCMBaseIntentService(5639): Intent service name: GCMIntentService-470484369549-1
12-27 17:26:50.210: D/GCMBaseIntentService(5639): handleRegistration: registrationId = APA91bEGLOHqoQHlmmb-wLCEzKFxrW2UHKaeMWnheA8nebNXNojI6O7o3B4BOnAc_tFXe8H3rsg6g4JH3mQl2vh5p8DxXbNhHgiSts-q2HFYFAT1l07Il-2QiRS0ypHLD4kGFQss0ueZWymkzOxypsFBQKPvezKq3Q, error = null, unregistered = null
12-27 17:26:50.210: D/GCMRegistrar(5639): resetting backoff for com.PushApplication
12-27 17:26:50.210: V/GCMRegistrar(5639): Saving regId on app version 1
12-27 17:26:50.210: D/WLDroidGap(5639): Registered at the GCM server with registration id APA91bEGLOHqoQHlmmb-wLCEzKFxrW2UHKaeMWnheA8nebNXNojI6O7o3B4BOnAc_tFXe8H3rsg6g4JH3mQl2vh5p8DxXbNhHgiSts-q2HFYFAT1l07Il-2QiRS0ypHLD4kGFQss0ueZWymkzOxypsFBQKPvezKq3Q
12-27 17:26:50.220: D/WLDroidGap(5639): Successfully registered to GCM notification service with token id APA91bEGLOHqoQHlmmb-wLCEzKFxrW2UHKaeMWnheA8nebNXNojI6O7o3B4BOnAc_tFXe8H3rsg6g4JH3mQl2vh5p8DxXbNhHgiSts-q2HFYFAT1l07Il-2QiRS0ypHLD4kGFQss0ueZWymkzOxypsFBQKPvezKq3Q
12-27 17:26:50.220: V/GCMBaseIntentService(5639): Releasing wakelock
12-27 17:26:50.220: D/PushApplication(5639): Push notification device token has changed, updating server notification token id.
12-27 17:26:50.230: D/PushApplication(5639): Request [http://192.168.48.69:8080/apps/services/api/PushApplication/android/notifications]
12-27 17:26:50.440: D/PushApplication(5639): response [http://192.168.48.69:8080/apps/services/api/PushApplication/android/notifications] success: /*-secure-
12-27 17:26:50.440: D/PushApplication(5639): {"errors":[],"isSuccessful":true,"warnings":[],"info":[]}*/
12-27 17:27:04.920: D/PushApplication(5639): Request [http://192.168.48.69:8080/apps/services/api/PushApplication/android/notifications]
12-27 17:27:06.900: D/SoftKeyboardDetect(5639): Ignore this event
12-27 17:27:07.000: D/SoftKeyboardDetect(5639): Ignore this event
12-27 17:27:12.060: D/SoftKeyboardDetect(5639): Ignore this event
12-27 17:27:12.070: W/IInputConnectionWrapper(5639): getTextBeforeCursor on inactive InputConnection
12-27 17:27:12.080: W/IInputConnectionWrapper(5639): getTextBeforeCursor on inactive InputConnection
12-27 17:27:12.170: D/SoftKeyboardDetect(5639): Ignore this event
12-27 17:27:16.120: D/SoftKeyboardDetect(5639): Ignore this event
12-27 17:27:17.910: D/PushApplication(5639): Request [login]
12-27 17:27:20.750: D/PushApplication(5639): Request [http://192.168.48.69:8080/apps/services/api/PushApplication/android/notifications]
12-27 17:27:20.780: D/PushApplication(5639): Clearing notification subscriptions.
12-27 17:27:20.780: D/PushApplication(5639): Updating notification subscriptions.
12-27 17:27:20.790: D/WLDroidGap(5639): Registering at the GCM server.
12-27 17:27:20.790: D/PushApplication(5639): response [http://192.168.48.69:8080/apps/services/api/PushApplication/android/notifications] success: /*-secure-
12-27 17:27:20.790: D/PushApplication(5639): {"isSuccessful":true,"WL-Authentication-Success":{"PushAppRealm":{"userId":"aahad","attributes":{},"isUserAuthenticated":1,"displayName":"aahad"}},"notificationSubscriptionState":{"eventSources":[{"eventSource":"PushEventSource","alias":"myPush","adapter":"PushAdapter"}],"token":"APA91bEGLOHqoQHlmmb-wLCEzKFxrW2UHKaeMWnheA8nebNXNojI6O7o3B4BOnAc_tFXe8H3rsg6g4JH3mQl2vh5p8DxXbNhHgiSts-q2HFYFAT1l07Il-2QiRS0ypHLD4kGFQss0ueZWymkzOxypsFBQKPvezKq3Q"}}*/
12-27 17:27:20.790: D/GCMRegistrar(5639): resetting backoff for com.PushApplication
12-27 17:27:20.790: V/GCMRegistrar(5639): Registering app com.PushApplication of senders 470484369549
12-27 17:27:21.500: V/GCMBroadcastReceiver(5639): onReceive: com.google.android.c2dm.intent.REGISTRATION
12-27 17:27:21.500: V/GCMBroadcastReceiver(5639): GCM IntentService class: com.PushApplication.GCMIntentService
12-27 17:27:21.500: V/GCMBaseIntentService(5639): Acquiring wakelock
12-27 17:27:21.510: V/GCMBaseIntentService(5639): Intent service name: GCMIntentService-470484369549-2
12-27 17:27:21.510: D/GCMBaseIntentService(5639): handleRegistration: registrationId = APA91bEGLOHqoQHlmmb-wLCEzKFxrW2UHKaeMWnheA8nebNXNojI6O7o3B4BOnAc_tFXe8H3rsg6g4JH3mQl2vh5p8DxXbNhHgiSts-q2HFYFAT1l07Il-2QiRS0ypHLD4kGFQss0ueZWymkzOxypsFBQKPvezKq3Q, error = null, unregistered = null
12-27 17:27:21.510: D/GCMRegistrar(5639): resetting backoff for com.PushApplication
12-27 17:27:21.520: V/GCMRegistrar(5639): Saving regId on app version 1
12-27 17:27:21.520: D/WLDroidGap(5639): Registered at the GCM server with registration id APA91bEGLOHqoQHlmmb-wLCEzKFxrW2UHKaeMWnheA8nebNXNojI6O7o3B4BOnAc_tFXe8H3rsg6g4JH3mQl2vh5p8DxXbNhHgiSts-q2HFYFAT1l07Il-2QiRS0ypHLD4kGFQss0ueZWymkzOxypsFBQKPvezKq3Q
12-27 17:27:21.520: D/WLDroidGap(5639): Successfully registered to GCM notification service with token id APA91bEGLOHqoQHlmmb-wLCEzKFxrW2UHKaeMWnheA8nebNXNojI6O7o3B4BOnAc_tFXe8H3rsg6g4JH3mQl2vh5p8DxXbNhHgiSts-q2HFYFAT1l07Il-2QiRS0ypHLD4kGFQss0ueZWymkzOxypsFBQKPvezKq3Q
12-27 17:27:21.520: V/GCMBaseIntentService(5639): Releasing wakelock
12-27 17:27:24.030: E/PushApplication(5639): Cannot register to event source callback with existing alias: myPush
12-27 17:28:15.890: D/PushApplication(5639): Request [http://192.168.48.69:8080/apps/services/api/PushApplication/android/notifications]
12-27 17:28:16.140: D/PushApplication(5639): response [http://192.168.48.69:8080/apps/services/api/PushApplication/android/notifications] success: /*-secure-
12-27 17:28:16.140: D/PushApplication(5639): {"isSuccessful":true}*/
12-27 17:28:16.170: D/dalvikvm(5639): GC_FOR_ALLOC freed 321K, 5% free 7957K/8340K, paused 15ms, total 16ms
12-27 17:28:23.520: D/PushApplication(5639): Request [http://192.168.48.69:8080/apps/services/api/PushApplication/android/notifications]
12-27 17:28:23.630: D/PushApplication(5639): response [http://192.168.48.69:8080/apps/services/api/PushApplication/android/notifications] success: /*-secure-
12-27 17:28:23.630: D/PushApplication(5639): {"isSuccessful":true}*/
I have successfully used the Push Notifications sample application on an AVD running Android 4.3.
Worklight setup:
Imported the sample
Replaced the API Key and senderId in application-descriptor.xml with the API Key and Project Number from the Google GCM console
Note: for API Key make sure you generate a browser key (Google documentation)
Added android:targetSdkVersion="18" in yourApp\android\native\AndroidManifest.xml in the line:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" />
Built and deployed the app and adapter
Right-clicked the generated Android project > Properties > Android and changed the Build Target to Android 4.3
AVD setup:
Make sure that in the Android SDK Manager you have installed from the Extras section both the Google Cloud Messaging for Android Library as well as Google Play services
Make sure to install the appropriate Google APIs for the API Level you are using in your AVD
Make sure to install the Android image for the API Level you are using in your AVD
Make sure to use this Google API as the Target for your AVD:
After that I have:
Launched the app in the AVD
Logged in with "idan"
Tapped the "Subscribe" button
Made sure I am indeed subscribed ("isSubscribed" button") and able to receive notifications ("isPushSupported" button)
Right-clicked on the PushAdapter folder and chose Run As > Invoke Worklight Procedure
Used the parameters: "idan","test message"
The notification was received in the AVD both when the app is open (the expected alerts were displayed) as well as closed (notification was displayed in the notification bar. Tapping it opened the app and after logging in the expected alerts were displayed).