ibm-bluemix-mobile-services / bms-clientsdk-android-core Goto Github PK
View Code? Open in Web Editor NEWCore components of Bluemix Mobile Services Android SDK
License: Apache License 2.0
Core components of Bluemix Mobile Services Android SDK
License: Apache License 2.0
Each request I'm making, I'm getting warning from okHttp
A connection to http://automation-iwetrzfr-cirilla-mac.mybluemix.net/ was leaked. Did you forget to close a response body?
You get an IllegalArgumentException instead of call to onFailure of the listener
calling to BMSClient.getInstance().initialize(getApplicationContext(), "" ,"", BMSClient.REGION_UK); is not returning any error
The library uses internal parts of OkHttp3, namely
com.ibm.mobilefirstplatform.clientsdk.android.core.internal.ResponseImpl (34): import static okhttp3.internal.Util.UTF_8;
Using OkHttp3 internals is not a good practice. This was removed from OkHttp3 at version 3.13.0.
When using the updated initialization function for Android, I can no longer successfully authenticate my Android app against MCA.
Updated API:
BMSClient.getInstance().initialize(this, "AppID", BMSClient.REGION_US_SOUTH);
Exception:
java.net.UnknownHostException: Unable to resolve host "imf-authserverf37159c3-862e-4f33-9310-d2d7021fd3f3": No address associated with hostname
at java.net.InetAddress.lookupHostByName(InetAddress.java:470)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at com.squareup.okhttp.Dns$1.lookup(Dns.java:39)
at com.squareup.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:175)
at com.squareup.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:141)
at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:83)
at com.squareup.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:174)
at com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
at com.squareup.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
at com.squareup.okhttp.Call.getResponse(Call.java:286)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
at com.squareup.okhttp.Call.access$100(Call.java:35)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
at libcore.io.Posix.android_getaddrinfo(Native Method)
at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
at java.net.InetAddress.lookupHostByName(InetAddress.java:451)
... 20 more
Get request to Bluemix failed: Unable to access Bluemix host!
Please verify internet connectivity and try again.
@dgonz7
In Android core package BaseRequest class, trailing slash / are removed from the URL. This doesn't seem right because there are URLs that have/need the / and I'm not sure why it's necessary to remove it. For example, this URL ('https://www.reddit.com/r/Awww/') needs the trailing slash. Doing a request to 'https://www.reddit.com/r/Awww' returns a 301 Moved Permanently, then another request has to be made to the one with trailing slash. This results in two requests when there really should've been 1. This creates a problem for Mobile Analytics because we then see this as two separate requests instead of 1.
In Swift core, I don't see code that removes trailing slash:
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-swift-core/blob/master/Source/Network%20Requests/BaseRequest.swift
@AnthonyOliveri @Aerex : can you verify that Swift and Cordova are not removing trailing slashes from URLs?
If I'm making simple request without calling to BMSClient.getInstance().initialize first
request like this
Request request = new Request("/protectedResource", Request.GET);
Then I'm getting exception (NullPointerException) and not a call to onFailure of the listener
line 564 in MFPPush.java is as below:
AuthorizationManager authorizationManager = BMSClient.getInstance().getAuthorizationManager();
However, com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient.java has not method getAuthorizationManager(),
I am using the release on 4/4/2016 for bms-clientsdk-android-core-master.zip (there is not newer release than the one on 4/4/2016 from github),
Please advise.
Thanks,
KC
If I'm calling to AuthorizationManager.getInstance().getUserIdentity().getDisplayName() before logging in, I'm getting an exception. I expect it to return me an empty string
Process: com.ibm.mobilefirst.mobileedge.gym, PID: 4627
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ibm.mobilefirst.mobileedge.gym/com.ibm.mobilefirst.mobileedge.gym.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:94)
at org.json.JSONObject.(JSONObject.java:156)
at org.json.JSONObject.(JSONObject.java:173)
at com.ibm.mobilefirstplatform.clientsdk.android.security.internal.preferences.SharedPreferencesManager$JSONPreference.getAsMap(SharedPreferencesManager.java:104)
at com.ibm.mobilefirstplatform.clientsdk.android.security.api.AuthorizationManager.getUserIdentity(AuthorizationManager.java:178)
at com.ibm.mobilefirst.mobileedge.gym.MainActivity.onCreate(MainActivity.java:35)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
I used to develop GCM on my apps with library com.google.android.gms:play-services-gcm:(version)
. It only takes few times to compile. Now I try bluemix sdk and it takes more than 5 minutes to build. I realized this library compile the whole play services library, that's why it takes more time.
why you even need to compile all of it if you just need play-services-gcm
? do you even need service like maps, ads, auth, etc from google?
My application cannot fetch https requests because you haven't updated the OkHttp library yet.
You are currently using version 2.7.4.
And this is the only reference in my project to this library.
+--- project :pgogateway
| +--- com.ibm.mobilefirstplatform.clientsdk.android:core:3.0.0
| | +--- com.squareup.okhttp:okhttp:2.7.4
| | | \--- com.squareup.okio:okio:1.6.0
Error:
W/System.err: java.net.ProtocolException: Expected ':status' header not present
at com.squareup.okhttp.internal.http.Http2xStream.readHttp2HeadersList(Http2xStream.java:267)
W/System.err: at com.squareup.okhttp.internal.http.Http2xStream.readResponseHeaders(Http2xStream.java:149)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:737)
at com.squareup.okhttp.internal.http.HttpEngine.access$200(HttpEngine.java:87)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:722)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:576)
at com.squareup.okhttp.Call.getResponse(Call.java:287)
W/System.err: at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
at com.squareup.okhttp.Call.access$100(Call.java:35)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:171)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
02-17 15:54:26.957 18654-18654/com.ibm.picafeteria E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ibm.picafeteria, PID: 18654
java.lang.RuntimeException: Unable to resume activity {com.ibm.picafeteria/com.ibm.picafeteria.StationActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONObject.optInt(java.lang.String)' on a null object reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2974)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3005)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1328)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONObject.optInt(java.lang.String)' on a null object reference
at com.ibm.mobilefirstplatform.clientsdk.android.analytics.api.MFPAnalytics.logApplicationStartup(MFPAnalytics.java:139)
at com.ibm.picafeteria.MainActivity.onStart(MainActivity.java:132)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
at android.app.Activity.performStart(Activity.java:6036)
at android.app.Activity.performRestart(Activity.java:6093)
at android.app.Activity.performResume(Activity.java:6098)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2963)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3005)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1328)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Latest core SDK is not working with push SDK. The response coming to push from Core rest api call is clipped to half. the response text field is missing. This mainly occurring while try to get the Token from FCM.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.