DevicePolicyManager.resetPasswordWithToken throws NPE - android

I use it like this:
devicePolicyManager
.resetPasswordWithToken(
componentName,
nonNullOrEmptyPassword,
nonNullOrEmptyByteArray,
0
)
And it throws NPE:
java.lang.NullPointerException: Attempt to get length of null array
at android.os.Parcel.createException(Parcel.java:2094)
at android.os.Parcel.readException(Parcel.java:2056)
at android.os.Parcel.readException(Parcel.java:2004)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.resetPasswordWithToken(IDevicePolicyManager.java:15625)
at android.app.admin.DevicePolicyManager.resetPasswordWithToken(DevicePolicyManager.java:3959)
Android 10, Samsung A51, app is a device owner. What's wrong?

Probaby internal implementation sets the token to null if the user is not admin on the device. Check what isResetPasswordTokenActive() returns.

Related

AWS Android initialization error | how to initialize

Getting error when trying to update version
https://search.maven.org/artifact/com.amazonaws/aws-android-sdk-auth-userpools
val initializeBuilder = AWSMobileClient.getInstance().initialize(activity) {
createAwsSessionComponent(environment, configuration)
doAfter.run()
}
initializeBuilder.awsConfiguration(configuration)
initializeBuilder.execute()
getting error
Type mismatch.
Required:
Callback<UserStateDetails!>!
Found:
() → Unit
I am currently getting this error while logging analytics was able to log all other events but a specific event when popup box is display i am getting this issue.
AbstractKinesisRecorder: DeadLetterListener onRecordsDropped has thrown an exception (user code)
java.lang.NullPointerException: Attempt to invoke interface method 'void com.amazonaws.mobileconnectors.kinesis.kinesisrecorder.DeadLetterListener.onRecordsDropped(java.lang.String, java.util.List)' on a null object reference
AbstractKinesisRecorder: ServiceException in submit all, the last request is presumed to be the cause and will be dropped
com.amazonaws.AmazonServiceException: User:
To create a Native Android Mobile app that can invoke AWS Services, try using the AWS SDK for Kotlin. You can find information on how to get up and running with this SDK here:
Setting up the AWS SDK for Kotlin
This SDK works nicely with Android Studio to build Android Apps. It exposes a strongly typed Service Client you can use within an Android Studio project. For example, to invoke SNS, you can use SnsClient:
fun getClient() : SnsClient{
val staticCredentials = StaticCredentialsProvider {
accessKeyId = "<Enter key>"
secretAccessKey = "<Enter key>"
}
val snsClient = SnsClient{
region = "us-west-2"
credentialsProvider = staticCredentials
}
return snsClient
}
Link in the comment below.

Google plus profile pic url is not getting

In my android app there is google plus login button.Google plus login works fine in my app. I use this code to access url of google plus profile pic
String profileurl=Account.getPhotoUrl().toString();
When I use this code.I got errors caused by this reason
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
What should I do to get profile picture url of google plus account?
As the error message clearly states, you are invoking the method "toString()" on a null object, you can either change your code to catch null instances
if (Account.getPhotoUrl() != null){
String profileurl=Account.getPhotoUrl().toString();
}
or make sure that "getPhotoURL()" never returns null
It seems your Account is null and you are trying to access value on null object thats why you are getting null pointer exception. So please try to get like this
GoogleSignInResult result;// its your google result
GoogleSignInAccount acct = result.getSignInAccount();// here your Account value is null
String profileURL = "";
if (acct != null)
profileURL = acct.getPhotoUrl().toString();
You can try this with firebase.
https://firebase.google.com/docs/auth/android/google-signin

Stock Android : NPException : at android.content.res.StringBlock.get(int)

SO users, please read fully then decide to mark the Duplicate for NullPointer exception.
While app launch, from ApplicationExt(extends Application), we initialize the thread in which load the CSV file from Resource bundle(RawSource). It always works on many of the devices. But get crashed on below device for the very first time. For the second time, it gets loaded from the bundle.
OS version : Lollipop (5.1.1)
Device : OnePlus A0001
Crash Log:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference
at android.content.res.AssetManager.getResourceValue(AssetManager.java:213)
at android.content.res.Resources.getValue(Resources.java:1334)
at android.content.res.Resources.getValue(Resources.java:1323)
at android.content.res.Resources.openRawResource(Resources.java:1242)
at android.content.res.Resources.openRawResource(Resources.java:1219)
at com.xxxx.yyyy.network.NetworkManager.getBrandCodesFromCsvFile(NetworkManager.java:2961)
at com.xxxx.yyyy.network.NetworkManager.getBrandCodes(NetworkManager.java:3221)
at com.xxxx.yyyy.network.NetworkManager.checkAndUpdateMobileCodeFromBundle(NetworkManager.java:3110)
at com.xxxx.yyyy.OurApplication$1.run(OurApplication.java:132)
at java.lang.Thread.run(Thread.java:818)
Code Snippet:
In Application, onCreate(...),
Create a thread with code of csv load
Run the thread at the end of onCreate -> new Thread(ourThread).start();
Exact crash on this line :
InputStream bundleStream = OurApplicationClass.getContext().getResources().openRawResource(sourceId);
Note:
I've found related issue on Github. https://github.com/osmandapp/Osmand/issues/2575. But unable to confirm whether it's working for my case.

Codename one crash during capture audio

I'm getting a crash on our app on a part that used to work:
a call to Capture.captureAudio() to get the path to a newly recorded audio file.
I've tested on android and I get this stack trace:
[EDT] 0:5:30,336 - Exception: java.lang.NullPointerException - Attempt to invoke interface method 'int android.database.Cursor.getColumnIndexOrThrow(java.lang.String)' on a null object reference
java.lang.NullPointerException: Attempt to invoke interface method 'int android.database.Cursor.getColumnIndexOrThrow(java.lang.String)' on a null object reference
at com.codename1.impl.android.AndroidImplementation.convertImageUriToFilePath(AndroidImplementation.java:5197)
at com.codename1.impl.android.AndroidImplementation.onActivityResult(AndroidImplementation.java:4936)
at com.codename1.impl.android.CodenameOneActivity$9.run(CodenameOneActivity.java:506)
at com.codename1.ui.Display.processSerialCalls(Display.java:1150)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1094)
at com.codename1.ui.Display.invokeAndBlock(Display.java:1204)
at com.codename1.ui.Display.invokeAndBlock(Display.java:1242)
at com.codename1.capture.Capture.captureAudio(Capture.java:95)
at com.handover.app.taskhandlers.AudioTaskListener$AudioShowHandler.lambda$run$11(AudioTaskListener.java:86)
at com.handover.app.taskhandlers.AudioTaskListener$AudioShowHandler.access$lambda$0(AudioTaskListener.java)
at com.handover.app.taskhandlers.AudioTaskListener$AudioShowHandler$$Lambda$1.actionPerformed(Unknown Source)
at com.codename1.ui.util.EventDispatcher.fireActionSync(EventDispatcher.java:459)
at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:362)
at com.codename1.ui.Button.fireActionEvent(Button.java:411)
at com.codename1.ui.Button.released(Button.java:442)
at com.codename1.ui.Button.pointerReleased(Button.java:530)
at com.codename1.ui.Form.pointerReleased(Form.java:2613)
at com.codename1.ui.Form.pointerReleased(Form.java:2549)
at com.codename1.ui.Component.pointerReleased(Component.java:3147)
at com.codename1.ui.Display.handleEvent(Display.java:2024)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1066)
at com.codename1.ui.Display.invokeAndBlock(Display.java:1204)
at com.codename1.ui.Display.invokeAndBlock(Display.java:1242)
at com.codename1.ui.AnimationManager.addAnimationAndBlock(AnimationManager.java:105)
at com.codename1.ui.Container.animateHierarchy(Container.java:2465)
at com.codename1.ui.Container.animateHierarchyAndWait(Container.java:2185)
at com.handover.app.ui.components.ToastNotification.setVisible(ToastNotification.java:782)
at com.handover.app.ui.components.ToastNotification.updateStatus(ToastNotification.java:530)
at com.handover.app.ui.components.ToastNotification.removeStatus(ToastNotification.java:738)
at com.handover.app.ui.components.ToastNotification.access$700(ToastNotification.java:82)
at com.handover.app.ui.components.ToastNotification$Status.clear(ToastNotification.java:380)
at com.handover.app.ui.components.NetworkProgressIndicator.actionPerformed(NetworkProgressIndicator.java:55)
at com.codename1.ui.util.EventDispatcher.fireActionSync(EventDispatcher.java:459)
at com.codename1.ui.util.EventDispatcher.access$100(EventDispatcher.java:45)
at com.codename1.ui.util.EventDispatcher$CallbackClass.run(EventDispatcher.java:95)
at com.codename1.ui.Display.processSerialCalls(Display.java:1150)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1094)
at com.codename1.ui.Display.mainEDTLoop(Display.java:995)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread$1.run(CodenameOneThread.java:60)
at java.lang.Thread.run(Thread.java:831)
It has been a while since this part of the app was throughly tested, and I'm not entirly sure which version of CN1 this was working on.
Capture.capturePhoto() and Capture.captureVideo() are both still working as expected.
This should be fixed in current versions of the Android build

HttpURLConnection failes with NullPointerException on Lollipop

I noticed that sometimes, not sure in which conditions, while downloading an image using Universal-Image-Loader (https://github.com/nostra13/Android-Universal-Image-Loader), I get the following NullPointerException:
E/ImageLoader(27386): Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference
E/ImageLoader(27386): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference
E/ImageLoader(27386): at com.android.okhttp.internal.http.StatusLine.<init>(StatusLine.java:24)
E/ImageLoader(27386): at com.android.okhttp.Response$Builder.statusLine(Response.java:419)
E/ImageLoader(27386): at com.android.okhttp.internal.http.JavaApiConverter.createOkResponse(JavaApiConverter.java:116)
E/ImageLoader(27386): at com.android.okhttp.internal.http.ResponseCacheAdapter.get(ResponseCacheAdapter.java:53)
E/ImageLoader(27386): at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:269)
E/ImageLoader(27386): at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)
E/ImageLoader(27386): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:323)
E/ImageLoader(27386): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:491)
E/ImageLoader(27386): at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
E/ImageLoader(27386): at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromNetwork(BaseImageDownloader.java:113)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:84)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.downloadImage(LoadAndDisplayImageTask.java:290)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryCacheImageOnDisk(LoadAndDisplayImageTask.java:273)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:229)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:135)
E/ImageLoader(27386): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/ImageLoader(27386): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/ImageLoader(27386): at java.lang.Thread.run(Thread.java:818)
This seems like a bug in okhttp, not in Universal-Image-Loader. The code does something like this, and it crashes in the call to getResponseCode:
String encodedUrl = Uri.encode(url, ALLOWED_URI_CHARS);
HttpURLConnection conn = (HttpURLConnection) new URL(encodedUrl).openConnection();
conn.getResponseCode()
I managed to work around this by disabling cache on the connection before calling getResponseCode:
conn.setUseCaches(false);
Does anyone have an idea why this happens and in which exact conditions? Can this be something related to server settings, perhaps something to do with caching?
The cause for this is a custom implementation of ResponseCache. When implementing CacheResponse.getHeaders(), you need to put the status line in the null key of the multimap. See: http://developer.android.com/reference/java/net/CacheResponse.html#getHeaders().
Failing to do so, causes okhttp to fail with a NullPointerException, which is a bug in okhttp.
I'm copying the full explanation from the okhttp issue tracker at https://code.google.com/p/android/issues/detail?id=160522#c5, as google code is about to close...
There's some strangeness in the HttpURLConnection APIs around the status line. When I implemented the ResponseCacheAdapter / JavaApiConverter I did so assuming certain behavior, where the behavior is sometimes poorly specified in the JavaDocs.
The root cause is that Android assumes that the status line (e.g. the part of the response that indicates the response code, a message) is held as the header with a null key. This is alluded to in the API docs when you look at the header with the index of zero, but is not explicit in the methods that return the Map, or that take a String.
See here: http://developer.android.com/reference/java/net/URLConnection.html#getHeaderFields()
And: http://developer.android.com/reference/java/net/CacheResponse.html#getHeaders()
OkHttp's HttpURLConnection implementation does this, and it has been the case on Android for many releases.
This code:
https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/util/TiResponseCache.java#L416
suggests the cache implementation won't deal properly with a response header with a null key. The header with a null key is being written out as being a header with the key with a string "null", so it is not round-tripped. When the cached headers are deserialized we end up without a header with a null key, which means the OkHttp code is not able to reconstruct the status line from the CacheResponse.

Categories

Resources