Application onCreate() never called - android

For some reason my app won't call custom application classes onCreate() anymore. Yesterday everything was fine but today my app crashes when it tries to open a connection to Realm.
java.lang.IllegalStateException: Call 'Realm.init(Context)' before calling this method.
Since I do initialize Realm in my custom application classes onCreate() I tried inserting a breakpoint and logging out of the method. Nothing.
This question had a similiar problem
Custom Application class onCreate() never called
I have disabled instant run, cleaned, rebuilt and even restarted android studio but the problem persists. I even tried checking out a commit from three days ago, which was most certainly working, but the result is the same.
Custom application class
public class MyApplication extends Application
{
#Override
public void onCreate()
{
super.onCreate();
JodaTimeAndroid.init(this);
Realm.init(this);
//more Realm initialization code
}
}
Manifest's application section
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="#style/MyTheme">
Any ideas what might cause this and how to get it fixed?
EDIT
Everything logcat puts out before crash
03-19 21:06:10.687 21869-21869/? E/Zygote: v2
03-19 21:06:10.687 21869-21869/? I/libpersona: KNOX_SDCARD checking this for 10323
03-19 21:06:10.687 21869-21869/? I/libpersona: KNOX_SDCARD not a persona
03-19 21:06:10.688 21869-21869/? E/Zygote: accessInfo : 0
03-19 21:06:10.688 21869-21869/? W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[2], Con:u:r:zygote:s0 RAM:SEPF_SECMOBILE_7.0_0004, [-1 -1 -1 -1 0 1]
03-19 21:06:10.689 21869-21869/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=hailer.com.hailer
03-19 21:06:10.692 21869-21869/? I/art: Late-enabling -Xcheck:jni
03-19 21:06:10.709 21869-21869/? D/TimaKeyStoreProvider: TimaSignature is unavailable
03-19 21:06:10.709 21869-21869/? D/ActivityThread: Added TimaKeyStore provider
03-19 21:06:10.790 21869-21869/hailer.com.hailer D/ContextRelationMgrBrdg: loadKlass() : caller=com.samsung.android.bridge.multiscreen.common.ContextRelationManagerBridge.<clinit>:28 android.app.LoadedApk.makeApplication:833
03-19 21:06:10.814 21869-21869/hailer.com.hailer W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
03-19 21:06:10.872 21869-21869/hailer.com.hailer D/AndroidRuntime: Shutting down VM
03-19 21:06:10.873 21869-21869/hailer.com.hailer E/AndroidRuntime: FATAL EXCEPTION: main
Process: hailer.com.hailer, PID: 21869
java.lang.RuntimeException: Unable to start activity ComponentInfo{hailer.com.hailer/hailer.com.hailer.activities.MainActivity}: java.lang.IllegalStateException: Call `Realm.init(Context)` before calling this method.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.IllegalStateException: Call `Realm.init(Context)` before calling this method.
at io.realm.Realm.getDefaultInstance(Realm.java:208)
at hailer.com.hailer.adapters.DiscussionAdapter.<init>(DiscussionAdapter.java:57)
at hailer.com.hailer.fragments.ChatListFragment.onCreateView(ChatListFragment.java:60)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2189)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2008)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at hailer.com.hailer.activities.MainActivity.onStart(MainActivity.java:320)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1256)
at android.app.Activity.performStart(Activity.java:6929)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008) 
at android.app.ActivityThread.-wrap14(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6688) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358) 
UPDATE
I trimmed down the libraries and disabled multidexing. Didn't help. I also went trough the DiscussionAdapter and ChatListFragment and both are fine. Realm is used in a correct manner and has worked for over a year without issues. I also have log.d("CUSTOMAPPCLS","onCreate called") in my custom application class which does not show in the log. Nor does a breakpoint stop in any part of the onCreate() call.
Now I got a new error. This time it's from PrefsAccessor - a wrapper for SharedPreferences which is also intialised in the custom applications onCreate call. PrefAccessor.init(this); I ran the build again but got the Realm error... The one considering PrefAccessor threw a nullpointer execption when trying to access the SharedPreferences. This further points to the fact that the application onCreate isn't called.
public static string isUseEnterToSendEnabled()
{
SharedPreferences prefs = applicationContext.getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE);// <-- nullpointer exception: Trying to call .getSharedPreferences on a null object
return prefs.getBoolean(ENTER_TO_SEND, false);
}

I found similar scenario to yours here:
https://github.com/realm/realm-java/issues/1800
The issue seems to be about having lots of libraries included to your project (such as Google Play Services) which might led to your app hitting the 65K methods limit.
Did you include any new dependencies to your project?
UPDATE:
after checking your log, I believe the problem can be here:
hailer.com.hailer.adapters.DiscussionAdapter.(DiscussionAdapter.java:57)
at
hailer.com.hailer.fragments.ChatListFragment.onCreateView(ChatListFragment.java:60)
Maybe in your ChatListFragment, you have an instance of DiscussionAdapter which in turn has some static initializer that invokes something related to Realm.

UPDATE 04/2017
The Samsung S7 started working couple of days after I posted this answer... Black magics all the way I say.
It seems that the Samsung S7 that I usually use for testing is somehow busted. I got some other phones from the office and all of them work just fine. I really have no idea what caused the phone to start crashing the app... None of the other apps are crashing and I didn't download any updates or other apps before this started. I'll post a comment to this answer if I figure this one out and accept this as the solution since I found a "solution"....

Related

Trying to create basic application using HERE Android Lite SDK

I am trying to run a basic example of an application with new Android Lite SDK from HERE and getting such error:
E/AndroidTangramPlatformBridge: parse
org.xmlpull.v1.XmlPullParserException: END_TAG expected (position:START_TAG (empty) <axis tag='wdth' stylevalue='100.0'>#279:51 in java.io.InputStreamReader#739274e)
at org.kxml2.io.KXmlParser.nextText(KXmlParser.java:2088)
at com.here.sdk.mapviewlite.FontFileParser.processDocument(Unknown Source:105)
at com.here.sdk.mapviewlite.FontFileParser.parse(Unknown Source:21)
at com.here.sdk.mapviewlite.FontFileParser.parse(Unknown Source:18)
at com.here.sdk.mapviewlite.AndroidTangramPlatformBridge.<init>(Unknown Source:33)
at com.here.sdk.mapviewlite.MapViewLite.onCreate(Unknown Source:6)
at com.here.hellomap.MainActivity.onCreate(MainActivity.java:46)
at android.app.Activity.performCreate(Activity.java:7458)
at android.app.Activity.performCreate(Activity.java:7448)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3409)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3614)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2199)
at android.os.Handler.dispatchMessage(Handler.java:112)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
D/HwCustConnectivityManagerImpl: isBlockNetworkRequestByNonAis, INVALID_SUBSCRIPTION_ID
D/ActivityThread: add activity client record, r= ActivityRecord{d1ae1ac token=android.os.BinderProxy#853d260 {com.here.hellomap/com.here.hellomap.MainActivity}} token= android.os.BinderProxy#853d260
E/: [ZeroHung]zrhung_get_config: Get config failed for wp[0x0008]
D/ZrHung.AppEyeUiProbe: notify runnable to start.
I/HwSecImmHelper: mSecurityInputMethodService is null
D/HwAppInnerBoostImpl: set config for com.here.hellomap BOOST_FLAG=false REPORT_DURATION_CLICK=1000 REPORT_TIMES_CLICK=3 REPORT_DURATION_SLIDE=5000 REPORT_TIMES_SLIDE=16
D/OpenGLRenderer: HWUI Binary is enabled
W/HiTouch_HiTouchSensor: depended package hiTouch does n't exist!
I/HiTouch_HiTouchSensor: HiTouch restricted: system app HiTouch don't exist.
D/HiTouch_PressGestureDetector: onAttached, package=com.here.hellomap, windowType=1, mHiTouchRestricted=true
E/analytics: [ERROR] analytics - Failed to get the authentication token: Authentication failed, error code: 1
E/analytics: [ERROR] analytics - Failed to get the authentication token: Authentication failed, error code: 1
[ERROR] analytics - Invalid access key
I/HwPhoneWindow: updateLayoutParamsColor false mSpecialSet=false, mForcedNavigationBarColor=false, navigationBarColor=ff000000, mNavBarShow=true, mIsFloating=false
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
I see only a blank map on my HUAWEI P Smart (on Virtual device code runs normally).
Does anyone have an idea of how to solve it?
Please check authentication token for android Lite version. Also check for the permission java class that has to be correctly written. The accompanying example apps can be found on GitHub : https://github.com/heremaps/here-sdk-examples
To try out these examples, add your HERE credentials (access_key_id and access_key_secret) to the AndroidManifest.xml file, and add the HERE SDK to the libs folder.

How can I run Google Fit Sample?

I downloaded the sample at https://github.com/googlesamples/android-fit
and Build a Project [StepCouter] is ok.
But when I run on my device, an error occured:
02-27 16:37:18.620 26622-26622/com.google.android.gms.fit.samples.stepcounter E/dalvikvm:
Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
02-27 16:37:18.660 26622-26622/com.google.android.gms.fit.samples.stepcounter E/AndroidRuntime:
FATAL EXCEPTION: main
java.lang.NoSuchMethodError: com.google.android.gms.fit.samples.common.logger.LogView.setTextAppearance
at com.google.android.gms.fit.samples.stepcounter.MainActivity.initializeLogging(MainActivity.java:161)
at com.google.android.gms.fit.samples.stepcounter.MainActivity.onCreate(MainActivity.java:57)
at android.app.Activity.performCreate(Activity.java:5111)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2185)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
at android.app.ActivityThread.access$700(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5159)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:810)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:577)
at dalvik.system.NativeStart.main(Native Method)
How can I fix this error?
Thanks all.
Make sure that you have the right permissions and scopes. You may follow this documentation on how to obtain authorization in Google Fit API.
User consent is always required before your app can read or write fitness data. To obtain authorization:
Register your Android app with a project in the Google Developers Console.
Specify a scope of access when connecting to the fitness service.
In Google Fit, scopes are strings that determine what kinds of fitness data an app can access and the level of access to this data.
For the Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering error, you may refer with this link.

Android app crashing after loading project on a different computer

I've been storing my project in DropBox to share across computers so I can work from my laptop upstairs. Everything worked fine on my PC, then I went and loaded the project on my laptop and it just crashed when I tried to run it so I gave up and came back to my PC, but now it isn't working there either. It was working fine, I didn't change anything about the code at all. but now I get the error below.
No matter how many gradle syncs and updates and everything that I try I can't figure out how to fix. In addition to fixing this, how am I supposed to work on the same project on multiple PC's without breaking everything?
I ran a Gradle Clean and Sync but it didn't seem to work that time either. Also I didn't even realize I was using AsyncTask, so I'll look at that.
Since I'm not sure exactly what the stack trace is, here's my whole LogCat :)
03-10 14:25:41.849 4830-4830/com.mydomain.myapp W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
03-10 14:25:41.960 4830-4830/com.mydomain.myapp I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
03-10 14:25:41.961 4830-4830/com.mydomain.myapp I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
03-10 14:25:41.966 4830-4870/com.mydomain.myapp V/FA: Using measurement service
03-10 14:25:41.966 4830-4870/com.mydomain.myapp V/FA: Connecting to remote service
03-10 14:25:41.967 4830-4870/com.mydomain.myapp V/FA: Activity resumed, time: 4313744
03-10 14:25:41.977 4830-5248/com.mydomain.myapp E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.mydomain.myapp, PID: 4830
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
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: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{36fd80a 4830:com.mydomain.myapp/u0a17} (pid=4830, uid=10017) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
at android.os.Parcel.readException(Parcel.java:1599)
at android.os.Parcel.readException(Parcel.java:1552)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:3550)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:4778)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2018)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1468)
at android.content.ContentResolver.query(ContentResolver.java:475)
at android.content.CursorLoader.loadInBackground(CursorLoader.java:64)
at android.content.CursorLoader.loadInBackground(CursorLoader.java:56)
at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:312)
at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:69)
at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:66)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
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) 
03-10 14:25:41.980 4830-5250/com.mydomain.myapp D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[ 03-10 14:25:41.982 4830: 4830 D/ ]
HostConnection::get() New Host Connection established 0x7effab5dc260, tid 4830
03-10 14:25:42.283 4830-4830/com.mydomain.myapp D/MainActivity: onAuthStateChanged:signed_out
03-10 14:25:42.314 4830-5250/com.mydomain.myapp I/OpenGLRenderer: Initialized EGL, version 1.4
03-10 14:25:42.314 4830-5250/com.mydomain.myapp W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
03-10 14:25:42.434 4830-4870/com.mydomain.myapp V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 469
03-10 14:25:42.435 4830-4870/com.mydomain.myapp V/FA: Using measurement service
03-10 14:25:42.435 4830-4870/com.mydomain.myapp V/FA: Connection attempt already in progress
03-10 14:25:42.436 4830-4870/com.mydomain.myapp V/FA: Activity paused, time: 4314214
03-10 14:25:42.457 4830-4870/com.mydomain.myapp D/FA: Connected to remote service
03-10 14:25:42.457 4830-4870/com.mydomain.myapp V/FA: Processing queued up service tasks: 2
03-10 14:25:42.526 4830-4830/com.mydomain.myapp W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
03-10 14:25:42.640 4830-5250/com.mydomain.myapp E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7effa40972a0
First thing, on the original computer on which this project last worked, try a gradle 'clean' and then a build. If that doesn't work, it probably means that you changed the code since it last worked. Try to figure out what you changed, and undo that.
Second, AsyncTask is the source of a lot of headaches (and crashes), because it holds a reference to the Activity from which it was started, but is not part of the Activity's lifecycle, so can operate on the Activity after the Activity has been destroyed. My suggestion - don't use AsyncTask - regardless of what you are using it for, there is almost always a better way. Post your stacktrace here, and we might be able to help you figure out what the problem is.
As far as sharing code, use a version control system. GitHub is good, and it's free. Proper use of it would also let you easily roll your code back to the point where it last worked.
=====
Ok, so looking at the stacktrace that you posted from your logcat, we see:
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) 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: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{36fd80a 4830:com.mydomain.myapp/u0a17} (pid=4830, uid=10017) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
So, it looks like you are attempting to access the ContactsProvider, but haven't put the READ_CONTACTS permission in your manifest.

Asynchronous Loopj - AsyncHttpClient: missing method "setCoookieStore()"

I'm trying to implement the sample android app provided here.
I've installed all the dependencies as directed, but when I run the code on an actual phone, the error messages suggests (I think!) that the method setCoookieStore() doesn't exist and that's leading to problems down the road. Is this actually a problem with AsyncHttpClient or is this something which should be done in the parent class? How can I resolve it?
I've tried googling around quite a bit, but most results don't seem relevant and quite often are over my head (Android development beginner...). This seems like the closest thing I could find, but I'm not sure if it's right or how to implement it if it is: Using Cookies across Activities when using HttpClient.
Thank you for your help!
This is the overall series of error message
04-29 05:58:24.386 6867-6867/? E/Zygote: MountEmulatedStorage()
04-29 05:58:24.386 6867-6867/? E/Zygote: v2
04-29 05:58:24.386 6867-6867/? E/Zygote: accessInfo : 0
04-29 05:58:24.386 6867-6867/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
04-29 05:58:25.066 6867-6867/com.empatica.empalinksample E/EMPA_C: Loaded
04-29 05:58:25.086 6867-6867/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.empatica.empalinksample, PID: 6867
java.lang.NoSuchMethodError: No virtual method setCookieStore(Lorg/apache/http/client/CookieStore;)V in class Lcom/loopj/android/http/AsyncHttpClient; or its super classes (declaration of 'com.loopj.android.http.AsyncHttpClient' appears in /data/app/com.empatica.empalinksample-2/base.apk)
at com.empatica.empalink.EmpaDeviceManager.<init>(EmpaDeviceManager.java:180)
at com.empatica.empalink.EmpaDeviceManager.<init>(EmpaDeviceManager.java:166)
at com.empatica.sample.MainActivity.onCreate(MainActivity.java:64)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3108)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3263)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1687)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6897)
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:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Apparently I needed to add "useLibrary 'org.apache.http.legacy'" to my app's build.gradle file and make sure the compileSdkVersion and buildToolsVersion were pointing to 23 (instead of 21 which they were before).
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
useLibrary 'org.apache.http.legacy'
....

Unable to extract the trust manager on a.a.k#... - PayPal-Android-SDK 2.13.3

I recently updated my Song Scrapbook app to the latest version and also made sure to update all third-party APIs used by the app. One such third-party tool is the PayPal Android SDK which I use to monetize my app since I live in a country where the Google Wallet Merchant service is currently not supported - which means I cannot use the Play Store in-app or once-off purchase systems in my app.
However, after updating the PayPal SDK to the latest version in my app (via mavenCentral) I get the following error in Android Studio (version: 1.5.1) everytime I want to execute a PayPal transaction:
debug W/paypal.sdk: PayPalService created. API:19 PayPalSDK/PayPal-Android-SDK 2.13.3 (Android 4.4.4; samsung GT-I9060I; )
03-20 16:58:45.540 7804-7804/com.whitsoft.songscrapbook.debug W/ApplicationPackageManager: getCSCPackageItemText()
03-20 16:58:45.550 7804-7804/com.whitsoft.songscrapbook.debug W/ApplicationPackageManager: getCSCPackageItemText()
03-20 16:58:45.550 7804-7804/com.whitsoft.songscrapbook.debug I/dalvikvm: Could not find method com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable, referenced from method com.paypal.android.sdk.at.a
03-20 16:58:45.550 7804-7804/com.whitsoft.songscrapbook.debug W/dalvikvm: VFY: unable to resolve static method 10405: Lcom/google/android/gms/common/GooglePlayServicesUtil;.isGooglePlayServicesAvailable (Landroid/content/Context;)I
03-20 16:58:45.610 7804-7804/com.whitsoft.songscrapbook.debug I/dalvikvm: Could not find method io.card.payment.CardIOActivity.checkSelfPermission, referenced from method io.card.payment.CardIOActivity.onCreate
03-20 16:58:45.610 7804-7804/com.whitsoft.songscrapbook.debug W/dalvikvm: VFY: unable to resolve virtual method 13172: Lio/card/payment/CardIOActivity;.checkSelfPermission (Ljava/lang/String;)I
03-20 16:58:45.820 7804-7843/com.whitsoft.songscrapbook.debug I/System: Loaded time zone names for "en" in 132ms (127ms in ICU)
03-20 16:58:45.840 7804-7804/com.whitsoft.songscrapbook.debug W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x4168cbc0)
03-20 16:58:45.840 7804-7804/com.whitsoft.songscrapbook.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.whitsoft.songscrapbook.debug, PID: 7804
java.lang.RuntimeException: Unable to start service com.paypal.android.sdk.payments.PayPalService#41e9c5a0 with Intent { cmp=com.whitsoft.songscrapbook.debug/com.paypal.android.sdk.payments.PayPalService (has extras) }: java.lang.IllegalStateException: Unable to extract the trust manager on a.a.k#41ff61a0, sslSocketFactory is class com.paypal.android.sdk.bn
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2987)
at android.app.ActivityThread.access$2100(ActivityThread.java:166)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5584)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Unable to extract the trust manager on a.a.k#41ff61a0, sslSocketFactory is class com.paypal.android.sdk.bn
at a.ak.<init>(Unknown Source)
at a.ak.<init>(Unknown Source)
at a.am.b(Unknown Source)
at com.paypal.android.sdk.bt.<init>(Unknown Source)
at com.paypal.android.sdk.payments.PayPalService.a(Unknown Source)
at com.paypal.android.sdk.payments.PayPalService.onStartCommand(Unknown Source)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2970)
at android.app.ActivityThread.access$2100(ActivityThread.java:166) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5584) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) 
at dalvik.system.NativeStart.main(Native Method) 
03-20 17:03:46.103 7804-7804/? I/Process: Sending signal. PID: 7804 SIG: 9
I know this problem is not caused by the device on which I tested the app - as I have tested this app on two very different devices (Samsung Grand Neo and Cubot X15) and both devices produced similar errors. I tried googling the problem to try and solve the problem but after hours of searching found no solution.
Any assistance will be much appreciated.
SilSur.
So it took me roughly 5 hours to figure this one out - which I achieved through a step-by-step elimination of possible causes of the problem.
Turns out the real problem was my haste in trying to update the app. The reason being that the PayPal SDK 2.13.3 version has a new rule in the 'proguard-rules.pro' file that is very important to include:
Rule as follows:
# This is added for okhttp 3.1.2 bug fix as shown at https://github.com/square/okhttp/issues/2323
-keepclassmembers class * implements javax.net.ssl.SSLSocketFactory {
private javax.net.ssl.SSLSocketFactory delegate;
}
This prevents the minify (obfuscation) process of Gradle from removing IMPORTANT code from a previous bug-fix in the PayPal SDK that caused problems with the secure layer socket factory. So yeah - that was the fix: the updated app now works perfectly (just as required).
Lesson learnt: make sure your 'proguard-rules' are exactly as they are suppose to be!
Over & Out, SilSur.

Categories

Resources