Thread : Crash with the message "java.lang.RuntimeException: Unable to instantiate activity" - android

i know this question has been treated so much time, but i really don't find the answer to my problem.
This is an application which connect to a server, so, there's a socket, that's why i'm using thread (i can't do anything else since android 4.0), but even if i'm disable the code of my socket, it still crash.
Here's the logCat error :
04-08 08:36:39.366: D/AndroidRuntime(16604): Shutting down VM
04-08 08:36:39.366: W/dalvikvm(16604): threadid=1: thread exiting with uncaught exception (group=0x4122f300)
04-08 08:36:39.366: E/AndroidRuntime(16604): FATAL EXCEPTION: main
04-08 08:36:39.366: E/AndroidRuntime(16604): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.projetlyres2013/com.example.projetlyres2013.PlanDMX}: java.lang.NullPointerException
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.os.Looper.loop(Looper.java:137)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-08 08:36:39.366: E/AndroidRuntime(16604): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 08:36:39.366: E/AndroidRuntime(16604): at java.lang.reflect.Method.invoke(Method.java:511)
04-08 08:36:39.366: E/AndroidRuntime(16604): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-08 08:36:39.366: E/AndroidRuntime(16604): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-08 08:36:39.366: E/AndroidRuntime(16604): at dalvik.system.NativeStart.main(Native Method)
04-08 08:36:39.366: E/AndroidRuntime(16604): Caused by: java.lang.NullPointerException
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.Activity.findViewById(Activity.java:1825)
04-08 08:36:39.366: E/AndroidRuntime(16604): at com.example.projetlyres2013.PlanDMX.<init>(PlanDMX.java:27)
04-08 08:36:39.366: E/AndroidRuntime(16604): at java.lang.Class.newInstanceImpl(Native Method)
04-08 08:36:39.366: E/AndroidRuntime(16604): at java.lang.Class.newInstance(Class.java:1319)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
04-08 08:36:39.366: E/AndroidRuntime(16604): ... 11 more
04-08 08:36:41.326: I/Process(16604): Sending signal. PID: 16604 SIG: 9
04-08 08:46:26.556: D/AndroidRuntime(16825): Shutting down VM
///////// Manifest /////////
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.projetlyres2013"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.projetlyres2013.PlanDMX"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I don't know what's happened when i want to launch it on my tablet (android 4.1).
I really need help for that :/
Thanks

NullPointer here means that you did not set your layout XML as contentView to your Activity.
Inside onCreate(...) method of Activity add
setContentView(R.layout.some_layout-file)

Related

when we run our application then it shows unfortunetly,application has stopped

04-08 00:46:02.390: D/AndroidRuntime(918): Shutting down VM
04-08 00:46:02.390: W/dalvikvm(918): threadid=1: thread exiting with uncaught exception (group=0xb4acab90)
04-08 00:46:02.420: E/AndroidRuntime(918): FATAL EXCEPTION: main
04-08 00:46:02.420: E/AndroidRuntime(918): Process: net.gnobal.dindy, PID: 918
04-08 00:46:02.420: E/AndroidRuntime(918): java.lang.RuntimeException: Unable to instantiate application net.gnobal.dindy.DindyApplication: java.lang.ClassNotFoundException: Didn't find class "net.gnobal.dindy.DindyApplication" on path: DexPathList[[zip file "/data/app/net.gnobal.dindy-1.apk"],nativeLibraryDirectories=[/data/app-lib/net.gnobal.dindy-1, /system/lib]]
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4298)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.ActivityThread.access$1400(ActivityThread.java:135)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1457)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.os.Handler.dispatchMessage(Handler.java:102)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.os.Looper.loop(Looper.java:137)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.ActivityThread.main(ActivityThread.java:4998)
04-08 00:46:02.420: E/AndroidRuntime(918): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 00:46:02.420: E/AndroidRuntime(918): at java.lang.reflect.Method.invoke(Method.java:515)
04-08 00:46:02.420: E/AndroidRuntime(918): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
04-08 00:46:02.420: E/AndroidRuntime(918): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
04-08 00:46:02.420: E/AndroidRuntime(918): at dalvik.system.NativeStart.main(Native Method)
04-08 00:46:02.420: E/AndroidRuntime(918): Caused by: java.lang.ClassNotFoundException: Didn't find class "net.gnobal.dindy.DindyApplication" on path: DexPathList[[zip file "/data/app/net.gnobal.dindy-1.apk"],nativeLibraryDirectories=[/data/app-lib/net.gnobal.dindy-1, /system/lib]]
04-08 00:46:02.420: E/AndroidRuntime(918): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-08 00:46:02.420: E/AndroidRuntime(918): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
04-08 00:46:02.420: E/AndroidRuntime(918): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.Instrumentation.newApplication(Instrumentation.java:975)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
04-08 00:46:02.420: E/AndroidRuntime(918): ... 11 more
04-08 00:46:07.430: I/Process(918): Sending signal. PID: 918 SIG: 9
Check your package name and also check whether the class name i.e activity is properly registered in the manifest.

Read DOCx,PPTx,XLSx Files from Android using Apache POI libs - Android

I am creating android app that is reading microsoft files without any third party application, I have used Apache POI lib. for reading/Open office files , I am able to open doc,ppt and xls file but not able to open DOCx,PPTx,XLSx , I had tried below code to read
FileInputStream inputStream = new FileInputStream(new File(getIntent().getStringExtra(Constants.FILEPATH)));
// getResources().getAssets().open("doc2.doc");
XWPFDocument xwpfDocument = new XWPFDocument(inputStream);
xwpfDocument.getXWPFDocument();
xwpfDocument.getBodyElements();
It throws exception as below
04-08 05:34:20.407: E/AndroidRuntime(1222): FATAL EXCEPTION: main
04-08 05:34:20.407: E/AndroidRuntime(1222): java.lang.ExceptionInInitializerError
04-08 05:34:20.407: E/AndroidRuntime(1222): at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:154)
04-08 05:34:20.407: E/AndroidRuntime(1222): at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
04-08 05:34:20.407: E/AndroidRuntime(1222): at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:37)
04-08 05:34:20.407: E/AndroidRuntime(1222): at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:83)
04-08 05:34:20.407: E/AndroidRuntime(1222): at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:272)
04-08 05:34:20.407: E/AndroidRuntime(1222): at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39)
04-08 05:34:20.407: E/AndroidRuntime(1222): at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:121)
04-08 05:34:20.407: E/AndroidRuntime(1222): at com.narola.yujidownloader.OfficeActivity.populateWordX(OfficeActivity.java:605)
04-08 05:34:20.407: E/AndroidRuntime(1222): at com.narola.yujidownloader.OfficeActivity.populate(OfficeActivity.java:139)
04-08 05:34:20.407: E/AndroidRuntime(1222): at com.narola.yujidownloader.OfficeActivity.initialize(OfficeActivity.java:111)
04-08 05:34:20.407: E/AndroidRuntime(1222): at com.narola.yujidownloader.OfficeActivity.onCreate(OfficeActivity.java:96)
04-08 05:34:20.407: E/AndroidRuntime(1222): at android.app.Activity.performCreate(Activity.java:5008)
04-08 05:34:20.407: E/AndroidRuntime(1222): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
04-08 05:34:20.407: E/AndroidRuntime(1222): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
04-08 05:34:20.407: E/AndroidRuntime(1222): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-08 05:34:20.407: E/AndroidRuntime(1222): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-08 05:34:20.407: E/AndroidRuntime(1222): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-08 05:34:20.407: E/AndroidRuntime(1222): at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 05:34:20.407: E/AndroidRuntime(1222): at android.os.Looper.loop(Looper.java:137)
04-08 05:34:20.407: E/AndroidRuntime(1222): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-08 05:34:20.407: E/AndroidRuntime(1222): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 05:34:20.407: E/AndroidRuntime(1222): at java.lang.reflect.Method.invoke(Method.java:511)
04-08 05:34:20.407: E/AndroidRuntime(1222): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-08 05:34:20.407: E/AndroidRuntime(1222): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-08 05:34:20.407: E/AndroidRuntime(1222): at dalvik.system.NativeStart.main(Native Method)
04-08 05:34:20.407: E/AndroidRuntime(1222): Caused by: java.lang.NoClassDefFoundError: org.dom4j.Namespace
04-08 05:34:20.407: E/AndroidRuntime(1222): at org.apache.poi.openxml4j.opc.internal.unmarshallers.PackagePropertiesUnmarshaller.<clinit>(PackagePropertiesUnmarshaller.java:49)
I have referred Apchae POI docx
Please guide me

iqengines demo app crashes

I'm trying to integrate iqengines sdk in my app(https://github.com/iqengines/iqe-android-sdk). i started with their demo app which i could not run properly.Installed Android NDK and Cygwin 1.7. also i have added the ANDROID_NDK_ROOT under eclipse substring and and modified API keys(https://github.com/iqengines/iqe-android-sdk#building-the-demo-app-). still the app crashes.
here is the stack trace.
04-08 14:32:25.181: E/AndroidRuntime(7610): FATAL EXCEPTION: main
04-08 14:32:25.181: E/AndroidRuntime(7610): java.lang.ExceptionInInitializerError
04-08 14:32:25.181: E/AndroidRuntime(7610): at com.iqengines.sdk.IQE.initIqSdk(IQE.java:249)
04-08 14:32:25.181: E/AndroidRuntime(7610): at com.iqengines.sdk.IQE.(IQE.java:224)
04-08 14:32:25.181: E/AndroidRuntime(7610): at com.iqengines.demo.DemoActivity.initIqSdk(DemoActivity.java:161)
04-08 14:32:25.181: E/AndroidRuntime(7610): at com.iqengines.demo.DemoActivity.onCreate(DemoActivity.java:133)
04-08 14:32:25.181: E/AndroidRuntime(7610): at android.app.Activity.performCreate(Activity.java:5206)
04-08 14:32:25.181: E/AndroidRuntime(7610): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
04-08 14:32:25.181: E/AndroidRuntime(7610): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
04-08 14:32:25.181: E/AndroidRuntime(7610): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
04-08 14:32:25.181: E/AndroidRuntime(7610): at android.app.ActivityThread.access$700(ActivityThread.java:140)
04-08 14:32:25.181: E/AndroidRuntime(7610): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
04-08 14:32:25.181: E/AndroidRuntime(7610): at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 14:32:25.181: E/AndroidRuntime(7610): at android.os.Looper.loop(Looper.java:137)
04-08 14:32:25.181: E/AndroidRuntime(7610): at android.app.ActivityThread.main(ActivityThread.java:4935)
04-08 14:32:25.181: E/AndroidRuntime(7610): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 14:32:25.181: E/AndroidRuntime(7610): at java.lang.reflect.Method.invoke(Method.java:511)
04-08 14:32:25.181: E/AndroidRuntime(7610): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
04-08 14:32:25.181: E/AndroidRuntime(7610): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
04-08 14:32:25.181: E/AndroidRuntime(7610): at dalvik.system.NativeStart.main(Native Method)
04-08 14:32:25.181: E/AndroidRuntime(7610): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load iqindex: findLibrary returned null
04-08 14:32:25.181: E/AndroidRuntime(7610): at java.lang.Runtime.loadLibrary(Runtime.java:365)
04-08 14:32:25.181: E/AndroidRuntime(7610): at java.lang.System.loadLibrary(System.java:535)
04-08 14:32:25.181: E/AndroidRuntime(7610): at com.iqengines.sdk.IQLocal.(IQLocal.java:34)
04-08 14:32:25.181: E/AndroidRuntime(7610): ... 18 more
I think this is because of the issues related to NDK and Windows 8. I switched to Ubuntu and it works fine.

NullPointerException error for Camera Parameters

I have the following code:
Line Code
193 private Camera mCamera;
<!-- NO CALLS TO mCamera HERE -->
229 mCamera = Camera.open();
230 Camera.Parameters p = mCamera.getParameters();
And when I run the application I get the following stacktrace:
04-08 20:56:45.330: E/AndroidRuntime(570): FATAL EXCEPTION: main
04-08 20:56:45.330: E/AndroidRuntime(570): java.lang.NullPointerException
04-08 20:56:45.330: E/AndroidRuntime(570): at com.soloman.cbc.FullscreenActivity$MySurfaceView.surfaceCreated(FullscreenActivity.java:230)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.SurfaceView.updateWindow(SurfaceView.java:569)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.SurfaceView.access$000(SurfaceView.java:86)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:174)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:680)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1842)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.Choreographer.doFrame(Choreographer.java:532)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.os.Handler.handleCallback(Handler.java:725)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.os.Handler.dispatchMessage(Handler.java:92)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.os.Looper.loop(Looper.java:137)
04-08 20:56:45.330: E/AndroidRuntime(570): at android.app.ActivityThread.main(ActivityThread.java:5039)
04-08 20:56:45.330: E/AndroidRuntime(570): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 20:56:45.330: E/AndroidRuntime(570): at java.lang.reflect.Method.invoke(Method.java:511)
04-08 20:56:45.330: E/AndroidRuntime(570): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-08 20:56:45.330: E/AndroidRuntime(570): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-08 20:56:45.330: E/AndroidRuntime(570): at dalvik.system.NativeStart.main(Native Method)
The code I am using is from How can I manipulate the camera preview?
I have the CAMERA permission in the AndroidManifest.xml, and all imports are accounted for. Does anyone have any suggestions on how to fix this error?
Thank you.
On devices without back-facing camera Camera.open() returns null. Try Camera.open(0) to get front camera.
if the android version is prior to 3.0 use the
getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

Force Close error on Android Application

I have added the Results class to the Android Manifest, so yes, you can cross that off the list.
Is it an error in the way I've set out the method?
package com.kenning.foreveralone;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
public class Results extends Activity{
EditText fbFriends;
TextView resulting;
String value;
#Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.rslt);
TextView resulting = (TextView) findViewById(R.id.result);
EditText fbFriends = (EditText) findViewById(R.id.noFacebookFriends);
String value = fbFriends.getText().toString();
resulting.setText("Your score is " + value);
}
}
When I start this class, it always seems to force close my app. Can anyone tell me what I'm doing wrong?
Here's the log cat:
04-08 20:05:24.169: E/AndroidRuntime(589): FATAL EXCEPTION: main
04-08 20:05:24.169: E/AndroidRuntime(589): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kenning.foreveralone/com.kenning.foreveralone.Results}: java.lang.NullPointerException
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.os.Looper.loop(Looper.java:123)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-08 20:05:24.169: E/AndroidRuntime(589): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 20:05:24.169: E/AndroidRuntime(589): at java.lang.reflect.Method.invoke(Method.java:521)
04-08 20:05:24.169: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-08 20:05:24.169: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-08 20:05:24.169: E/AndroidRuntime(589): at dalvik.system.NativeStart.main(Native Method)
04-08 20:05:24.169: E/AndroidRuntime(589): Caused by: java.lang.NullPointerException
04-08 20:05:24.169: E/AndroidRuntime(589): at com.kenning.foreveralone.Results.onCreate(Results.java:20)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-08 20:05:24.169: E/AndroidRuntime(589): ... 11 more
It's a null pointer exception in onCreate, so why not try stepping through onCreate to see what variable is null?
That said, I'm guessing R.id.noFacebookFriends is not part of the R.layout.rslt.
You are getting a NullPointerException somewhere in your OnCreate. I am guessing that either the ids are wrong in your rslt.xml layout so result and fbFriends is null, or fbFriends doesn't have any text in it so getText() returns null.

Categories

Resources