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.
Related
I am making app which on portrait mode shows fragmentA (containing Listview) and when in Landscape mode, it shows fragmentA and fragmentB(Listview and its corresponding description).It keeps on crashing,my hunch says either there is a fault in if-else condition in MainActivity or problem is in communication pattern.I request Everyone to please Help. Here is my MainActivity.xml
package com.example.prince.fragment_modularui2;
import android.content.Intent;
import android.content.res.Resources;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity implements FragmentA.Communicator{
String s;
Resources r=getResources();
String[] a=r.getStringArray(R.array.descr);
FragmentA fa;
FragmentB fb;
FragmentManager manager;
#Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
manager=getSupportFragmentManager();
//fa always present
fa= (FragmentA) manager.findFragmentById(R.id.fragment);
fb= (FragmentB) manager.findFragmentById(R.id.fragment2);
fa.setCommunicator(this);
}
#Override
public void respond(int data) {
Intent i=new Intent(this,AnotherActivity.class);
i.putExtra("index",data);
startActivity(i);
}
}
here is activity_main.xml in Portrait
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.prince.fragment_modularui2.FragmentA"
android:id="#+id/fragment"
></fragment>
</LinearLayout>
activity_main in landscape
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<fragment
android:id="#+id/fragment"
android:name="com.example.prince.fragment_modularui2.FragmentA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true" />
<fragment
android:id="#+id/fragment2"
android:name="com.example.prince.fragment_modularui2.FragmentB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true" />
</LinearLayout>
Rest of the code is https://github.com/AlmightyHeathcliff/Fragment_ModularUi2
The stackTrace is
07-18 09:45:09.252 1974-1974/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:09.254 1974-1974/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:09.289 1974-1974/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:09.301 1974-1974/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:09.316 1974-1974/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:09.316 1974-1974/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:09.317 1974-1974/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:09.325 1974-1974/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm
07-18 09:45:09.330 1974-1974/? I/art: System.exit called, status: 0
07-18 09:45:09.330 1974-1974/? I/AndroidRuntime: VM exiting with result code 0.
07-18 09:45:09.333 1974-1982/? W/MessageQueue: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:643)
at android.os.Handler.sendMessageAtTime(Handler.java:612)
at android.os.Handler.sendMessageDelayed(Handler.java:582)
at android.os.Handler.post(Handler.java:338)
at android.os.ResultReceiver$MyResultReceiver.send(ResultReceiver.java:57)
at com.android.internal.os.IResultReceiver$Stub.onTransact(IResultReceiver.java:58)
at android.os.Binder.execTransact(Binder.java:565)
07-18 09:45:09.972 1993-1993/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:09.976 1993-1993/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:10.012 1993-1993/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:10.015 1993-1993/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:10.049 1993-1993/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:10.049 1993-1993/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:10.050 1993-1993/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:10.059 1993-1993/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm
07-18 09:45:10.064 1993-2001/? W/MessageQueue: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.os.Handler) {f6bbfb3} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
at android.os.Handler.enqueueMessage(Handler.java:643)
at android.os.Handler.sendMessageAtTime(Handler.java:612)
at android.os.Handler.sendMessageDelayed(Handler.java:582)
at android.os.Handler.post(Handler.java:338)
at android.os.ResultReceiver$MyResultReceiver.send(ResultReceiver.java:57)
at com.android.internal.os.IResultReceiver$Stub.onTransact(IResultReceiver.java:58)
at android.os.Binder.execTransact(Binder.java:565)
07-18 09:45:10.064 1993-1993/? I/art: System.exit called, status: 0
07-18 09:45:10.064 1993-1993/? I/AndroidRuntime: VM exiting with result code 0.
07-18 09:45:13.487 2005-2005/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:13.491 2005-2005/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:13.569 2005-2005/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:13.575 2005-2005/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:13.708 2009-2009/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
07-18 09:45:13.715 2009-2009/? D/AndroidRuntime: CheckJNI is OFF
07-18 09:45:13.760 2005-2005/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:13.760 2005-2005/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:13.761 2005-2005/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:13.776 2005-2005/? D/AndroidRuntime: Calling main entry com.android.commands.wm.Wm
07-18 09:45:13.814 2009-2009/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:13.825 2009-2009/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-18 09:45:13.833 2005-2005/? D/AndroidRuntime: Shutting down VM
07-18 09:45:13.839 2005-2019/? W/art: Thread attaching while runtime is shutting down: Binder:2005_2
07-18 09:45:13.839 2005-2019/? I/AndroidRuntime: NOTE: attach of thread 'Binder:2005_2' failed
07-18 09:45:13.891 2009-2009/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-18 09:45:13.891 2009-2009/? E/android.os.Debug: failed to load memtrack module: -2
07-18 09:45:13.892 2009-2009/? I/Radio-JNI: register_android_hardware_Radio DONE
07-18 09:45:13.903 2009-2009/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
07-18 09:45:13.909 765-1149/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.prince.fragment_modularui2/.MainActivity} from uid 0 on display 0
07-18 09:45:13.919 2009-2009/? D/AndroidRuntime: Shutting down VM
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: returned from zygote!
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: done updating battery stats
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: building log message
07-18 09:45:13.993 765-1021/system_process I/ActivityManager: Start proc 2027:com.example.prince.fragment_modularui2/u0a115 for activity com.example.prince.fragment_modularui2/.MainActivity
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: starting to update pids map
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: done updating pids map
07-18 09:45:13.993 765-1021/system_process W/ActivityManager: Slow operation: 75ms so far, now at startProcess: done starting proc!
07-18 09:45:14.003 2027-2027/? I/art: Late-enabling -Xcheck:jni
07-18 09:45:14.004 2027-2027/? W/art: Unexpected CPU variant for X86 using defaults: x86
07-18 09:45:14.258 500-757/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x933 imply creation of host color buffer
07-18 09:45:14.784 2027-2027/com.example.prince.fragment_modularui2 W/System: ClassLoader referenced unknown path: /data/app/com.example.prince.fragment_modularui2-1/lib/x86
07-18 09:45:14.813 2027-2027/com.example.prince.fragment_modularui2 I/InstantRun: starting instant run server: is main process
07-18 09:45:14.814 2027-2027/com.example.prince.fragment_modularui2 V/InstantRun: Starting server socket listening for package com.example.prince.fragment_modularui2 on android.net.LocalSocketAddress#8989009
07-18 09:45:14.814 2027-2027/com.example.prince.fragment_modularui2 V/InstantRun: Started server for package com.example.prince.fragment_modularui2
07-18 09:45:14.903 2027-2027/com.example.prince.fragment_modularui2 D/AndroidRuntime: Shutting down VM
07-18 09:45:14.904 2027-2027/com.example.prince.fragment_modularui2 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.prince.fragment_modularui2, PID: 2027
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.prince.fragment_modularui2/com.example.prince.fragment_modularui2.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
at android.content.ContextWrapper.getResources(ContextWrapper.java:86)
at android.view.ContextThemeWrapper.getResourcesInternal(ContextThemeWrapper.java:127)
at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:121)
at android.support.v7.app.AppCompatActivity.getResources(AppCompatActivity.java:549)
at com.example.prince.fragment_modularui2.MainActivity.<init>(MainActivity.java:12)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
07-18 09:45:14.907 765-1021/system_process W/ActivityManager: Force finishing activity com.example.prince.fragment_modularui2/.MainActivity
07-18 09:45:15.031 500-505/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
07-18 09:45:15.058 500-505/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
07-18 09:45:15.115 500-505/? D/gralloc_vbox86: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
07-18 09:45:15.232 765-1842/system_process I/OpenGLRenderer: Initialized EGL, version 1.4
07-18 09:45:15.232 765-1842/system_process D/OpenGLRenderer: Swap behavior 1
07-18 09:45:15.429 765-779/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{b0310c2 u0 com.example.prince.fragment_modularui2/.MainActivity t693 f}
07-18 09:45:15.431 765-779/system_process I/ActivityManager: Killing 1353:android.process.media/u0a10 (adj 906): empty #17
07-18 09:45:15.432 765-779/system_process I/WindowManager: Failed to capture screenshot of Token{7756ed3 ActivityRecord{b0310c2 u0 com.example.prince.fragment_modularui2/.MainActivity t693 f}} appWin=Window{7f1e54b u0 Starting com.example.prince.fragment_modularui2} drawState=1
07-18 09:45:15.448 765-786/system_process I/Choreographer: Skipped 70 frames! The application may be doing too much work on its main thread.
07-18 09:45:15.452 765-1150/system_process D/ActivityManager: cleanUpApplicationRecord -- 1353
07-18 09:45:15.456 765-1842/system_process E/EGL_emulation: tid 1842: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
07-18 09:45:15.456 765-1842/system_process W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xc4afa800, error=EGL_BAD_MATCH
07-18 09:45:16.337 765-780/system_process I/Choreographer: Skipped 52 frames! The application may be doing too much work on its main thread.
07-18 09:45:25.438 765-779/system_process W/ActivityManager: Activity destroy timeout for ActivityRecord{b0310c2 u0 com.example.prince.fragment_modularui2/.MainActivity t693 f}
From the stacktrace I gather that you are calling getResources() on a Context that is null. This makes sense because you are declaring your resources as a field like:
Resources res = getResources();
This gets executed before the activity is created but you can only call getResources() once the activity is created. So the solution is to declare your resources like:
private Resources res;
And in your activity onCreate method you do:
res = getResources();
This also means that you can't use the res variable until the onCreate method is executed. Generally it is better to not declare resources as a variable like that but rather declare your string array as:
String[] a;
and then in onCreate just call: a = getResources().getStringArray(R.array.desc);
One other tip I can give you is to name your variable clearer. A string array named 'a' is not very descriptive. You can call it something like descriptionArray to make it more clear.
my App was already running fine, but suddenly the main activity is not found any more. Don't have a clue why.
In the end I get java.lang.ClassNotFoundException: de.xxx.android.shopper.MyShopperActivity
I did a software update using the Android SDK manager. After that I get the error in this special app, all others are not affected.
My manifest
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="19"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="#drawable/shoppericon2"
android:allowBackup="true"
android:label="#string/AppNameAppString" >
<activity
android:name=".MyShopperActivity"
android:label="#string/AppNameActivityString"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MenuActivity" />
<activity
android:name="com.google.ads.AdActivity"
android:label="#string/AppNameActivityString"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
The activity
package de.xxx.android.shopper;
import ...
#SuppressLint("ParserError")
public class MyShopperActivity extends Activity implements AdListener
{
...
}
This is what logcat says:
06-10 10:45:57.464: D/AndroidRuntime(1518): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
06-10 10:45:57.474: D/AndroidRuntime(1518): CheckJNI is ON
06-10 10:45:58.133: D/AndroidRuntime(1518): Calling main entry com.android.commands.pm.Pm
06-10 10:45:58.193: D/AndroidRuntime(1518): Shutting down VM
06-10 10:45:58.203: D/dalvikvm(1518): GC_CONCURRENT freed 100K, 78% free 454K/2048K, paused 1ms+4ms
06-10 10:45:58.213: D/dalvikvm(1518): Debugger has detached; object registry had 1 entries
06-10 10:45:58.623: D/AndroidRuntime(1532): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
06-10 10:45:58.623: D/AndroidRuntime(1532): CheckJNI is ON
06-10 10:45:59.244: D/AndroidRuntime(1532): Calling main entry com.android.commands.am.Am
06-10 10:45:59.284: I/ActivityManager(863): Force stopping package de.xxx.android.shopper uid=10039
06-10 10:45:59.284: I/ActivityManager(863): Killing proc 1500:de.xxx.android.shopper/10039: force stop
06-10 10:45:59.284: W/ActivityManager(863): Force removing ActivityRecord{b5cbedc0 de.xxx.android.shopper/.MyShopperActivity}: app died, no saved state
06-10 10:45:59.304: W/NetworkManagementSocketTagger(863): setKernelCountSet(10039, 0) failed with errno -2
06-10 10:45:59.314: W/NetworkManagementSocketTagger(863): setKernelCountSet(10012, 1) failed with errno -2
06-10 10:45:59.334: I/ActivityManager(863): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=de.xxx.android.shopper/.MyShopperActivity} from pid 1532
06-10 10:45:59.384: D/AndroidRuntime(1532): Shutting down VM
06-10 10:45:59.414: D/dalvikvm(1532): GC_CONCURRENT freed 100K, 77% free 478K/2048K, paused 5ms+2ms
06-10 10:45:59.424: D/dalvikvm(1532): Debugger has detached; object registry had 1 entries
06-10 10:45:59.454: D/dalvikvm(1544): Not late-enabling CheckJNI (already on)
06-10 10:45:59.484: I/ActivityManager(863): Start proc de.xxx.android.shopper for activity de.xxx.android.shopper/.MyShopperActivity: pid=1544 uid=10039 gids={3003}
06-10 10:45:59.514: E/jdwp(1544): Failed writing handshake bytes: Broken pipe (-1 of 14)
06-10 10:45:59.514: D/dalvikvm(1544): Debugger has detached; object registry had 0 entries
06-10 10:45:59.554: W/NetworkManagementSocketTagger(863): setKernelCountSet(10039, 1) failed with errno -2
06-10 10:45:59.575: W/ActivityThread(1544): Application de.xxx.android.shopper is waiting for the debugger on port 8100...
06-10 10:45:59.575: I/System.out(1544): Sending WAIT chunk
06-10 10:46:00.307: I/dalvikvm(1544): Debugger is active
06-10 10:46:00.431: I/System.out(1544): Debugger has connected
06-10 10:46:00.431: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:00.641: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:00.778: W/ActivityManager(863): Launch timeout has expired, giving up wake lock!
06-10 10:46:00.850: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:01.055: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:01.267: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:01.482: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:01.688: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:01.897: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:02.103: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:02.321: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:02.535: I/System.out(1544): waiting for debugger to settle...
06-10 10:46:02.740: I/System.out(1544): debugger has settled (1314)
06-10 10:46:02.894: I/dalvikvm(1544): Failed resolving Lde/xxx/android/shopper/MyShopperActivity; interface 58 'Lcom/google/ads/AdListener;'
06-10 10:46:02.894: W/dalvikvm(1544): Link of class 'Lde/xxx/android/shopper/MyShopperActivity;' failed
06-10 10:46:04.593: W/NetworkManagementSocketTagger(863): setKernelCountSet(10012, 0) failed with errno -2
06-10 10:46:09.561: W/ActivityManager(863): Activity idle timeout for ActivityRecord{b5af65b8 de.xxx.android.shopper/.MyShopperActivity}
Hi i think ur parent package you noted in the manifest.xml and package name for the MyShopperActivity class is different. I hope that is the problem.
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'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.
Updated: I have now included the logcat file below. Looking at it it appears I am still having a permission problems (06-05 14:10:36.593) - I am guessing the same problem I am having with SDK 7
Well I was trying to get the HelloWebview example working with SDK 7 with no success (see HelloWebView Sample: java.lang.SecurityException: Permission Denial thread), so I decided just out of curiosity to back off to SDK3 to see if I could learn anything. I have been able to get all the "Layout" samples to work and decided to try something a little harder.
Unfortunately, I still cannot get the simple HelloWebView app to run. I no longer get a Permission Denial but now the app is getting killed.
Killed usually implies that there are not enough resources (memory etc.) for an application to run.... Any thoughts? Are there any other log files I can look at either on my computer or on the emulator?
The main.xml, manifest, and console output are below. Let me know if you need more information.
Thanks,
Tim
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"
>
<WebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
mainfest file:
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="3" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloWebView3"
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=".HelloWebView3" android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
</application>
Console output:
[2010-06-05 08:43:37 - HelloWebView3] ------------------------------
[2010-06-05 08:43:37 - HelloWebView3] Android Launch!
[2010-06-05 08:43:37 - HelloWebView3] adb is running normally.
[2010-06-05 08:43:37 - HelloWebView3] Performing com.example.hellowebview3.HelloWebView3 activity launch
[2010-06-05 08:43:37 - HelloWebView3] Automatic Target Mode: launching new emulator with compatible AVD 'Android1.5'
[2010-06-05 08:43:37 - HelloWebView3] Launching a new emulator with Virtual Device 'Android1.5'
[2010-06-05 08:43:42 - HelloWebView3] New emulator found: emulator-5554
[2010-06-05 08:43:42 - HelloWebView3] Waiting for HOME ('android.process.acore') to be launched...
[2010-06-05 08:45:04 - HelloWebView3] HOME is up on device 'emulator-5554'
[2010-06-05 08:45:04 - HelloWebView3] Uploading HelloWebView3.apk onto device 'emulator-5554'
[2010-06-05 08:45:04 - HelloWebView3] Installing HelloWebView3.apk...
[2010-06-05 08:45:19 - HelloWebView3] Success!
[2010-06-05 08:45:19 - HelloWebView3] Starting activity com.example.hellowebview3.HelloWebView3 on device
[2010-06-05 08:45:23 - HelloWebView3] ActivityManager: Starting: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} comp={com.example.hellowebview3/com.example.hellowebview3.HelloWebView3} }
[2010-06-05 08:45:23 - HelloWebView3] ActivityManager: [1] Killed am start -n com....
logcat output:
06-05 14:10:33.963: DEBUG/AndroidRuntime(763): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
06-05 14:10:33.963: DEBUG/AndroidRuntime(763): CheckJNI is ON
06-05 14:10:34.232: INFO/jdwp(763): received file descriptor 20 from ADB
06-05 14:10:34.253: DEBUG/AndroidRuntime(763): --- registering native functions ---
06-05 14:10:35.013: DEBUG/AndroidRuntime(763): Shutting down VM
06-05 14:10:35.013: DEBUG/dalvikvm(763): DestroyJavaVM waiting for non-daemon threads to exit
06-05 14:10:35.022: DEBUG/dalvikvm(763): DestroyJavaVM shutting VM down
06-05 14:10:35.032: DEBUG/dalvikvm(763): HeapWorker thread shutting down
06-05 14:10:35.053: DEBUG/dalvikvm(763): HeapWorker thread has shut down
06-05 14:10:35.053: DEBUG/jdwp(763): JDWP shutting down net...
06-05 14:10:35.062: DEBUG/jdwp(763): +++ peer disconnected
06-05 14:10:35.062: INFO/dalvikvm(763): Debugger has detached; object registry had 2 entries
06-05 14:10:35.073: DEBUG/dalvikvm(763): VM cleaning up
06-05 14:10:35.102: WARN/dalvikvm(763): LinearAlloc 0x0 not freed: 0x410caa08 len=20
06-05 14:10:35.102: WARN/dalvikvm(763): LinearAlloc 0x0 not freed: 0x410caa20 len=340
06-05 14:10:35.112: WARN/dalvikvm(763): LinearAlloc 0x0 not freed: 0x410cab78 len=2244
06-05 14:10:35.112: DEBUG/dalvikvm(763): LinearAlloc 0x0 used 632420 of 4194304 (15%)
06-05 14:10:35.561: DEBUG/AndroidRuntime(772): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
06-05 14:10:35.561: DEBUG/AndroidRuntime(772): CheckJNI is ON
06-05 14:10:35.793: DEBUG/AndroidRuntime(772): --- registering native functions ---
06-05 14:10:35.803: INFO/jdwp(772): received file descriptor 20 from ADB
06-05 14:10:36.593: INFO/ActivityManager(579): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x10000000 comp={com.example.hellowebview3/com.example.hellowebview3.HelloWebView3} }
06-05 14:10:36.593: WARN/ActivityManager(579): Permission Denial: starting Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x10000000 comp={com.example.hellowebview3/com.example.hellowebview3.HelloWebView3} } from null (pid=-1, uid=-1) requires null
06-05 14:10:36.602: DEBUG/AndroidRuntime(772): Shutting down VM
06-05 14:10:36.613: WARN/dalvikvm(772): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
06-05 14:10:36.613: ERROR/AndroidRuntime(772): Uncaught handler: thread main exiting due to uncaught exception
06-05 14:10:36.623: ERROR/AndroidRuntime(772): *** EXCEPTION IN SYSTEM PROCESS. System will crash.
06-05 14:10:36.633: ERROR/AndroidRuntime(772): java.lang.SecurityException: Permission Denial: starting Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x10000000 comp={com.example.hellowebview3/com.example.hellowebview3.HelloWebView3} } from null (pid=-1, uid=-1) requires null
06-05 14:10:36.633: ERROR/AndroidRuntime(772): at android.os.Parcel.readException(Parcel.java:1234)
06-05 14:10:36.633: ERROR/AndroidRuntime(772): at android.os.Parcel.readException(Parcel.java:1222)
06-05 14:10:36.633: ERROR/AndroidRuntime(772): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1046)
06-05 14:10:36.633: ERROR/AndroidRuntime(772): at com.android.commands.am.Am.runStart(Am.java:199)
06-05 14:10:36.633: ERROR/AndroidRuntime(772): at com.android.commands.am.Am.run(Am.java:73)
06-05 14:10:36.633: ERROR/AndroidRuntime(772): at com.android.commands.am.Am.main(Am.java:51)
06-05 14:10:36.633: ERROR/AndroidRuntime(772): at com.android.internal.os.RuntimeInit.finishInit(Native Method)
06-05 14:10:36.633: ERROR/AndroidRuntime(772): at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:186)
06-05 14:10:36.633: ERROR/AndroidRuntime(772): at dalvik.system.NativeStart.main(Native Method)
06-05 14:10:36.661: ERROR/JavaBinder(772): Unknown binder error code. 0xfffffff7
06-05 14:10:36.661: ERROR/AndroidRuntime(772): Crash logging skipped, no checkin service
06-05 14:10:36.673: INFO/Process(772): Sending signal. PID: 772 SIG: 9
06-05 14:21:41.081: DEBUG/dalvikvm(626): GC freed 9840 objects / 555600 bytes in 106ms
There are any error messages you can look to. If you're using eclipse goto ddms perspective and open window logcat. (you can also directly display logcat without switching to the ddms perspective)
You have twice
<activity android:name=".HelloWebView3"
In your manifest