java.lang.RuntimeException: Unable to start activity ComponentInfo by library - android

I used this library https://github.com/liuguangqiang/IPicker
This is my code:
public void onClick(View view) {
switch (view.getId()) {
case R.id.ll_profile_pic_container:
IPicker.open(getApplicationContext(), selectPictures);
return;
...
}
This is the error I receive when in activity com.liuguangqiang.ipicker.IPickerActivity I select my image from the gallery:
java.lang.RuntimeException: Unable to start activity ComponentInfo{rp.com.bmicalculator/com.liuguangqiang.ipicker.crop.CropImageActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setHomeAsUpIndicator(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setHomeAsUpIndicator(int)' on a null object reference
at com.liuguangqiang.ipicker.crop.CropImageActivity.initToolbar(CropImageActivity.java:116)
at com.liuguangqiang.ipicker.crop.CropImageActivity.onCreate(CropImageActivity.java:91)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 I've followed all the directions I've provided from the library author ... Can the bug be in the library? No, because I've tested the app created by the same author and everything works perfectly ...

So, I installed the library you mentioned. Everything seems to work well. Maybe you are using AppTheme with no ActionBar?

Related

Why am I getting java.lang.NoClassDefFoundError when calling getDrawable?

I am trying to change the icon on a button inside a ListView at runtime, but when my code has calls to getDrawable, e.g.
getDrawable(android.R.drawable.ic_media_pause)
I get java.lang.NoClassDefFoundError from inside the activity's onCreate method. When I remove calls to getDrawable, the app runs fine.
01-29 18:31:43.526 30890-30890/com.p403n1x87.motee E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.p403n1x87.motee, PID: 30890
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/p403n1x87/motee/device/DeviceActivity$onCreate$adapter$1$1;
at com.p403n1x87.motee.device.DeviceActivity.onCreate(DeviceActivity.kt:40)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.p403n1x87.motee.device.DeviceActivity$onCreate$adapter$1$1" on path: DexPathList[[zip file "/data/app/com.p403n1x87.motee-1/base.apk"],nativeLibraryDirectories=[/data/app/com.p403n1x87.motee-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.p403n1x87.motee.device.DeviceActivity.onCreate(DeviceActivity.kt:40) 
at android.app.Activity.performCreate(Activity.java:6251) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException: com.p403n1x87.motee.device.DeviceActivity$onCreate$adapter$1$1
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
After seeing the same error when trying to get the intent from the activity inside an anonymous class instance, I realised that I should have explicitly requested the method from it, i.e. it.getDrawable. Given that the build process completes successfully, this looks like a Kotlin bug to me.

Android log cat error

The logcat message shows this:
12-05 19:24:09.406 28495-28495/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.user.fragment, PID: 28495
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.fragment/com.example.user.fragment.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.example.user.fragment.MainActivity.onCreate(MainActivity.java:25)
at android.app.Activity.performCreate(Activity.java:6672)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6123) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757) 
The app has suddenly stopped working. What could be the possible error?
You have button defined in Activity file, and you are accessing layout button but which is actually not there. Please check at your end.

Android - ResourceNotFoundException and NumberFormatException

I have created an app in which I've used android.support.v4.widget.DrawerLayout along with android.support.v7.widget.Toolbar.
When I run this app on a Samsung Tablet Neo (Android version 4.2.2), the app is running perfectly.
But when I run the same app on Google Nexus 5 (Android version 6.0.1), I'm getting ResourceNotFoundException and the app just crashes on the starting line of the following code in my Java (Activity) file.
The app crashes on this line: setSupportActionBar(topToolBar);
FATAL EXCEPTION: main
rocess: com.myapp, PID: 11761
va.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.MainActivityWithNavigationViewExpandableList}: android.content.res.Resources$NotFoundException: File res/color/abc_hint_foreground_material_dark.xml from color state list resource ID #0x7f0c00ab
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
aused by: android.content.res.Resources$NotFoundException: File res/color/abc_hint_foreground_material_dark.xml from color state list resource ID #0x7f0c00ab
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2750)
at android.content.res.Resources.loadColorStateList(Resources.java:2699)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:485)
at android.widget.TextView.<init>(TextView.java:746)
at android.widget.TextView.<init>(TextView.java:671)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:54)
at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:756)
at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261)
at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243)
at android.support.v7.app.ToolbarActionBar.<init>(ToolbarActionBar.java:78)
at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:223)
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:130)
at com.myapp.MainActivityWithNavigationViewExpandableList.onCreate(MainActivityWithNavigationViewExpandableList.java:64)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
aused by: java.lang.NumberFormatException: Invalid float: "0.70000005dip"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:164)
at java.lang.StringToReal.parseFloat(StringToReal.java:323)
at java.lang.Float.parseFloat(Float.java:306)
at android.content.res.TypedArray.getFloat(TypedArray.java:396)
at android.content.res.ColorStateList.inflate(ColorStateList.java:275)
at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:222)
at android.content.res.ColorStateList.createFromXml(ColorStateList.java:201)
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2746)
at android.content.res.Resources.loadColorStateList(Resources.java:2699) 
at android.content.res.TypedArray.getColorStateList(TypedArray.java:485) 
at android.widget.TextView.<init>(TextView.java:746) 
at android.widget.TextView.<init>(TextView.java:671) 
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62) 
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58) 
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:54) 
at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:756) 
at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261) 
at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243) 
at android.support.v7.app.ToolbarActionBar.<init>(ToolbarActionBar.java:78) 
at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:223) 
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:130) 
at com.myapp.MainActivityWithNavigationViewExpandableList.onCreate(MainActivityWithNavigationViewExpandableList.java:64) 
at android.app.Activity.performCreate(Activity.java:6251) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
I searched other SO answers as well.
The resource 'abc_hint_foreground_material_dark' is not in my 'color'. This resource should come from Support Library of Android, which I'm using in Android Studio.
abc_hint_foreground_material_dark is a link to the theme's foreground_material_dark, see here.
The NumberFormatException says that this color value is invalid ('Invalid float: "0.70000005dip"'). This value does not come from support library so must have been set by your resources (check colors.xml and values.xml). Color values should be hex integers and are not in dp or any other unit. See here for more info.
So finally I digged more in the issue and my suspect was NumberFormatException. I searched for decimal values in my dimens.xml file and commented them. And it worked fine now. Basically, Android was unable to parse the decimal values placed in dimens.xml file.

Google Play Store suddently began crashing every time I open it

Suddently, during regular usage of my Nexus 5, the Google Play Store started crashing every time I try to open it.
So, I tried to get the log of the error, here it is:
11664-11664/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.android.vending, PID: 11664
java.lang.RuntimeException: Unable to create application com.google.android.finsky.FinskyApp: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.AppOpsManager.checkPackage(int, java.lang.String)' on a null object reference
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334)
at android.app.ActivityThread.handleBindApplication(<Xposed>)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.AppOpsManager.checkPackage(int, java.lang.String)' on a null object reference
at android.os.Parcel.readException(Parcel.java:1605)
at android.os.Parcel.readException(Parcel.java:1552)
at android.content.pm.IPackageInstaller$Stub$Proxy.getMySessions(IPackageInstaller.java:385)
at android.content.pm.PackageInstaller.getMySessions(PackageInstaller.java:415)
at com.google.android.finsky.installer.PackageInstallerImpl.<init>(PackageInstallerImpl.java:71)
at com.google.android.finsky.installer.PackageInstallerFactory.init(PackageInstallerFactory.java:23)
at com.google.android.finsky.FinskyApp.onCreate(FinskyApp.java:387)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334) 
at android.app.ActivityThread.handleBindApplication(<Xposed>) 
at android.app.ActivityThread.-wrap1(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102) `
I tried to look for this error online, but couldn't find anything. I assume it's related to some system app that has one of her permissions unapproved (I don't know which could be the one), or maybe related to my Xposed Framework installation.
What could it be?
Thank you for your help.
its not any other problem did you see Attempt to invoke virtual method 'void android.app.AppOpsManager.checkPackage(int, java.lang.String)' on a null object reference. you have calling some null object reference.

Android Marshmallow Keystore SecurityException

I'm trying to implement functionality similar to Android Keystore Direct access. The code is making use of IPC and an exception is thrown when mRemote.transact was called (IKeystoreService.java line 54)
This works well on versions of Android before Marshmallow (API 23). I know the permissions model has changed since.
The exception is:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.activity.MainActivity}: java.lang.SecurityException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.SecurityException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at com.example.utilities.security.IKeystoreService$Stub$Proxy.test(IKeystoreService.java:55)
at com.example.utilities.security.KeyStoreKk.state(KeyStoreKk.java:93)
at com.example.utilities.security. Cryto.isPasswordPinEnabled(Cryto.java:198)
at com.example.activity.MainActivity.onCreate(MainActivity.java:65)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Is there a particular permission I need to check for during runtime? Or is this another problem altogether?

Categories

Resources