nullpointerexception

How to log hard finding crash in Android?

こ雲淡風輕ζ 提交于 2020-01-24 15:48:08
问题 I've an app which crash almost once a day, and I've used the default uncaught exception handler in order to save the crash log e.g. Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler("/sdcard/crash")); However, for normal crash such as stackoverflow (intentional) it can be logged, but for my bug it never get logged. I guess it is because the crash is raised outside the scope of a normal activity. (yes, the crash happen when the app is in the background) I've also tried to

NullPointerException when accessing RelativeLayout from a custom view

别等时光非礼了梦想. 提交于 2020-01-24 12:42:07
问题 I am relatively new to Android and am completely stuck on how to access my programmatically-defined Relative Layout (defined in a fragment) in my custom View. In the fragment, this is what I have: ... @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment1, container,false); RelativeLayout rl1 = new RelativeLayout(view.getContext()); TextView tView1 = new TextView(view.getContext()); tView1

findViewById returns null for WebView

谁说胖子不能爱 提交于 2020-01-24 07:23:07
问题 I'm trying to build an android app, which just consists of a webview. I took the example from android dev site and modified it. But as simple as it looks, every call to findViewById results in a null pointer. The .java file: public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WebView webView = (WebView) findViewById(R.id.webview); // returns null pointer webView.loadUrl("file:///android_asset/index

NullPointerException org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:37)

主宰稳场 提交于 2020-01-24 03:51:05
问题 Got the following stacktrace when launching gradle 1.1, anyone know how to resolve them: Exception in thread "main" java.lang.NullPointerException at org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:37) at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:28) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:47) I think the automatic unzip of the

Error android.graphics.Canvas.throwIfRecycled when overlaying bitmaps

梦想与她 提交于 2020-01-24 03:05:14
问题 Im trying to overlay images on a canvas using the following method: private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) { bmOverlay = Bitmap.createBitmap(70, 70, Bitmap.Config.RGB_565); canvas = new Canvas(bmOverlay); canvas.drawBitmap(bmp1, 0, 0, null); //line 179 canvas.drawBitmap(bmp2, 0, 0, null); return bmOverlay; } However, my app keeps crashing and the log reads: java.lang.NullPointerException at android.graphics.Canvas.throwIfRecycled(Canvas.java:954) at android.graphics.Canvas

mservice NPE on Android 5.0 devices

与世无争的帅哥 提交于 2020-01-23 18:21:10
问题 I'm having an issue similar to the question found here: Google In-App billing, IllegalArgumentException: Service Intent must be explicit, after upgrading to Android L Dev Preview. I have tried the solution in the suggested answer:https://stackoverflow.com/a/26318757/1489990 but I am getting an issue specifically on my nexus 9 with android 5.0.1 (and I'm assuming this also applies to all devices with android 5.0). The issue is that with this code: connection = new ServiceConnection() {

Android Activity — NullPointerException (“unable to instantiate activity ComponentInfo”)?

喜欢而已 提交于 2020-01-22 16:51:02
问题 I'm trying to create a program for Android which will read in text, and then print it out, jsut to get used to using I/O for Android. However, whenever I run it on the AVD, it returns an error in LogCat saying that there is a NullPointerException in my code, and that it is therefore "unable to instantiate activity ComponentInfo". I can't find where I'm referring to anything null. Here is my code: import android.app.*; import android.os.*; import android.view.View; import android.view.View.*;

Android Activity — NullPointerException (“unable to instantiate activity ComponentInfo”)?

自作多情 提交于 2020-01-22 16:49:17
问题 I'm trying to create a program for Android which will read in text, and then print it out, jsut to get used to using I/O for Android. However, whenever I run it on the AVD, it returns an error in LogCat saying that there is a NullPointerException in my code, and that it is therefore "unable to instantiate activity ComponentInfo". I can't find where I'm referring to anything null. Here is my code: import android.app.*; import android.os.*; import android.view.View; import android.view.View.*;

Communicating between the tablayout Fragments [duplicate]

本秂侑毒 提交于 2020-01-22 04:06:00
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 3 months ago . I used a tab layout with fragment. The scenario goes like this. Activity: Fragment 1 , Fragment2 , Fragment3 From Fragment2 Updating the UI of Fragment1. I tried to access the methods from fragment but resulting null pointer exception . 回答1: You may use Observer Pattern to achieve this. To do this, You have to create a MutableLiveData in your MainActivity and pass

NullPointerException ViewPager SetAdapter

落爺英雄遲暮 提交于 2020-01-22 02:35:09
问题 I am adding a tab view or (ViewPager) to my Fragment in an App I am working on. I want to put the tab view inside the Contact Fragment I have a Navigation Drawer that opens, and you see list of options... Home Services Contact Everything you click goes to a fragment Then in that fragment loads the .XML file, with a corresponding class to program everything inside the .XML file. I was following an online tutorial [CLICK HERE][3] Obviously it was over 2 years ago. Android Code has changed since