I am trying to Create side bar navigation in android but there is one problem I am facing.I went through so many post on stackoverflow but it didn't solved my problem
I am following the tutorial exactly mentioned here
But when I a running my app I am getting error
Process: com.example.deepak.myapplication, PID: 26704
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.deepak.myapplication/com.example.deepak.myapplication.Naviagtion}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2721)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2782)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1521)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6228)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
at com.example.deepak.myapplication.Naviagtion.onCreate(Naviagtion.java:29)
at android.app.Activity.performCreate(Activity.java:6871)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2674)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2782)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1521)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6228)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
I am using styles as mentioned
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
Also I am Extending AppCompatActivity
So please help me and let me know where I am going wrong
you have not set ActionBar, put this line above
setSupportActionBar(toolbar); // <--- put this
ActionBar.setDisplayHomeAsUpEnabled(true)
Related
native ad mobile opened. This error is causing this error for me. I tried to fix this error several times but I could not fix it. Native ad is causing this error.
Error
*E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 19618
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.ads.AdView.setAdSize(com.google.android.gms.ads.AdSize)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3318)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3429)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2009)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7555)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.ads.AdView.setAdSize(com.google.android.gms.ads.AdSize)' on a null object reference
at com.example.myapplication.MainActivity.loadBanner(MainActivity.java:59)
at com.example.myapplication.MainActivity.onCreate(MainActivity.java:38)
at android.app.Activity.performCreate(Activity.java:7343)
at android.app.Activity.performCreate(Activity.java:7333)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1219)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3271)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3429)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2009)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7555)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
I/Process: Sending signal. PID: 19618 SIG: 9*
I guess you are using the Admob Adaptive Banner. If so, then you are probably missing an instance of AdView. Make sure that you have the following code in onCreateView and call loadBanner() function after the instance of AdView is created:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
adContainerView = findViewById(R.id.ad_view_container);
adView = new AdView(this);
adView.setAdUnitId(getString(R.string.adaptive_banner_ad_unit_id));
adContainerView.addView(adView);
loadBanner();
}
From The Official Document:
you want to use AdSize from com.google.android.gms.ads and it returns null. you can declare the size of BANNER, or
I recommend that you use Firebase - Ads.
I hope I have helped.
I tried to run my APP, I just ended up getting a message "MegaVidi Stopped Working", I tried to run some tests and got the following errors
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.megatechnologyteam.megavidi/com.megatechnologyteam.megavidi.SplashActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.appcompat.app.ActionBar.hide()' on a null object reference
FATAL EXCEPTION: main
Process: com.megatechnologyteam.megavidi, PID: 10886
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.megatechnologyteam.megavidi/com.megatechnologyteam.megavidi.SplashActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.appcompat.app.ActionBar.hide()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
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.NullPointerException: Attempt to invoke virtual method 'void androidx.appcompat.app.ActionBar.hide()' on a null object reference
at com.megatechnologyteam.megavidi.SplashActivity.onCreate(SplashActivity.java:20)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
How do I solve this so that my APP can run properly?
Help me please
Please locate the object in your code
com.megatechnologyteam.megavidi.SplashActivity.onCreate(SplashActivity.java:20)
There should have an object of the class ActionBar attempting calling hide().
This just object is actually null. Please check.
In SplashActivity you are trying to hide the ActionBar which is null (that is why you are getting NullPointerException).
To resolve the issue, remove the line where you are calling ActionBar.hide().
I cannot tell you more than this without seeing the code of SplashActivity.
This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 4 years ago.
Now that i finally got Firebase connected im having a Problem with The Authentification. Its a NullpointerException in Line 47 but i dont get why, maybe im just overlooking something or i cannot find the issue
Stacktrace:
05-14 20:57:52.413 8315-8315/com.github.compete E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.github.compete, PID: 8315
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.github.compete/com.github.compete.MainActivityMenu}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.github.compete.MainActivityMenu.onCreate(MainActivityMenu.java:47)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
Code in Line 47:findViewById(R.id.nav_camera).setOnClickListener(this);
I dont see the problem, maybe i should stop for today.
-Thanks
There is no view having as id nav_camera in your view.
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.
I want to use Volley to pull some JSON data from a Service class, but I keep receiving File Cache crashes at RequestQueue mRequestQueue = Volley.newRequestQueue(this); in the service class.
It works fine in my main application.
Edit
FATAL EXCEPTION: main
Process: com.xxx.yyy, PID: 28290
java.lang.RuntimeException: Unable to instantiate service
com.idlctech.etherpooler.PoolerService:
java.lang.NullPointerException: Attempt to invoke virtual method
'android.content.Context
android.content.Context.getApplicationContext()' on a null object
reference
at
android.app.ActivityThread.handleCreateService(ActivityThread.java:3121)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1530)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5969)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:801)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual
method 'android.content.Context
android.content.Context.getApplicationContext()' on a null object
reference
at
android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:106)
at
xxx.yyy.zzz.PoolerService.(PoolerService.java:38)
at java.lang.Class.newInstance(Native Method)
at
android.app.ActivityThread.handleCreateService(ActivityThread.java:3118)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1530)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5969)
Define the service in the manifest.
<application ... >
<service android:name=".ExampleService" />
...
</application>
Look at this post. With the code you have provided us that's all I can think of.
I wasn't passing the correct context.