Articles of nullpointerexception

如何解决这个问题:’运行android lint’问题

在我的项目的任何活动中,如果我做了一些更改,然后保存该活动,我得到消息“运行android lint遇到了问题。” 这是我的错误日志: java.lang.NullPointerException at com.android.ide.eclipse.adt.AdtUtils.workspacePathToFile(AdtUtils.java:466) at com.android.ide.eclipse.adt.internal.lint.EclipseLintClient.getClassPath(EclipseLintClient.java:753) at com.android.tools.lint.client.api.LintClient.getJavaClassFolders(LintClient.java:198) at com.android.tools.lint.detector.api.Project.getJavaClassFolders(Project.java:270) at com.android.tools.lint.client.api.LintDriver.checkIndividualClassFiles(LintDriver.java:977) at com.android.tools.lint.client.api.LintDriver.checkClasses(LintDriver.java:920) at com.android.tools.lint.client.api.LintDriver.runFileDetectors(LintDriver.java:785) at com.android.tools.lint.client.api.LintDriver.checkProject(LintDriver.java:661) at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.java:288) at com.android.ide.eclipse.adt.internal.lint.LintJob.run(LintJob.java:151) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)\ 我不知道如何解决这个问题。

尝试在空对象引用上调用虚方法’int android.text.Layout.getLineCount()’

我随机获得空指针exception,通常它工作,有时它崩溃,我搜索了很多,但没有得到任何帮助,因为没有正确的线从我得到任何帮助, 我也在使用处理程序。 我的logcat错误如下,代码添加在它下面, java.lang.NullPointerException: Attempt to invoke virtual method ‘int android.text.Layout.getLineCount()’ on a null object reference at android.widget.TextView.onMeasure(TextView.java:6703) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:17547) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at android.support.v7.internal.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at […]

java.lang.NullPointerException:println需要一条消息

我得到了错误:java.lang.NullPointerException:println在使用这个方法时需要一条消息: lst_info = new HashMap(); SystemDatabaseHandler db = new SystemDatabaseHandler(getApplicationContext()); lst_info = db.getLstInfo(sql_id); SystemDatabaseHandler: public HashMap getLstInfo(int id){ HashMap lst_temp; lst_temp = new HashMap(); String selectQuery = “SELECT * FROM dkr_lst_lst WHERE lst_id = ” + id; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { Log.d(“sql_id”, cursor.getString(0)); lst_temp.put(“sql_id”, cursor.getString(0)); […]

getActionBar()setDisplayHomeAsUpEnabled(真)。 在新活动创建时抛出NullPointerException(Google – Basic Tutorial)

我正在遵循本教程并在此代码块的DisplayMessageActivity的onCreate方法中获取NullPointerException: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // Show the Up button in the action bar. getActionBar().setDisplayHomeAsUpEnabled(true); //Exception here } 我正在使用NexusOne AVD模板在模拟器上运行应用程序。 当我点击发送按钮并输入一些文字时,我得到了例外。 这是日志: 09-03 23:02:07.586: E/AndroidRuntime(7095): FATAL EXCEPTION: main 09-03 23:02:07.586: E/AndroidRuntime(7095): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage.myfirstapp/com.mypackage.myfirstapp.DisplayMessageActivity}: java.lang.NullPointerException 09-03 23:02:07.586: E/AndroidRuntime(7095): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 09-03 23:02:07.586: E/AndroidRuntime(7095): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 09-03 23:02:07.586: E/AndroidRuntime(7095): at android.app.ActivityThread.access$600(ActivityThread.java:141) 09-03 […]

启动IntentService的空指针exception

我有一个我想要启动的IntentService。 当我这样做时,它会吐出这个: java.lang.RuntimeException: Unable to start service com.pec.testapp.service.NewsService@406bd940 with Intent { cmp=com.pec.testapp/.service.NewsService }: java.lang.NullPointerException at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2173) … (omitted for brevity) Caused by: java.lang.NullPointerException at android.app.IntentService.onStart(IntentService.java:110) at android.app.IntentService.onStartCommand(IntentService.java:118) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2160) … 10 more 我已经搜索了这个,并查看了尽可能多的类似StackOverflow问题。 然而,有一些微妙的差异,我无法解决。 首先,exception中没有引用任何类。 其次,通过更改上下文或双重检查来确定类似的问题,以确保它不为空。 我有代码检查是不是这样: public Context context; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); context = getApplicationContext(); if(context == null) Log.d(“PECAPP”,”Context is null”); […]

Android Studio v1.2.0启动错误:java.lang.NullPointerException

将Android Studio更新为v1.2.0后。 在启动时,我得到以下日志,无法打开Android Studio。 我正在使用Windows 7-64bit,看起来也像Ubuntu一样错误 此问题也在Android问题中报告,但仍然没有解决方案 java.lang.RuntimeException: java.lang.NullPointerException at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:178) at com.intellij.idea.MainImpl$1$1$1.run(MainImpl.java:52) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:738) at java.awt.EventQueue.access$300(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:699) at java.awt.EventQueue$3.run(EventQueue.java:697) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:708) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:362) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) Caused by: java.lang.NullPointerException at com.android.tools.idea.welcome.AndroidVirtualDevice.(AndroidVirtualDevice.java:81) at com.android.tools.idea.welcome.InstallComponentsPath.createComponentTree(InstallComponentsPath.java:89) at com.android.tools.idea.welcome.InstallComponentsPath.init(InstallComponentsPath.java:215) at com.android.tools.idea.wizard.DynamicWizardPath.attachToWizard(DynamicWizardPath.java:97) […]

Instrumentation.execStartActivity中的Android NullPointerException

我不断得到一些用户的轰鸣声例外: java.lang.NullPointerException at android.app.Instrumentation.execStartActivity(Instrumentation.java:1414) at android.app.Activity.startActivityForResult(Activity.java:2880) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817) at android.app.Activity.startActivity(Activity.java:2986) at com.google.android.gms.internal.bb$5.onClick(Unknown Source) at android.view.View.performClick(View.java:2535) at android.view.View$PerformClick.run(View.java:9130) at android.os.Handler.handleCallback(Handler.java:618) at android.os.Handler.dispatchMessage(Handler.java:123) at android.os.Looper.loop(SourceFile:351) at android.app.ActivityThread.main(ActivityThread.java:3826) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:538) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727) at dalvik.system.NativeStart.main(Native Method) 我在这里发现了一个类似的问题,但自4月以来它没有得到解决。 我所知道的是,它是在三星Galaxy Y(GT-S5360)上复制的,而我正在使用Google Maps Android API v2。 你知道我怎么能为此做一个解决方法?

将RelativeLayout用作自定义InfoWindow时出现NullPointerException

我正在尝试使用RelativeLayout作为我的标记的自定义InfoWindow ,但是每次调用showInfoWindow时showInfoWindow得到NullPointerException (通过点击Marker或以编程方式)。 我正在使用Google Maps Android API v2。 例外: FATAL EXCEPTION: main java.lang.NullPointerException at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:465) at android.view.View.measure(View.java:15172) at maps.ayi(Unknown Source) at maps.aya(Unknown Source) at maps.awa(Unknown Source) at maps.a.bd.a(Unknown Source) at maps.y.bw.b(Unknown Source) at maps.y.bw.a(Unknown Source) at maps.a.dh.a(Unknown Source) at maps.anc(Unknown Source) at maps.a.dw.a(Unknown Source) at maps.a.bd.c(Unknown Source) at maps.a.dq.onSingleTapConfirmed(Unknown Source) at maps.evonSingleTapConfirmed(Unknown Source) at maps.ejhandleMessage(Unknown […]

– java.lang.NullPointerException – null对象引用的setText

这就是我想要做几个小时的事情:我有一个MainActivity.java文件(在下面列出)和一个带有开始按钮的fragment_start.xml文件。 点击开始按钮应显示带有points- / round-和countdown-Textviews的activity_main.xml文件。 它不起作用,这是正在发生的事情: logcat告诉我: PID:1240 java.lang.NullPointerException:尝试在空对象引用上调用虚方法’void android.widget.TextView.setText(java.lang.CharSequence)’ 模拟器显示: 不幸的是,GAME已停止。 有必要提一下我在编程方面比较新吗? 谢谢你的建议! import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; public class MainActivity extends Activity implements View.OnClickListener { private int points; private int round; private int countdown; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); showStartFragment(); } private void newGame () { […]

NullPointerException的原因android.support.v7.widget.RecyclerView.onMeasure

我得到以下exception 01-27 11:15:15.756 18348-18348/com.example.pnimje.newswipelistview E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.NullPointerException at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:1764) at android.view.View.measure(View.java:15848) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:477) at android.view.View.measure(View.java:15848) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5008) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:15848) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5008) at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:453) at android.view.View.measure(View.java:15848) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5008) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:15848) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5008) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:15848) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5008) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2189) at android.view.View.measure(View.java:15848) […]