I'm trying to create an application such that when I click on a button in the 1st layout, it will extract the text from an EditText and place that value into a TextView from the 2nd layout. However, it seems that the application will crash because of the setText for the TextView.
I didn't put the logCat as it doesn't tell much. I believe that the error comes from the setText part. But I have no idea on how to fix that part, or maybe that my way of coding is wrong. Hope that someone will help me. Thanks in advance.
<TextView android:id="#+id/showtitle"
android:layout_marginTop="1dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold" />
<TextView android:id="#+id/showtemplate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/showtitle"
android:layout_alignLeft="#+id/showtitle"
android:paddingBottom="4dip"
android:includeFontPadding="false"
android:textSize="15sp"
android:textStyle="normal" />
Below is my java code:
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.EditText;
import android.widget.Button;
import android.widget.Toast;
import android.app.Activity;
public class AndroidGroupSMS extends Activity{
private EditText title;
private EditText template;
private Button btnsave;
private Button btnload;
private TextView text,text2;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
title = (EditText) findViewById(R.id.title);
template = (EditText) findViewById(R.id.template);
btnsave = (Button) findViewById(R.id.save);
btnload = (Button) findViewById(R.id.load);
text = (TextView) findViewById(R.id.showtitle);
text2 = (TextView) findViewById(R.id.showtemplate);
btnsave.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
String sTitle = title.getText().toString();
String sTemplate = template.getText().toString();
if(sTitle.length() > 0 && sTemplate.length() > 0)
{
//this is where i'm setting the text extracted from the edittext boxes
text.setText(sTitle.toString());
text2.setText(sTemplate.toString());
}
else
Toast.makeText(getBaseContext(),"Please enter the title and template" + "", Toast.LENGTH_SHORT).show();
}
});
}
I have no idea how to read this.
Below is my logCat as requested:
11-12 04:32:51.652: DEBUG/AndroidRuntime(283): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
11-12 04:32:51.662: DEBUG/AndroidRuntime(283): CheckJNI is ON
11-12 04:32:51.982: DEBUG/AndroidRuntime(283): --- registering native functions ---
11-12 04:32:52.464: DEBUG/ddm-heap(283): Got feature list request
11-12 04:32:53.092: DEBUG/AndroidRuntime(283): Shutting down VM
11-12 04:32:53.102: DEBUG/dalvikvm(283): DestroyJavaVM waiting for non-daemon threads to exit
11-12 04:32:53.102: DEBUG/dalvikvm(283): DestroyJavaVM shutting VM down
11-12 04:32:53.102: DEBUG/dalvikvm(283): HeapWorker thread shutting down
11-12 04:32:53.112: DEBUG/dalvikvm(283): HeapWorker thread has shut down
11-12 04:32:53.112: DEBUG/jdwp(283): JDWP shutting down net...
11-12 04:32:53.122: INFO/dalvikvm(283): Debugger has detached; object registry had 1 entries
11-12 04:32:53.132: DEBUG/dalvikvm(283): VM cleaning up
11-12 04:32:53.192: DEBUG/dalvikvm(283): LinearAlloc 0x0 used 629532 of 5242880 (12%)
11-12 04:32:53.842: DEBUG/AndroidRuntime(291): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
11-12 04:32:53.842: DEBUG/AndroidRuntime(291): CheckJNI is ON
11-12 04:32:54.182: DEBUG/AndroidRuntime(291): --- registering native functions ---
11-12 04:32:54.682: DEBUG/ddm-heap(291): Got feature list request
11-12 04:32:55.302: DEBUG/dalvikvm(104): GC freed 2293 objects / 132304 bytes in 2157ms
11-12 04:32:55.352: DEBUG/ActivityManager(52): Uninstalling process joel.AndroidGroupSMS
11-12 04:32:55.362: DEBUG/ActivityManager(52): Force removing process ProcessRecord{43d9daf0 275:joel.AndroidGroupSMS/10024} (joel.AndroidGroupSMS/10024)
11-12 04:32:55.401: INFO/Process(52): Sending signal. PID: 275 SIG: 9
11-12 04:32:55.492: INFO/UsageStats(52): Unexpected resume of com.android.launcher while already resumed in joel.AndroidGroupSMS
11-12 04:32:55.512: INFO/WindowManager(52): WIN DEATH: Window{43cf7840 joel.AndroidGroupSMS/joel.AndroidGroupSMS.AndroidGroupSMS paused=false}
11-12 04:32:55.592: INFO/ActivityManager(52): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=joel.AndroidGroupSMS/.AndroidGroupSMS }
11-12 04:32:55.612: DEBUG/ActivityManager(52): Received spurious death notification for thread android.os.BinderProxy#43bc8370
11-12 04:32:55.652: DEBUG/AndroidRuntime(291): Shutting down VM
11-12 04:32:55.652: DEBUG/dalvikvm(291): DestroyJavaVM waiting for non-daemon threads to exit
11-12 04:32:55.662: DEBUG/dalvikvm(291): DestroyJavaVM shutting VM down
11-12 04:32:55.662: DEBUG/dalvikvm(291): HeapWorker thread shutting down
11-12 04:32:55.672: DEBUG/dalvikvm(291): HeapWorker thread has shut down
11-12 04:32:55.672: DEBUG/jdwp(291): JDWP shutting down net...
11-12 04:32:55.672: INFO/dalvikvm(291): Debugger has detached; object registry had 1 entries
11-12 04:32:55.672: DEBUG/dalvikvm(291): VM cleaning up
11-12 04:32:55.732: ERROR/AndroidRuntime(291): ERROR: thread attach failed
11-12 04:32:55.832: DEBUG/dalvikvm(291): LinearAlloc 0x0 used 639500 of 5242880 (12%)
11-12 04:32:55.952: INFO/ActivityManager(52): Start proc joel.AndroidGroupSMS for activity joel.AndroidGroupSMS/.AndroidGroupSMS: pid=298 uid=10024 gids={1015}
11-12 04:32:56.062: WARN/InputManagerService(52): Got RemoteException sending setActive(false) notification to pid 275 uid 10024
11-12 04:32:56.392: DEBUG/ddm-heap(298): Got feature list request
11-12 04:32:56.592: WARN/ActivityThread(298): Application joel.AndroidGroupSMS is waiting for the debugger on port 8100...
11-12 04:32:56.642: INFO/System.out(298): Sending WAIT chunk
11-12 04:32:56.691: INFO/dalvikvm(298): Debugger is active
11-12 04:32:56.872: INFO/System.out(298): Debugger has connected
11-12 04:32:56.882: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:57.082: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:57.282: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:57.483: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:57.692: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:57.893: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:58.092: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:58.300: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:58.502: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:58.707: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:58.912: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:59.112: INFO/System.out(298): waiting for debugger to settle...
11-12 04:32:59.322: INFO/System.out(298): debugger has settled (1361)
11-12 04:33:00.792: INFO/ActivityManager(52): Displayed activity joel.AndroidGroupSMS/.AndroidGroupSMS: 4860 ms (total 4860 ms)
11-12 04:33:02.942: WARN/KeyCharacterMap(298): No keyboard for id 0
11-12 04:33:02.952: WARN/KeyCharacterMap(298): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
11-12 04:33:04.592: DEBUG/dalvikvm(99): GC freed 481 objects / 24704 bytes in 185ms
Everything looks fine except the part where you use toString() on String object, that is not neccessary.
But are the text and the text2 TextViews located in the same XML layout as EditText views? In this case the main.xml? If the answer is no, then you have NullPointerException when you try to use them because findViewById can't find them.
You could just do text2.setText(template.getText().toString());
Instead of text2.setText(sTemplate.toString());
See if that works.
Joel,
Considering you have the edittext's in a different xml file. You might be able to create another resource file for what is displayed in your xml files. For instance you could create an xml file that will hold the values of what is displayed in your other xml files. Take a look at this example (notepad). The example is from the android development web site. You could use the values that are placed in your "values" xml for the values as all your other xml files. This way, you have a central place for your other xml files to grab their values. This may solve your problem. Let us know what results you find.
You will need to open the res folder and the values folder to see what im talking about when you are viewing the example.
Related
After successful tests I've tried to rename my project / package from, 'test...' to something more relevant. I used the various Eclipse refactor helpers where possible. All the source files appear to have the right package at the top now, the manifest seems to have the right package name, etc. I performed a 'clean'.
All seemed well. Only problem is that it won't launch - doesn't even get to the activity onCreate() handler. It crashes at AvtivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line 2417.
Clearly something still has the old name in it, but I cannot find it.
Any suggestions where to look / what to do?
As requested: log cat (nothing in console):
07-14 07:00:04.149: D/AndroidRuntime(347): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<<br>
07-14 07:00:04.149: D/AndroidRuntime(347): CheckJNI is ON<br>
07-14 07:00:04.389: D/AndroidRuntime(347): --- registering native functions ---<br>
07-14 07:00:04.830: D/ddm-heap(347): Got feature list request<br>
07-14 07:00:05.239: D/AndroidRuntime(347): Shutting down VM<br>
07-14 07:00:05.250: D/dalvikvm(347): DestroyJavaVM waiting for non-daemon threads to exit<br>
07-14 07:00:05.250: D/dalvikvm(347): DestroyJavaVM shutting VM down<br>
07-14 07:00:05.250: D/dalvikvm(347): HeapWorker thread shutting down<br>
07-14 07:00:05.259: D/dalvikvm(347): HeapWorker thread has shut down<br>
07-14 07:00:05.259: D/jdwp(347): JDWP shutting down net...<br>
07-14 07:00:05.269: I/dalvikvm(347): Debugger has detached; object registry had 1 entries<br>
07-14 07:00:05.279: D/dalvikvm(347): VM cleaning up<br>
07-14 07:00:05.291: E/AndroidRuntime(347): ERROR: thread attach failed<br>
07-14 07:00:05.309: D/dalvikvm(347): LinearAlloc 0x0 used 629532 of 5242880 (12%)<br>
07-14 07:00:05.801: D/AndroidRuntime(355): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<<br>
07-14 07:00:05.809: D/AndroidRuntime(355): CheckJNI is ON<br>
07-14 07:00:06.049: D/AndroidRuntime(355): --- registering native functions ---<br>
07-14 07:00:06.490: D/ddm-heap(355): Got feature list request<br>
07-14 07:00:06.910: D/ActivityManager(52): Uninstalling process uk.co.nightshadearts.golfcaddy<br>
07-14 07:00:06.910: I/ActivityManager(52): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=uk.co.nightshadearts.golfcaddy/uk.co.nightshadearts.golfcaddy }<br>
07-14 07:00:06.969: D/AndroidRuntime(355): Shutting down VM<br>
07-14 07:00:06.969: D/dalvikvm(355): DestroyJavaVM waiting for non-daemon threads to exit<br>
07-14 07:00:07.009: E/AndroidRuntime(355): ERROR: thread attach failed<br>
07-14 07:00:07.009: D/dalvikvm(355): DestroyJavaVM shutting VM down<br>
07-14 07:00:07.009: D/dalvikvm(355): HeapWorker thread shutting down<br>
07-14 07:00:07.019: D/dalvikvm(355): HeapWorker thread has shut down<br>
07-14 07:00:07.019: D/jdwp(355): JDWP shutting down net...<br>
07-14 07:00:07.019: I/dalvikvm(355): Debugger has detached; object registry had 1 entries<br>
07-14 07:00:07.051: D/dalvikvm(355): VM cleaning up<br>
07-14 07:00:07.070: D/dalvikvm(355): LinearAlloc 0x0 used 639500 of 5242880 (12%)<br>
07-14 07:00:07.160: I/ActivityManager(52): Start proc uk.co.nightshadearts.golfcaddy for activity uk.co.nightshadearts.golfcaddy/uk.co.nightshadearts.golfcaddy: pid=362 uid=10031 gids={1015}<br>
07-14 07:00:07.309: D/ddm-heap(362): Got feature list request<br>
07-14 07:00:07.460: W/ActivityThread(362): Application uk.co.nightshadearts.golfcaddy is waiting for the debugger on port 8100...<br>
07-14 07:00:07.489: I/System.out(362): Sending WAIT chunk<br>
07-14 07:00:07.510: I/dalvikvm(362): Debugger is active<br>
07-14 07:00:07.750: I/System.out(362): Debugger has connected<br>
07-14 07:00:07.750: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:07.951: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:08.150: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:08.350: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:08.559: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:08.759: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:08.960: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:09.187: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:09.397: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:09.609: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:09.827: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:10.039: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:10.263: I/System.out(362): waiting for debugger to settle...<br>
07-14 07:00:10.479: I/System.out(362): debugger has settled (1449)<br>
07-14 07:00:10.681: E/gralloc(52): [unregister] handle 0x3fa718 still locked (state=40000001)<br>
07-14 07:00:17.029: W/ActivityManager(52): Launch timeout has expired, giving up wake lock!<br>
07-14 07:00:17.391: W/ActivityManager(52): Activity idle timeout for HistoryRecord{44f00a48 uk.co.nightshadearts.golfcaddy/uk.co.nightshadearts.golfcaddy}<br>
Calls:
GolfCaddy [Android Application]
DalvikVM[localhost:8610]
Thread [<3> main] (Suspended (exception RuntimeException))
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2417
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2512
ActivityThread.access$2200(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 119
ActivityThread$H.handleMessage(Message) line: 1863
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4363
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 860
ZygoteInit.main(String[]) line: 618
NativeStart.main(String[]) line: not available [native method]
Thread [<13> Binder Thread #2] (Running)
Thread [<11> Binder Thread #1] (Running)
Answer:
Actually, I seem to have solved it, though I don't really know what I've fixed.
Following instructions fromn alextsc on app won't install after package rename I did the following:
Dumped the faulty project completely (deleted the project and the file tree) - fortunately I had the common sense to have copied the original before I did anything.
Copied the original back under 'workbench'.
Added a new project (original name) using create from existing source option.
That got it back and working.
Then rt clk on project and select Android Tools >> Rename application package, and let it do everything it wanted to.
Under src the package still had the old name, however. Used Eclipse refactor on that to change to the new name.
Still seems to work. All src files have the right package as well.
Renamed the (one) activity - still works. After that it was just more internal code modifactions line the XML app name.
Conclusion: Android Tools >> Rename application package did something, but I don't know what.
Moral: pick a name and stick to it in future.
Change the package name in manifest as
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.org.xxx" // your packagename here..
>
</manifest>
after changing this R.java will created once again under the new package and then you have to import R in all activity..
Try this, it may helpful to you..
Here is what I did.
In the Eclipse project "src" folder, you are going to have something called "com.test...", rename it to the new name and click OK. Then all the files should update automatically. At least it worked perfectly for me.
Please, remember that you have to change it in the Android Manifest as well.
Let me start by saying that this app was working fine the day before. I have restarted the pc, removed the project and added a previous version of the project and it keeps crashing. If i remove this from main.xml which gets loaded from the mainactivity the app does not crash. If i have this in the main.xml :
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="a14ee1ad68dcbdb"
ads:loadAdOnCreate="true" />
the app crashes. If i run the app and this code is not in the main.xml file but in other xml files the app works fine and it will show adds from other activities.
I tried removing all the code in the xml file and just have the above admob adds in there and it still crashed. I was thinking about uninstalling eclipse and installing it again???
Any ideas????
Here is a Everything from start to finish in logcat:
03-30 11:39:17.215: D/AndroidRuntime(338): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-30 11:39:17.215: D/AndroidRuntime(338): CheckJNI is ON
03-30 11:39:17.335: D/AndroidRuntime(338): --- registering native functions ---
03-30 11:39:17.825: D/AndroidRuntime(338): Shutting down VM
03-30 11:39:17.825: D/dalvikvm(338): Debugger has detached; object registry had 1 entries
03-30 11:39:17.845: I/AndroidRuntime(338): NOTE: attach of thread 'Binder Thread #3' failed
03-30 11:39:18.215: D/AndroidRuntime(346): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-30 11:39:18.215: D/AndroidRuntime(346): CheckJNI is ON
03-30 11:39:18.345: D/AndroidRuntime(346): --- registering native functions ---
03-30 11:39:18.835: I/ActivityManager(59): Force stopping package com.petermihaylov.android.cardcounter uid=10040
03-30 11:39:18.835: I/Process(59): Sending signal. PID: 331 SIG: 9
03-30 11:39:18.896: I/UsageStats(59): Unexpected resume of com.android.launcher while already resumed in com.petermihaylov.android.cardcounter
03-30 11:39:18.905: W/InputManagerService(59): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#45094eb8
03-30 11:39:18.945: I/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.petermihaylov.android.cardcounter/.MainActivity }
03-30 11:39:18.945: D/AndroidRuntime(346): Shutting down VM
03-30 11:39:18.955: D/jdwp(346): Got wake-up signal, bailing out of select
03-30 11:39:18.955: D/dalvikvm(346): Debugger has detached; object registry had 1 entries
03-30 11:39:19.039: I/AndroidRuntime(346): NOTE: attach of thread 'Binder Thread #3' failed
03-30 11:39:19.155: I/ActivityManager(59): Start proc com.petermihaylov.android.cardcounter for activity com.petermihaylov.android.cardcounter/.MainActivity: pid=353 uid=10040 gids={3003}
03-30 11:39:19.345: D/dalvikvm(33): GC_EXPLICIT freed 285 objects / 10864 bytes in 186ms
03-30 11:39:19.475: W/ActivityThread(353): Application com.petermihaylov.android.cardcounter is waiting for the debugger on port 8100...
03-30 11:39:19.525: I/System.out(353): Sending WAIT chunk
03-30 11:39:19.565: I/dalvikvm(353): Debugger is active
03-30 11:39:19.595: D/dalvikvm(33): GC_EXPLICIT freed 47 objects / 2056 bytes in 249ms
03-30 11:39:19.745: I/System.out(353): Debugger has connected
03-30 11:39:19.745: I/System.out(353): waiting for debugger to settle...
03-30 11:39:19.945: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.075: D/dalvikvm(33): GC_EXPLICIT freed 2 objects / 64 bytes in 422ms
03-30 11:39:20.207: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.405: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.605: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.823: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.025: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.225: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.468: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.677: I/System.out(353): debugger has settled (1469)
03-30 11:39:29.005: W/ActivityManager(59): Launch timeout has expired, giving up wake lock!
03-30 11:39:29.421: W/ActivityManager(59): Activity idle timeout for HistoryRecord{450bae78 com.petermihaylov.android.cardcounter/.MainActivity}
Looks like you're trying to debug the app, and it's hanging on debug. Do you get any more relevant logs if you try to just run it?
Also, have you updated to r17 of the Android Tools by any chance? r17 of the tools force you to place the SDK in the libs/ folder of your project.
Are you sure you have stepped through a tutorial properly and added the permissions and imported the SDK?
Try stepping through this guide from the beginning:
https://developers.google.com/mobile-ads-sdk/docs/android/fundamentals
Cleaning the project in Eclipse sometimes solves some problems.
I had a very similar bizarre issue with Admob recently after a fresh install of Eclipse. After hours of looking into why, it ended up being my build order in the project preferences. I set the Google AdMob jar to the top, cleaned the project and all my issues were resolved.
The logcat text you have pasted does not give any error information. Can you paste the logcat text from the point of failure, generally you can see the communications with AdMob in here.
May help, just a thought.
New version of Android LED Clock just uploaded to the market
Jason
I wonder if you can help me with this error.
I am running a fresh fully updated install of windows 7 with
Visual studio 2010 Professional in trial mode.
In Visual Studio I create a new OpenGl Mono for Android Application
using the built in template.
I compile and run the application.
The emulator boots (I am running API_8) EMU.
The application starts and then aborts.
(In the emulator I get a black screen which quickly closes.)
Same thing happens if I do similar using the Mono Develop IDE
and or the other templates.
Here is a dump of the error message (I cannot find much info on google)
It looks like the error is related to the load library fail.
Thanks
// DUMP
03-05 23:23:47.464 D/AndroidRuntime( 418):
03-05 23:23:47.464 D/AndroidRuntime( 418): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-05 23:23:47.464 D/AndroidRuntime( 418): CheckJNI is ON
03-05 23:23:47.574 D/AndroidRuntime( 418): --- registering native functions ---
03-05 23:23:48.034 I/ActivityManager( 60): Start proc OpenGLApplication1.OpenGLApplication1 for broadcast OpenGLApplication1.OpenGLApplication1/mono.android.Seppuku: pid=424 uid=10038 gids={3003, 1015}
03-05 23:23:48.164 I/ActivityThread( 424): Publishing provider OpenGLApplication1.OpenGLApplication1.__mono_init__: mono.MonoRuntimeProvider
03-05 23:23:48.174 D/dalvikvm( 424): Trying to load lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7f010
03-05 23:23:48.174 D/dalvikvm( 424): Added shared lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7f010
03-05 23:23:48.184 F/MonoDroid( 424): shared runtime initialization error: Cannot load library: load_library[1083]: Library '/data/data/Mono.Android.DebugRuntime/lib/libmonosgen-2.0.so' not found
03-05 23:23:48.204 I/ActivityManager( 60): Process OpenGLApplication1.OpenGLApplication1 (pid 424) has died.
03-05 23:23:48.214 D/AndroidRuntime( 418): Shutting down VM
03-05 23:23:48.214 D/jdwp ( 418): adbd disconnected
03-05 23:23:48.624 D/AndroidRuntime( 432):
03-05 23:23:48.624 D/AndroidRuntime( 432): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-05 23:23:48.624 D/AndroidRuntime( 432): CheckJNI is ON
03-05 23:23:48.734 D/AndroidRuntime( 432): --- registering native functions ---
03-05 23:23:49.173 I/ActivityManager( 60): Start proc OpenGLApplication1.OpenGLApplication1 for broadcast OpenGLApplication1.OpenGLApplication1/mono.android.Seppuku: pid=438 uid=10038 gids={3003, 1015}
03-05 23:23:49.294 I/ActivityThread( 438): Publishing provider OpenGLApplication1.OpenGLApplication1.__mono_init__: mono.MonoRuntimeProvider
03-05 23:23:49.303 D/dalvikvm( 438): Trying to load lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7f010
03-05 23:23:49.303 D/dalvikvm( 438): Added shared lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7f010
03-05 23:23:49.314 F/MonoDroid( 438): shared runtime initialization error: Cannot load library: load_library[1083]: Library '/data/data/Mono.Android.DebugRuntime/lib/libmonosgen-2.0.so' not found
03-05 23:23:49.334 I/ActivityManager( 60): Process OpenGLApplication1.OpenGLApplication1 (pid 438) has died.
03-05 23:23:49.344 D/AndroidRuntime( 432): Shutting down VM
03-05 23:23:49.344 D/jdwp ( 432): adbd disconnected
03-05 23:23:50.333 D/AndroidRuntime( 447):
03-05 23:23:50.333 D/AndroidRuntime( 447): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-05 23:23:50.333 D/AndroidRuntime( 447): CheckJNI is ON
03-05 23:23:50.443 D/AndroidRuntime( 447): --- registering native functions ---
03-05 23:23:50.873 I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=OpenGLApplication1.OpenGLApplication1/openglapplication1.Activity1 }
03-05 23:23:50.893 I/ActivityManager( 60): Start proc OpenGLApplication1.OpenGLApplication1 for activity OpenGLApplication1.OpenGLApplication1/openglapplication1.Activity1: pid=453 uid=10038 gids={3003, 1015}
03-05 23:23:50.923 D/AndroidRuntime( 447): Shutting down VM
03-05 23:23:50.923 D/jdwp ( 447): adbd disconnected
03-05 23:23:50.953 I/AndroidRuntime( 447): NOTE: attach of thread 'Binder Thread #3' failed
03-05 23:23:51.173 I/ActivityThread( 453): Publishing provider OpenGLApplication1.OpenGLApplication1.__mono_init__: mono.MonoRuntimeProvider
03-05 23:23:51.223 D/dalvikvm( 453): Trying to load lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7eef0
03-05 23:23:51.223 D/dalvikvm( 453): Added shared lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7eef0
03-05 23:23:51.263 F/MonoDroid( 453): shared runtime initialization error: Cannot load library: load_library[1083]: Library '/data/data/Mono.Android.DebugRuntime/lib/libmonosgen-2.0.so' not found
03-05 23:23:51.283 I/ActivityManager( 60): Process OpenGLApplication1.OpenGLApplication1 (pid 453) has died.
03-05 23:23:51.293 I/UsageStats( 60): Unexpected resume of com.android.launcher while already resumed in OpenGLApplication1.OpenGLApplication1
03-05 23:23:51.423 W/InputManagerService( 60): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#45104b68
The issue is from the newer versions of mono where libmonosgen-2.0 does not get installed automatically. The path that you will see in which it fails is actually a simlink for the library. What you have to do is manually or through a non-mono apk, create the following:
A folder with your package name in /data/app-lib/
in the folder you will have to push the libmonosgen-2.0.so (and libmonodroid.so if needed)
After this is done you have to navigate to data/data/your.package.name and create a simlink from lib -> the folder you created previously. the command to use is ln -s.
I have noticed that in some cases the simlink exists, but is pointing to a false location.
I had to do this manually and it would not survive a factory reset. A colleugue of mine actually did this the non-mono apk path which does everything for him when ever the provisioning app executes on first launch.
Try going to the project properties and turn off "fast deployment". Then manually remove your app from the emu/device, and try again.
Another possibility is that you don't have enough free space on your device. The problem isn't in your package (OpenGLApplication1), the problem is from installing the Mono.Android.DebugRuntime package, as /data/data/Mono.Android.DebugRuntime/lib/libmonosgen-2.0.so doesn't exist.
I would suggest looking through the adb logcat log, and see if something like the following is present:
W/NativeHelper( 98): Failed to cache package shared libs
W/NativeHelper( 98): java.io.IOException: Couldn't create cached binary /data/data/Mono.Android.DebugRuntime/lib/libmonosgen-2.0.so in /data/data/Mono.Android.DebugRuntime/lib
W/NativeHelper( 98): at com.android.internal.content.NativeLibraryHelper.copyNativeBinaryLI(NativeLibraryHelper.java:289)
If messages like the above are present, remove the Mono.Android.DebugRuntime package (adb uninstall Mono.Android.DebugRuntime), remove some extra apps from your device (to free up space), and try re-installing your app from the IDE.
Problem is simple.
Two Activities. One throwing intent at other.
Project have name : "Stupidroid"
package : "com.examples.stupidroid"
activity : "stupidOnSteroids"
below is stupidOnSteroids .java
package com.examples.stupidroid;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class stupidOnSteroids extends Activity {
private Button buttonThatWillTakeYouPlacesButton;
private Intent intentThatwillTakeYouPlacesIntent;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
InitLayouts();
InitSetOnClickListeners();
}
private void InitSetOnClickListeners() {
buttonThatWillTakeYouPlacesButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
intentThatwillTakeYouPlacesIntent.setAction("");
}
});
}
private void InitLayouts() {
buttonThatWillTakeYouPlacesButton = (Button)findViewById(R.id.buttonThatWillGiveThyPowerButton);
intentThatwillTakeYouPlacesIntent = new Intent(stupidOnSteroids.this, Calc_print_codefile.class);
}
}
now is main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
>
<Button android:id="#+id/goToOtherMoronButton"
android:text="Next Activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
></Button>
</LinearLayout>
now is another java file : Calc_print_codefile.java
package com.examples.stupidroid;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Calc_print_codefile extends Activity{
Button buttonThatWillHelpYouCalculateButton;
TextView textThatWillTakeTheHitText;
Button buttonThatWillTakeYouHomeButton;
Intent intentThatWillTakeYouHomeIntent;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.calc_prin_layout);
InitLayouts();
InitSetOnClickListener();
}
private void InitSetOnClickListener() {
buttonThatWillHelpYouCalculateButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
for(int i=0; i<32000; i++){
textThatWillTakeTheHitText.setText(i);
}
}
});
}
private void InitLayouts() {
buttonThatWillHelpYouCalculateButton = (Button)findViewById(R.id.buttonThatWillGiveThyPowerButton);
textThatWillTakeTheHitText = (TextView)findViewById(R.id.textThatWillAbsolveThyText);
intentThatWillTakeYouHomeIntent = new Intent(Calc_print_codefile.this, stupidOnSteroids.class);
}
}
corresponding xml : calc_prin_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="#+id/textThatWillAbsolveThyText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=" "
/>
<Button android:id="#+id/buttonThatWillGiveThyPowerButton"
android:text="Press ME, hard!"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></Button>
</LinearLayout>
below is AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examples.stupidroid"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".stupidOnSteroids"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Calc_print_codefile"></activity>
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>
Here are images (actually one only):
now is information from DDMS
07-29 14:13:31.344: WARN/ActivityThread(379): Application com.examples.stupidroid is waiting for the debugger on port 8100...
07-29 14:13:31.374: INFO/System.out(379): Sending WAIT chunk
07-29 14:13:31.434: INFO/dalvikvm(379): Debugger is active
07-29 14:13:31.594: INFO/System.out(379): Debugger has connected
07-29 14:13:31.604: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:31.804: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:31.824: DEBUG/dalvikvm(33): GC_EXPLICIT freed 2 objects / 64 bytes in 556ms
07-29 14:13:32.038: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:32.296: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:32.444: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{440534a8 com.examples.stupidroid/.stupidOnSteroids}
07-29 14:13:32.494: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:32.694: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:32.894: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:33.113: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:33.356: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:33.574: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:33.795: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:34.008: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:34.215: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:34.423: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:34.634: INFO/System.out(379): waiting for debugger to settle...
07-29 14:13:34.868: INFO/System.out(379): debugger has settled (1504)
07-29 14:13:40.587: WARN/ActivityManager(60): Launch timeout has expired, giving up wake lock!
07-29 14:13:41.254: WARN/ActivityManager(60): Activity idle timeout for HistoryRecord{44078b28 com.examples.stupidroid/.stupidOnSteroids}
07-29 14:13:46.454: DEBUG/dalvikvm(135): GC_EXPLICIT freed 1190 objects / 62584 bytes in 179ms
07-29 14:13:57.363: DEBUG/dalvikvm(60): GC_FOR_MALLOC freed 12320 objects / 698248 bytes in 153ms
07-29 14:13:58.423: DEBUG/AndroidRuntime(379): Shutting down VM
07-29 14:13:58.423: WARN/dalvikvm(379): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
**07-29 14:13:58.543: ERROR/AndroidRuntime(379): FATAL EXCEPTION: main
07-29 14:13:58.543: ERROR/AndroidRuntime(379): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.examples.stupidroid/com.examples.stupidroid.stupidOnSteroids}: java.lang.NullPointerException**
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.os.Looper.loop(Looper.java:123)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at java.lang.reflect.Method.invokeNative(Native Method)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at java.lang.reflect.Method.invoke(Method.java:521)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at dalvik.system.NativeStart.main(Native Method)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): Caused by: java.lang.NullPointerException
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at com.examples.stupidroid.stupidOnSteroids.InitSetOnClickListeners(stupidOnSteroids.java:20)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at com.examples.stupidroid.stupidOnSteroids.onCreate(stupidOnSteroids.java:17)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-29 14:13:58.543: ERROR/AndroidRuntime(379): ... 11 more
07-29 14:13:58.613: WARN/ActivityManager(60): Force finishing activity com.examples.stupidroid/.stupidOnSteroids
07-29 14:13:59.128: WARN/ActivityManager(60): Activity pause timeout for HistoryRecord{44078b28 com.examples.stupidroid/.stupidOnSteroids}
07-29 14:14:09.273: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{44078b28 com.examples.stupidroid/.stupidOnSteroids}
07-29 14:14:13.443: INFO/Process(379): Sending signal. PID: 379 SIG: 9
07-29 14:14:13.465: INFO/ActivityManager(60): Process com.examples.stupidroid (pid 379) has died.
07-29 14:14:13.483: WARN/InputManagerService(60): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#43ef9a68
Please tell me what can I do? I have followed same approach the other guy followed. My other project is working. what can it be? is it wrong nomenclature or what?
From my past experiences, it looks like very small very narrow mistake , might be silly, still can't put my finger at it.
Thanks for spending time reading this.
And oh, if I remove InitSetOnClickListeners(); from stupidOnSteroids.java file, I can at least see a button. So, there might be error.
You initializing of your button is wrong. In your main xml you don't have a button with the id R.id.buttonThatWillGiveThyPowerButton. You should change it to
R.id.goToOtherMoronButton.
You should take the time you spend to create this question to read the stacktrace (it says where to find the null pointer) and than spend the rest of the time to debug (if it is more complex than the simple null pointer). But a plus point for the quality of your question. Everything is there... code, log, pictures :)
Change:
textThatWillTakeTheHitText.setText(i);
to:
textThatWillTakeTheHitText.setText(String.valueOf(i));
Make sure that this line:
buttonThatWillTakeYouPlacesButton = (Button)findViewById(R.id.buttonThatWillGiveThyPowerButton);
Actually returns something and not just null.
I am getting an exception in a very simple 'study' application, so I expect the problem to be in my project setup, but I don't know how to debug ...
What is the context of the exception, "ExceptionInInitializationError"?
Where is it documented? A: Search Android Developers Guide
Stack trace from within Eclipse Debugger with: select thread -> right-click -> copy stack
Thread [<3> main] (Suspended (exception ExceptionInInitializerError))
Class.newInstance() line: 1479
Instrumentation.newActivity(ClassLoader, String, Intent) line: 1021
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2367
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2470
ActivityThread.access$2200(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 119
ActivityThread$H.handleMessage(Message) line: 1821
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4310
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 860
ZygoteInit.main(String[]) line: 618
NativeStart.main(String[]) line: not available [native method]
Here is the logcat:
I/ActivityManager( 52): Starting activity: Intent { flg=0x10000000 cmp=com.androidcode.study_wikinotes/.WikiNotes }
D/AndroidRuntime( 198): Shutting down VM
D/dalvikvm( 198): DestroyJavaVM waiting for non-daemon threads to exit
D/dalvikvm( 198): DestroyJavaVM shutting VM down
D/dalvikvm( 198): HeapWorker thread shutting down
D/dalvikvm( 198): HeapWorker thread has shut down
D/jdwp ( 198): JDWP shutting down net...
I/jdwp ( 198): adbd disconnected
D/dalvikvm( 198): VM cleaning up
E/AndroidRuntime( 198): ERROR: thread attach failed
I/ActivityManager( 52): Start proc com.androidcode.study_wikinotes for activity com.androidcode.study_wikinotes/.WikiNotes: pid=219 uid=10023 gids={}
D/dalvikvm( 198): LinearAlloc 0x0 used 634508 of 5242880 (12%)
D/ddm-heap( 155): Got feature list request
D/ddm-heap( 169): Got feature list request
D/ddm-heap( 183): Got feature list request
D/ddm-heap( 206): Got feature list request
D/ddm-heap( 219): Got feature list request
W/ActivityThread( 219): Application com.androidcode.study_wikinotes is waiting for the debugger on port 8100...
I/System.out( 219): Sending WAIT chunk
I/dalvikvm( 219): Debugger is active
I/System.out( 219): Debugger has connected
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): waiting for debugger to settle...
I/System.out( 219): debugger has settled (1382)
W/dalvikvm( 219): Exception Ljava/util/regex/PatternSyntaxException; thrown during Lcom/androidcode/study_wikinotes/WikiNotes;.<clinit>
W/dalvikvm( 219): Class init failed in newInstance call (Lcom/androidcode/study_wikinotes/WikiNotes;)
Ahh ... I have an incomplete class in WikiNotes. Would you say the answer is to "start with logcat"? :) Thanks for the help. Go ahead and add your answer and I will accept it.
Yes the first thing to do when debugging in Android is to start by looking in LogCat.