Im designing my first android application and keep coming up with the following error which is draining the life out of me and I do not understand it very well (Please find my Logcat (verbose), Java Code(this i played around with and this began to occur once started to work on my editButton and buttonUpdate bit. Does it have anything to do with the editStatus? I really think it may) and I have also put in my manifest file:
LOGCAT verbose
04-21 15:30:23.388: D/AndroidRuntime(276): Shutting down VM
04-21 15:30:23.388: W/dalvikvm(276): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-21 15:30:23.427: E/AndroidRuntime(276): FATAL EXCEPTION: main
04-21 15:30:23.427: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}: java.lang.ClassCastException: android.widget.TextView
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 15:30:23.427: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 15:30:23.427: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 15:30:23.427: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 15:30:23.427: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 15:30:23.427: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
04-21 15:30:23.427: E/AndroidRuntime(276): Caused by: java.lang.ClassCastException: android.widget.TextView
04-21 15:30:23.427: E/AndroidRuntime(276): at com.locator.demo.LocatorDemoActivity.onCreate(LocatorDemoActivity.java:21)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-21 15:30:23.427: E/AndroidRuntime(276): ... 11 more
04-21 15:35:23.607: I/Process(276): Sending signal. PID: 276 SIG: 9
04-21 15:50:32.127: D/AndroidRuntime(301): Shutting down VM
04-21 15:50:32.127: W/dalvikvm(301): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-21 15:50:32.147: E/AndroidRuntime(301): FATAL EXCEPTION: main
04-21 15:50:32.147: E/AndroidRuntime(301): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}: java.lang.ClassCastException: android.widget.TextView
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.os.Looper.loop(Looper.java:123)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 15:50:32.147: E/AndroidRuntime(301): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 15:50:32.147: E/AndroidRuntime(301): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 15:50:32.147: E/AndroidRuntime(301): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 15:50:32.147: E/AndroidRuntime(301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 15:50:32.147: E/AndroidRuntime(301): at dalvik.system.NativeStart.main(Native Method)
04-21 15:50:32.147: E/AndroidRuntime(301): Caused by: java.lang.ClassCastException: android.widget.TextView
04-21 15:50:32.147: E/AndroidRuntime(301): at com.locator.demo.LocatorDemoActivity.onCreate(LocatorDemoActivity.java:21)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-21 15:50:32.147: E/AndroidRuntime(301): ... 11 more
CODE:
package com.locator.demo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class LocatorDemoActivity extends Activity implements OnClickListener {
EditText editStatus;
Button buttonUpdate;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.locationstatus);
editStatus = (EditText)findViewById(R.id.edit_status);
buttonUpdate = (Button)findViewById(R.id.button_update);
buttonUpdate.setOnClickListener(this);
//have button 'listen' for click
}
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}
ANDROID Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.locator.demo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_main" >
<activity
android:name=".LocatorDemoActivity"
android:label="#string/app_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I have;
attempted to do adb kill-server and adb start-server and run it with an without an emulator as suggested in another post. Please be slightly understanding as my knowledge of eclipse and Java is pretty low and im learning.
Please help
As seen from this error:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}:
java.lang.ClassCastException: android.widget.TextView
And this one:
Caused by: java.lang.ClassCastException: android.widget.TextView
You are trying to cast a TextView to EditText ( in this line: editStatus = (EditText)findViewById(R.id.edit_status);).
Go to locationstatus.xml, and change the TextView with the id edit_status to EditText.
Related
i'm getting this message when i run my application i don't know why i'm getting it could any one help me. here is the logcat.
java.lang.VerifyError: com.kosh.me.Smaller
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1429)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
This happens when the build library classes conflict with those at run-time. Try performing a Clean of your project followed by a build.
Here is my simple layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/my_long_textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/long_text_str" />
<Button
android:id="#+id/capture_screen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="captureScreen"
android:text="Capture Screen" />
</LinearLayout>
</ScrollView>
the following code in captureScreen() function crashes the app:
TextView tv = (TextView) findViewById(R.id.my_long_textview);
tv.setDrawingCacheEnabled(true);
tv.buildDrawingCache(); // comment out this line makes no difference
bitmap = Bitmap.createBitmap(tv.getDrawingCache()); // this is line 31 in stack trace
tv.setDrawingCacheEnabled(false);
This code works but I really like to capture the entire TextView:
View rv = v.getRootView();
rv.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(rv.getDrawingCache());
rv.setDrawingCacheEnabled(false);
Stack Trace is as follows:
04-21 00:17:08.023: E/AndroidRuntime(27472): java.lang.IllegalStateException: Could not execute method of the activity
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.view.View$1.onClick(View.java:2072)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.view.View.performClick(View.java:2408)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.view.View$PerformClick.run(View.java:8816)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.os.Handler.handleCallback(Handler.java:587)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.os.Handler.dispatchMessage(Handler.java:92)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.os.Looper.loop(Looper.java:123)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 00:17:08.023: E/AndroidRuntime(27472): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 00:17:08.023: E/AndroidRuntime(27472): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 00:17:08.023: E/AndroidRuntime(27472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 00:17:08.023: E/AndroidRuntime(27472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 00:17:08.023: E/AndroidRuntime(27472): at dalvik.system.NativeStart.main(Native Method)
04-21 00:17:08.023: E/AndroidRuntime(27472): Caused by: java.lang.reflect.InvocationTargetException
04-21 00:17:08.023: E/AndroidRuntime(27472): at com.gtgg.ui.TextViewAct.captureScreen(TextViewAct.java:31)
04-21 00:17:08.023: E/AndroidRuntime(27472): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 00:17:08.023: E/AndroidRuntime(27472): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.view.View$1.onClick(View.java:2067)
04-21 00:17:08.023: E/AndroidRuntime(27472): ... 11 more
04-21 00:17:08.023: E/AndroidRuntime(27472): Caused by: java.lang.NullPointerException
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.graphics.Bitmap.createBitmap(Bitmap.java:358)
04-21 00:17:08.023: E/AndroidRuntime(27472): ... 15 more
Is there a way to save the big text view into a bitmap, even though it's bigger than the rootView?
Thanks a lot!
I am trying to setup barcode scanner for an android app. I was able to setup the barcode scanner using the plugin provided by phonegap. That worked fine on some phones but was not working on some HTC phones. I searched online and some one suggested that upgrading to zxing 2.0 should solve the problem. So, I downloaded the zxing-2.0 and followed the following steps:
1. Unzipped the zxing-2.0 and built the core package.
2. Added the android package to eclipse as an Android Project and selected it as library( named zxing-2 ).
3. Added core.jar as an external jar to the zxing-2 which made it build successfully on eclipse.
4. Added the zxing-2 as project dependency of my main app(myApp). Also added core.jar as an external jar in myApp.
MyApp's mainfest.xml now contains( earlier it contained the action name as com.phonegap.plugins.barcodescanner.SCAN):
<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.encode.EncodeActivity"
android:label="#string/share_name">
<intent-filter>
<action android:name="com.google.zxing.client.android.ENCODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
I am using the BarcodeScanner.java provided in phone gap plugin to invoke the barcode scanner. I changed the scan() method in it to:
//new version
public void scan() {
Intent intentScan = new Intent("com.google.zxing.client.android.SCAN");
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
this.ctx.startActivityForResult((Plugin) this, intentScan, REQUEST_CODE);
}
//earlier version(it worked with zxing 1.7)
public void scan() {
Intent intentScan = new Intent("com.phonegap.plugins.barcodescanner.SCAN");
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
this.ctx.startActivityForResult((Plugin) this, intentScan, REQUEST_CODE);
}
The project builds fine but when I run it and trigger the scan, I get the following runtime exception:
03-03 19:43:13.499: E/AndroidRuntime(276): FATAL EXCEPTION: main
03-03 19:43:13.499: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.phonegap.myApp/com.google.zxing.client.android.CaptureActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class phonegap
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 19:43:13.499: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 19:43:13.499: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 19:43:13.499: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
03-03 19:43:13.499: E/AndroidRuntime(276): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class phonegap
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:441)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.inflate(GenericInflater.java:317)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.inflate(GenericInflater.java:263)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:251)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.PreferenceManager.setDefaultValues(PreferenceManager.java:444)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.PreferenceManager.setDefaultValues(PreferenceManager.java:422)
03-03 19:43:13.499: E/AndroidRuntime(276): at com.google.zxing.client.android.CaptureActivity.onCreate(CaptureActivity.java:167)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-03 19:43:13.499: E/AndroidRuntime(276): ... 11 more
03-03 19:43:13.499: E/AndroidRuntime(276): Caused by: java.lang.ClassNotFoundException: android.preference.phonegap in loader dalvik.system.PathClassLoader[/data/app/com.phonegap.myApp-1.apk]
03-03 19:43:13.499: E/AndroidRuntime(276): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.createItem(GenericInflater.java:375)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.onCreateItem(GenericInflater.java:417)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:428)
03-03 19:43:13.499: E/AndroidRuntime(276): ... 19 more
Can someone help me figure out what I am doing wrong here or have I missed something.
Thanks.
Your major problem is that you are trying to integrate by Intent, but are also including core/ and android/. You should never use android/ like this, and only use core/ if building your own internal scanning. Remove these entirely.
All you want from the project is android-integration/ and all you need to do is here: http://code.google.com/p/zxing/wiki/ScanningViaIntent
I don't know Phonegap well, but it's not worth using it on Android for this.
15 reports
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.oas.fruitkungfufree/com.openfeint.internal.ui.IntroFlow}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.openfeint.internal.Util.setOrientation(Util.java:36)
at com.openfeint.internal.ui.NestedWindow.onCreate(NestedWindow.java:32)
at com.openfeint.internal.ui.WebNav.onCreate(WebNav.java:93)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
Does any one have a solution for this??
This is a problem with your code, you can't use an object that is null. This is a hint.
I am getting this error in my application, and this happens only on UPC300-2.2 Viewsonic G-Tablet. All answers I've found so far (including this one) adviced on putting
<uses-permission android:name="android.permission.INTERNET"/>
to the manifest file, but it doesn't help.
Here is the complete stacktrace:
java.lang.NoClassDefFoundError: android.net.NetworkConnectivityListener
at
com.google.android.maps.MapActivity.onCreate(MapActivity.java:199)
at
myapp.Activity.ActivityMapSearch.onCreate(ActivityMapSearch.java:99)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at
android.app.ActivityThread.access$2300(ActivityThread.java:125)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at
android.os.Handler.dispatchMessage(Handler.java:99)
at
android.os.Looper.loop(Looper.java:123)
at
android.app.ActivityThread.main(ActivityThread.java:4627)
at
java.lang.reflect.Method.invokeNative(Native
Method) at
java.lang.reflect.Method.invoke(Method.java:521)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at
dalvik.system.NativeStart.main(Native
Method)
If that is TRUE, you can grab the source code of the class from the Android Source and add it yourself