Security Exception with AccountManager - android

I'd like to create an account in my Android app programatically.
I've read thing about the AccountManager class and tried to implement it.
Unfortunately, I get a SecurityException when I try to add the account.
Account account = new Account(user.getLogin(), 'packageName');
The thing I don't understand is about the type (in the second parameter).
What do I've to put in second parameter in order to make my code working.
Moreover, I'd like to know if I can add an acount simply with theses lines of code, or should I use a service like many example show ?
Thanks
EDIT - Full Exception Message
java.lang.SecurityException: caller uid 10047 is different than the authenticator's uid
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.accounts.IAccountManager$Stub$Proxy.addAccount(IAccountManager.java:580)
at android.accounts.AccountManager.addAccountExplicitly(AccountManager.java:565)
at fr.opendev.elisaG.activity.LoginActivity.isUserAuthorized(LoginActivity.java:113)
at fr.opendev.elisaG.activity.LoginActivity.access$500(LoginActivity.java:27)
at fr.opendev.elisaG.activity.LoginActivity$1.onClick(LoginActivity.java:70)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16964)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

Related

What is the cause of an IllegalArgumentException at onRestoreInstanceState

There was multiple (more than 10) crashes reported in my Google Play Console with this stack trace (full):
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method:0)
Caused by: java.lang.IllegalArgumentException:
at android.view.View.onRestoreInstanceState(View.java:12308)
at android.view.View.dispatchRestoreInstanceState(View.java:12284)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2617)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
at android.view.View.restoreHierarchyState(View.java:12262)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1647)
at android.app.Activity.onRestoreInstanceState(Activity.java:938)
at android.app.Activity.performRestoreInstanceState(Activity.java:910)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1138)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2189)
What would trigger this exception? There was no mention of my application's classes in the stack trace. What should I do?
The following text is written in the Android source code in View.java:12308 as the IllegalArgumentException message:
Wrong state class, expecting View State but received (something else) instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is (view id). Make sure other views do not use the same id.

Firebase Authentication causing Android fatal exception

I just finished integrating Firebase real time data base and Authentication into my Android Studio application. It ran successfully two or three times on my Google Nexus 7 genymotion emulator that has google play services on it. Then I tried launching it again and I started getting the below error:
06-25 16:50:46.994 7699-7699/
com.careersvirtualsolutions.uprate E/AndroidRuntime:
FATAL EXCEPTION: main
java.lang.NullPointerException
at com.google.firebase.auth.FirebaseAuth$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
I think this has something to do with the Firebase Authentication SDK but I am not sure.
Do you know what this is caused by? How can I solve it?
I actually figured it out, the problem was with the AuthStateListener.
So if you're having a similar issue, try testing your project with the AuthStateListener commented out and see if it launches without crashing. If it does you can then figure out how to replace the existing listener.
Hope this helps in some way!

How to understand such stack trace from Google Play app?

On Google Play developer console I sometimes get crash reports that I don't understand at all. There is noting from my app code in the stack trace reported. Could anyone shed some light e.g. on this one?
java.lang.NullPointerException
at android.os.Parcel.readException(Parcel.java:1338)
at android.os.Parcel.readException(Parcel.java:1286)
at android.speech.tts.ITextToSpeechService$Stub$Proxy.setCallback(ITextToSpeechService.java:573)
at android.speech.tts.TextToSpeech$Connection.onServiceConnected(TextToSpeech.java:1278)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1125)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1142)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4945)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
It's clearly in some Text to Speech package, but how am I, the app author, resposible for this one? I do initialize TTS and my app is reading text aloud, but how can I fix such error?
Greg
here is your errors
ITextToSpeechService$Stub$Proxy.setCallback(ITextToSpeechService.java:573)
it's clearly !

"Failed to register input channel" - what is this caused by and how to fix this?

I've been getting the following error, reported via Market developer console by the users of my app:
java.lang.RuntimeException: Failed to register input channel. Check logs for details.
at android.view.InputQueue.nativeRegisterInputChannel(Native Method)
at android.view.InputQueue.registerInputChannel(InputQueue.java:92)
at android.view.ViewRoot.setView(ViewRoot.java:568)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:465)
at android.app.Dialog.show(Dialog.java:241)
at my.program.MyActivity.handleFailure(Unknown Source)
at my.program.MyActivity$RunFailed.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
at dalvik.system.NativeStart.main(Native Method)
Italicized lines are part of my code. The code in question just creates and shows a dialog. It is run from a Runnable posted to a Handler. Everything should be happening in the GUI thread (that's why Handler is used).
I don't know how to debug this. I haven't experienced this problem myself, and all I have is just a bunch of automated reports. Google shows up a couple of threads on this exact problem, but no answers (except a hint of this being an Android 2.3.3-specific problem).
This may be a Launcher Pro issue. LP is a home replacement. It appears Launcher Pro does not release some resources as it should. Check out this answer here

exception log in Android Market Place

I'm seeing this exception in my android Market Developer Console -->Crash errors
java.lang.NullPointerException
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:398)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:366)
at android.widget.AbsListView.obtainView(AbsListView.java:1943)
at android.widget.ListPopupWindow$DropDownListView.obtainView(ListPopupWindow.java:1143)
at android.widget.ListView.makeAndAddView(ListView.java:1756)
at android.widget.ListView.fillDown(ListView.java:656)
at android.widget.ListView.fillSpecific(ListView.java:1314)
at android.widget.ListView.layoutChildren(ListView.java:1587)
at android.widget.AbsListView.onLayout(AbsListView.java:1794)
at android.view.View.layout(View.java:9330)
at android.view.ViewGroup.layout(ViewGroup.java:3795)
at android.widget.FrameLayout.onLayout(FrameLayout.java:400)
at android.view.View.layout(View.java:9330)
at android.view.ViewGroup.layout(ViewGroup.java:3795)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1201)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1944)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:126)
at android.app.ActivityThread.main(ActivityThread.java:3998)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Here are the things which i don't understand about this error:
Where is it coming from (i don't see any reference to my classes in this trace)?
Does it mean the application shuts down because of this errors?
What is the mechanism by which this error gets logged in market place?
Note : there are no user messages in the error log.
Looks like either it expects a TextView in your layout which is not there, or an item in your list is null. The relevant source is at http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.5_r1/android/widget/ArrayAdapter.java#ArrayAdapter.createViewFromResource%28int%2Candroid.view.View%2Candroid.view.ViewGroup%2Cint%29, line 398 corresponds to line 355 on this page.

Categories

Resources