No virtual method loadThumbnail() in class ContentResolver or its super classes - android

When I use public #NonNull Bitmap loadThumbnail(#NonNull Uri uri, #NonNull Size size,#Nullable CancellationSignal signal) method ,
it is always showing this error
2019-12-24 16:16:10.661 30299-30299/com.shaheen.filemanager E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.shaheen.filemanager, PID: 30299
java.lang.NoSuchMethodError: No virtual method loadThumbnail(Landroid/net/Uri;Landroid/util/Size;Landroid/os/CancellationSignal;)Landroid/graphics/Bitmap; in class Landroid/content/ContentResolver; or its super classes (declaration of 'android.content.ContentResolver' appears in /system/framework/framework.jar)
at com.shaheen.filemanager.activities.FileSelectActivity.onCreate(FileSelectActivity.kt:38)
at android.app.Activity.performCreate(Activity.java:7036)
at android.app.Activity.performCreate(Activity.java:7027)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Is there is any other way to solve this error ?
My code looks like this :
val bitmap = applicationContext.contentResolver.loadThumbnail(uri,Size(5,5),null)
thumbnail_image_view.setImageBitmap(bitmap)
screenshot_image_view.setImageBitmap(bitmap)

The method loadThumbnail() was only added in API level 29 that Android 10.0 so it won't work in lower versions.
However, you can use image loader libraries like picasso or glide with the uri.

Have you tried passing the context of activity or fragment instead of application context ?

Related

Unable to execute billing on LG Nexus 5X

My app has in-app purchases. I use the billing library:
def billing_version = "4.1.0"
implementation("com.android.billingclient:billing:$billing_version")
implementation("com.android.billingclient:billing-ktx:$billing_version")
I observe in Firebase, that user with LG Nexus 5X (Android 8.1) can't make the purchase. He tried several times, but gets the same problem:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{studio.yatoo.calendarwidget/com.android.billingclient.api.ProxyBillingActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.IntentSender android.app.PendingIntent.getIntentSender()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.IntentSender android.app.PendingIntent.getIntentSender()' on a null object reference
at com.android.billingclient.api.ProxyBillingActivity.onCreate(com.android.billingclient:billing##4.1.0:11)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
All other users have no such problem. Only user with LG Nexus 5X. Could somebody help, how to solve this problem?
As I stated in my comment below the question, I get the feeling this is safe to ignore. My app is relatively niche, and the probability of someone with a device this old, with this OS version, making a purchase so soon is almost zero. I wish Google would be more explicit about their automated testing devices, as I've wasted time chasing similar, seemingly impossible bugs before, but this smells like it's safe to ignore (with caution).

Clear ViewModel throws IllegalArgumentException

I have a ViewModel what is initialize by one Activity and shared by multiple Fragments, so I have an app what only exist of one Activity.
When I remove my current device, I also clear my ViewModel manually by
activity?.viewModelStore?.clear()
After this I go back to another Fragment and call
bleDeviceViewModel = ViewModelProvider(requireActivity()).get(BleDeviceViewModel::class.java)
the following error is thrown ->
Process: de.app.ilockit, PID: 2120
java.lang.IllegalArgumentException: SavedStateProvider with the given key is already registered
at androidx.savedstate.SavedStateRegistry.registerSavedStateProvider(SavedStateRegistry.java:111)
at androidx.lifecycle.SavedStateHandleController.attachToLifecycle(SavedStateHandleController.java:50)
at androidx.lifecycle.SavedStateHandleController.create(SavedStateHandleController.java:70)
at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:67)
at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:84)
at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:107)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:187)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150)
at de.app.ui.home.HomeFragment.onCreateView(HomeFragment.kt:43)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2950)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:515)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2094)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Note: I use Hilt as dependency injection if it has anything to do with it

How to use the aws genarated Android SDK with api gateway

My deployed AWS API Gateway has one endpoint:
/users with a DELETE Method. I'm trying to call this method from my android app using a generated SDK.
I have deployed the API, then generated the SDK in the API Gateway console and downloaded my zip folder named aws-apigateway-api-sdk-1.0.0. I then ran 'mvn install' inside the folder and copied the generated .jar file and libs into my project and added the gradle imports (basically I did everything as in these instructions until point 7).
Now I want to create the SDK in my android code. In the instructions they do it this way:
// Create an instance of your SDK. Here, 'SimpleCalcClient.java' is the compiled java class for the SDK generated by API Gateway.
final SimpleCalcClient client = factory.build(SimpleCalcClient.class);
My problem is this SimpleCalcClient.class -> I know I need to replace this with my own value, but in my generated target folder I only found following class named LambdaSimpleProxyClient.class, which is an interface. This doesnt seem to be the right class though:
I still tried to use the ApiClientFactory with this class, right now my code looks like this:
public void deleteUser(View view) {
ApiClientFactory factory = new ApiClientFactory();
final LambdaSimpleProxyClient client = factory.build(LambdaSimpleProxyClient.class);
client.usersDelete();
}
The LambdaSimpleProxyClass.java was generated in step 5 when I ran mvn install, it has the method usersDelete() in it, which makes sense to me because that fits with how I called my API Endpoint and looks kinda promising, but I don't rally think that's the class I should use here (but there was no other .class file in my zip folder that was generated by the API Gateway Generate SDK Method:
/**
*
*
* #return Empty
*/
#com.amazonaws.mobileconnectors.apigateway.annotation.Operation(path = "/users", method = "DELETE")
Empty usersDelete();
I also don't understand how to pass my query parameter username in here, but I still tried to call this method. The program then crashes at client.usersDelete();
So what else than LambdaSimpleProxyClient.class should I use there? There is no other .class file in my generated zip folder aws-apigateway-api-sdk-1.0.0 or in my by maven generated target folder.
2020-12-21 20:59:32.427 5340-5340/de.stuttgart.syzl3000 D/ProfileActivity: deleteAccount: delete Btn clicked
2020-12-21 20:59:32.441 5340-5340/de.stuttgart.syzl3000 D/AndroidRuntime: Shutting down VM
2020-12-21 20:59:32.445 5340-5340/de.stuttgart.syzl3000 E/AndroidRuntime: FATAL EXCEPTION: main
Process: de.stuttgart.syzl3000, PID: 5340
java.lang.IllegalStateException: Could not execute method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:414)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24701)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24701)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: com.amazonaws.mobileconnectors.apigateway.ApiClientException: (Service: null; Status Code: 0; Error Code: null; Request ID: null)
at com.amazonaws.mobileconnectors.apigateway.ApiClientHandler.invoke(ApiClientHandler.java:118)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy1.usersDelete(Unknown Source)
at de.stuttgart.syzl3000.menu.ProfileActivity.deleteAccount(ProfileActivity.java:49)
at java.lang.reflect.Method.invoke(Native Method)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24701)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1448)
at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:102)
at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:90)
at java.net.InetAddress.getAllByName(InetAddress.java:787)
at com.android.okhttp.Dns$1.lookup(Dns.java:39)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:175)
at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:141)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:83)
at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:174)
at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseMessage(HttpURLConnectionImpl.java:534)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseMessage(DelegatingHttpsURLConnection.java:109)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseMessage(Unknown Source:0)
at com.amazonaws.http.UrlHttpClient.createHttpResponse(UrlHttpClient.java:92)
at com.amazonaws.http.UrlHttpClient.execute(UrlHttpClient.java:85)
at com.amazonaws.mobileconnectors.apigateway.ApiClientHandler.invoke(ApiClientHandler.java:109)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy1.usersDelete(Unknown Source)
at de.stuttgart.syzl3000.menu.ProfileActivity.deleteAccount(ProfileActivity.java:49)
at java.lang.reflect.Method.invoke(Native Method)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24701)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Any hints are welcomed
I had to run the "Generate SDK" in my API Gateway Console again, because somehow the query parameter that I added wasn't in the deployed version. After deploying it again and generating a new SDK, I moved the unzipped folder aws-apigateway-api-sdk-1.0.0 into my app folder. Then the LambdaSimpleProxyClient.class was automatically recognised in the factory.build(LambdaSimpleProxyClient.class) call and I was able to pass the query parameter into the client.deleteUser("<my-username-value>") method that now accepted a passed in String parameter.
There's still an error, but I'll open a new question for that.

Chuck IncompatibleClassChangeError

I make a simple app, that uses http. For debug previously I used Chuck library. But now, when I try to open http-package from Chuck I get exception and I don't understand why.
You can see the project here: https://github.com/FirstSpectr/Sandbox
Process: ru.spectr.kotlinsandbox, PID: 4699
java.lang.IncompatibleClassChangeError: Class 'com.readystatesoftware.chuck.internal.ui.TransactionActivity' does not implement interface 'androidx.lifecycle.LifecycleOwner' in call to 'androidx.lifecycle.Lifecycle androidx.lifecycle.LifecycleOwner.getLifecycle()' (declaration of 'androidx.lifecycle.LiveData' appears in /data/app/ru.spectr.kotlinsandbox-cFhy1fESF3ecXGlmQrM-Yg==/base.apk!classes2.dex)
at androidx.lifecycle.LiveData.observe(LiveData.java:172)
at androidx.loader.app.LoaderManagerImpl$LoaderInfo.setCallback(LoaderManagerImpl.java:100)
at androidx.loader.app.LoaderManagerImpl.createAndInstallLoader(LoaderManagerImpl.java:400)
at androidx.loader.app.LoaderManagerImpl.initLoader(LoaderManagerImpl.java:421)
at com.readystatesoftware.chuck.internal.ui.TransactionActivity.onCreate(TransactionActivity.java:91)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)```
I found problem dependency:
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
After deleted chuck work fine

Android : java.lang.NoSuchMethodError: No static method decodeHex

I have added an external library from .jar in my project and whenever I run the the app, it throws this error :
FATAL EXCEPTION: main
Process: com.enginious.snowblossom, PID: 17643
java.lang.NoSuchMethodError: No static method decodeHex(Ljava/lang/String;)[B in class Lorg/apache/commons/codec/binary/Hex; or its super classes (declaration of 'org.apache.commons.codec.binary.Hex' appears in /system/framework/org.apache.http.legacy.boot.jar)
at snowblossom.lib.SnowFieldInfo.(SnowFieldInfo.java:28)
at snowblossom.lib.NetworkParamsTestnet.genSnowFields(NetworkParamsTestnet.java:32)
at snowblossom.lib.NetworkParams.(NetworkParams.java:22)
at snowblossom.lib.NetworkParamsTestnet.(NetworkParamsTestnet.java:13)
at snowblossom.lib.NetworkParams.loadFromConfig(NetworkParams.java:96)
at snowblossom.client.SnowBlossomClient.(SnowBlossomClient.java:281)
at com.enginious.snowblossom.MainActivity.onCreate(MainActivity.java:32)
at android.app.Activity.performCreate(Activity.java:7183)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
org.Appache.Commons is included in the library I have added but it is still throwing this error. I need guidance regarding this issue. Thanks.

Categories

Resources