java.lang.NoClassDefFoundError: android.app.usage.UsageStatsManager in android - java

Hi i am using UsageStatsManager api to show some usage list to user. But i am facing some issue. i am getting this error in many device, in some device it's working fine. i am still surfing about this issue. can you guys please help me to solve this.
Error:
java.lang.NoClassDefFoundError: android.app.usage.UsageStatsManager
at com.yourapp.fragment.AppUsageStatisticsFragment.onViewCreated(AppUsageStatisticsFragment.java:64)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5463)
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:854)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:621)
at dalvik.system.NativeStart.main(Native Method)
Code i have used:
private UsageStatsManager mUsageStatsManager;
//i am getting error at below line.
mUsageStatsManager = (UsageStatsManager) getActivity()
.getSystemService("usagestats"); //Context.USAGE_STATS_SERVICE
Manifest:
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions"/>
Check my app.

UsageStatsManager Added in API level 21 this is not a part of your appcompact API. So that's why before API level 21 you will get the ClassNotFoundException

UsageStatsManager was Added in API level 21 so you will get this ClassNotFoundException on preLollipop.
Also some samsung and other devices throws ClassNotFoundException on lollipop too as they haven't included that class, You can only safely use the class in API 22

Related

java.lang.RuntimeException: Unable to start activity: com.google.android.apps.messaging.ui.conversationlist.ShareIntentActivity - Resources not found

I created a game on Unity for Android. I got this error when uploading an update of my build on Google Play:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.apps.messaging/com.google.android.apps.messaging.ui.conversationlist.ShareIntentActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f08014a
I only changed the sound volume in the update, so I guess the issue was already there in the previous builds but not detected.
I used visual scripting. I only have5 scripts downloaded from internet:
to allow to take a screenshot and share it on a platform when
pressing a button
to adapt the game to the screen resolution of the device
to authenticate to Google Play and send the score to the leaderboard
to trigger an event when the Unity ad did finish
to keep playing the music when reloading the scene
Here is the detail of the issue:
FATAL EXCEPTION: main
Process: com.google.android.apps.messaging, PID: 30735
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.apps.messaging/com.google.android.apps.messaging.ui.conversationlist.ShareIntentActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f08014a
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2805)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2883)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6523)
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:857)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f08014a
at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:229)
at android.content.res.Resources.getDrawableForDensity(Resources.java:876)
at android.content.res.Resources.getDrawable(Resources.java:819)
at android.content.Context.getDrawable(Context.java:605)
at ym.a(PG:15)
at com.google.android.apps.messaging.ui.common.ListEmptyView.a(PG:5)
at nog.c(PG:20)
at cy.b(PG:48)
at nol.b(PG:15)
at android.support.v4.app.Fragment.g(PG:120)
at em.f(PG:71)
at ee.a(PG:447)
at ee.c(PG:436)
at ee.d(PG:395)
at ee.a(PG:427)
at ee.b(PG:327)
at ee.a(PG:535)
at ee.c(PG:217)
at ee.c(PG:109)
at ee.i(PG:61)
at di.onStart(PG:114)
at ma.onStart(PG:128)
at vit.onStart(PG:60)
at lkx.onStart(PG:33)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1334)
at android.app.Activity.performStart(Activity.java:7033)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2768)
... 9 more
I am not a programmer so I don't know where to start. The error is about com.google.android.apps.messaging/com.google.android.apps.messaging.ui.conversationlist.ShareIntentActivity
So maybe it is related to script to share a screenshot?
Thank you!
I got the same error just now, complaining about that exact resource ID 0x7f08014a. It's not an error in your app. Looks like Google has some resource bug in their messaging app.
If you view the test-run video, I believe you will see something like Google's messaging app being started. Perhaps from a share button?

Attempt to invoke virtual method 'java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String)' on a null object reference

I updated my android studio from 3.1.2 to 3.1.3 and updated my project sdk version to 28 and when i run the application it crashes as soon as it open and throws the following exception,
FATAL EXCEPTION: main
Process: com.google.android.apps.nexuslauncher, PID: 10288
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String)' on a null object reference
at android.os.Parcel.createException(Parcel.java:1948)
at android.os.Parcel.readException(Parcel.java:1865)
at android.app.IActivityManager$Stub$Proxy.startActivity(IActivityManager.java:4541)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1660)
at android.app.Activity.startActivityForResult(Activity.java:4574)
at com.android.launcher3.Launcher.startActivityForResult(SourceFile:1394)
at android.app.Activity.startActivity(Activity.java:4889)
at com.android.launcher3.Launcher.startActivitySafely(SourceFile:2000)
at com.android.launcher3.Launcher.startAppShortcutOrInfoActivity(SourceFile:1850)
at com.android.launcher3.Launcher.onClick(SourceFile:1703)
at android.view.View.performClick(View.java:6579)
at android.view.View.performClickInternal(View.java:6556)
at android.view.View.access$3100(View.java:777)
at android.view.View$PerformClick.run(View.java:25660)
at android.os.Handler.handleCallback(Handler.java:819)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6656)
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:823)
Caused by: android.os.RemoteException: Remote stack trace:
at android.app.LoadedApk.createAppFactory(LoadedApk.java:224)
at android.app.LoadedApk.<init>(LoadedApk.java:152)
at android.app.ActivityThread.getPackageInfo(ActivityThread.java:2043)
at android.app.ActivityThread.getPackageInfo(ActivityThread.java:1998)
at android.app.ActivityThread.getPackageInfo(ActivityThread.java:1970)
It is a problem of API P emulator. On API 28, 27 it works right.
As CoolMind said, It is a problem in API P emulator, you can solve it by updating your Google APIs Intel System Image in Android SDK.
Add these two lines in your gradle.properties file and then build project. After i added these lines, Android Studio showed stacktrace in Logcat.I fixed those issues and then my app started working.
android.enableD8.desugaring = true
android.enableR8 = true

java.lang.NoClassDefFoundError: com.google.android.gms.common.internal.zzbo

I know this question may be duplicate but I have tried many solutions but I am unable to make my app work. It should be noted that I have enabled Multidex but still getting below error. I am creating a react native app.
FATAL EXCEPTION: main
Process: com.xxxxxx.yyyyyyyy, PID: 3978
java.lang.NoClassDefFoundError: com.google.android.gms.common.internal.zzbo
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5049)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4623)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4563)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5333)
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:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
If you are developing a react native application and above error came , just make sure that all of your dependencies's Gradle are using same version of firebase servces and play service base.
For example :- my app level gradle file contains
compile "com.google.android.gms:play-services-base:11.4.0"
compile "com.google.firebase:firebase-core:11.4.0"
compile "com.google.firebase:firebase-messaging:11.4.0"
compile "com.google.firebase:firebase-analytics:11.4.0"
compile "com.google.firebase:firebase-crash:11.4.0"
compile "com.google.firebase:firebase-ads:11.4.0"
and one react-native library is using
compile "com.google.android.gms:play-services-base:11.8.0"
and other one library is using
compile "com.google.android.gms:play-services-base:+"
so what i did , i changed all services version to 11.8.0.
BTW you can see gradles of all libraries or dependencies when you open your react-native-project/android folder in Android studio
I hope this will solve your issue

android.view.InflateException for some devices (mostly Android 4.4)

I see quite a number of crashes of my Android application with an android.view.InflateException. Unfortunately, it does not happen on my device or simulators and the error is telling me nothing. I am assuming it works for most of the devices, the error is mostly occuring in Android 4.x and rarely on 5.
Could any of you help me? That would be great!
It seems to happen when the users open up my preference activity. Here is the stacktrace:
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5603)
at java.lang.reflect.Method.invokeNative(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method:0)
Caused by: android.view.InflateException:
at android.preference.GenericInflater.createItem(GenericInflater.java:397)
at android.preference.GenericInflater.onCreateItem(GenericInflater.java:417)
at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:428)
at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
at android.preference.GenericInflater.inflate(GenericInflater.java:326)
at android.preference.GenericInflater.inflate(GenericInflater.java:263)
at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:272)
at android.preference.PreferenceFragment.addPreferencesFromResource(PreferenceFragment.java:315)
at bloggersoft.sudokuoftheday.EinstellungenActivity$MyPreferenceFragment.onCreate(EinstellungenActivity.java:305)
at android.app.Fragment.performCreate(Fragment.java:1678)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:859)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1453)
at android.app.Activity.performStart(Activity.java:5467)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2386)
I have to apologize. The code I posted was the full output from the developer console stacktrace and did not help me as well, upon testing it in the right emulator the error was shown: I forgot to set a default value for a MultiSelectList preference. This fixed it.

Android/Adobe air crash report: java.lang.UnsatisfiedLinkError

i am getting this error inside Google's "Crashes & ANRs". The application built with Adobe Air and packaged as captive runtime.
java.lang.UnsatisfiedLinkError: nativeSurfaceCreated
at com.adobe.air.AIRWindowSurfaceView.nativeSurfaceCreated(Native Method)
at com.adobe.air.AIRWindowSurfaceView.surfaceCreated(AIRWindowSurfaceView.java:719)
at android.view.SurfaceView.updateWindow(SurfaceView.java:545)
at android.view.SurfaceView.access$000(SurfaceView.java:81)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:169)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:693)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1731)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2583)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4508)
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:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(Native Method)
Does anybody know what this means?
The UnsatisfiedLinkError for Java usually means that you tried to load a library called nativeSurfaceCreated. Basically your code called a method that called a method and so on, and some code somebody else wrote called a native method. This native method loaded a library called nativeSurfaceCreated, which you don't have. This is usually packaged in a dll in Windows or a so file in Linux. If you can find this dll/so file, you can probably run whatever you're running.

Categories