transparent panel in activity - android

I am trying to set transparent panel using this tutorial in my app but whenever i use following xml to my activity it comes up with force to close
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/home_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="#+id/city_map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0DUEIIn35xtmC6Vk1JkFEF74kwkUjgb7HrUMKfA"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="bottom"
android:paddingLeft="5px"
android:paddingTop="5px"
android:paddingRight="5px">
<com.pocketjourney.view.TransparentPanel
android:id="#+id/transparent_panel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5px"
android:paddingLeft="5px"
android:paddingBottom="5px"
android:paddingRight="5px">
<Button android:id="#+id/button_click_me"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me!"/>
</com.pocketjourney.view.TransparentPanel>
</LinearLayout>
</FrameLayout>
Thanks
logcat
07-04 00:14:09.874: DEBUG/ddm-heap(3005): Got feature list request
07-04 00:14:09.974: DEBUG/dalvikvm(55): GC freed 315 objects / 12176 bytes in 264ms
07-04 00:14:10.004: WARN/dalvikvm(101): disableGcForExternalAlloc: false
07-04 00:14:10.084: WARN/dalvikvm(3005): Unable to resolve superclass of Lcom/droidnova/android/howto/optionmenu/ControlMenu; (69)
07-04 00:14:10.084: WARN/dalvikvm(3005): Link of class 'Lcom/droidnova/android/howto/optionmenu/ControlMenu;' failed
07-04 00:14:10.094: DEBUG/AndroidRuntime(3005): Shutting down VM
07-04 00:14:10.094: WARN/dalvikvm(3005): threadid=3: thread exiting with uncaught exception (group=0x4001e390)
07-04 00:14:10.104: ERROR/AndroidRuntime(3005): Uncaught handler: thread main exiting due to uncaught exception
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.droidnova.android.howto.optionmenu/com.droidnova.android.howto.optionmenu.ControlMenu}: java.lang.ClassNotFoundException: com.droidnova.android.howto.optionmenu.ControlMenu in loader dalvik.system.PathClassLoader#448a0d70
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2497)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at android.app.ActivityThread.access$2200(ActivityThread.java:126)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at android.os.Handler.dispatchMessage(Handler.java:99)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at android.os.Looper.loop(Looper.java:123)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at android.app.ActivityThread.main(ActivityThread.java:4595)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at java.lang.reflect.Method.invokeNative(Native Method)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at java.lang.reflect.Method.invoke(Method.java:521)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at dalvik.system.NativeStart.main(Native Method)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): Caused by: java.lang.ClassNotFoundException: com.droidnova.android.howto.optionmenu.ControlMenu in loader dalvik.system.PathClassLoader#448a0d70
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-04 00:14:10.124: ERROR/AndroidRuntime(3005): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2489)
and now i am getting this
07-04 00:28:31.914: ERROR/ActivityManager(101): fail to set top app changed!

the XML declaration
is saying in the packages com/pocketjourney/view there will a class called TransparentPanel
so I assume your package isn't that, you will have named it yourself so you need to update your XML
com.your.package.TransparentPanel

Related

android arduino usb communication

I'm trying to establish communication between Arduino UNO R3 and Galaxy SII on Android 4.1 cross usb. The code sample i am following i here: http://androidgurusolutions.blogspot.com/2012/07/arduino-adk-board-blink-led-with-your.html . Unfortunately, i am getting this message 'app has stopped' and here is LogCat error
LogCat:
E/AndroidRuntime(535): FATAL EXCEPTION: main
E/AndroidRuntime(535): java.lang.NoClassDefFoundError: com.android.future.usb.UsbManager
E/AndroidRuntime(535): at com.example.mypro.MainActivity.onCreate(MainActivity.java:123)
E/AndroidRuntime(535): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime(535): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime(535): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
E/AndroidRuntime(535): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
E/AndroidRuntime(535):at android.app.ActivityThread.access$600(ActivityThread.java:122)
E/AndroidRuntime(535):at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
E/AndroidRuntime(535):at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(535):at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(535):at android.app.ActivityThread.main(ActivityThread.java:4340)
E/AndroidRuntime(535):at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(535):at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(535):at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(535):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(535):at dalvik.system.NativeStart.main(Native Method)
please can anybody help me. thanks in advance.....

Simple Intent to change activity not working

I'm trying to change activity by an intent like this to a fragmentactivity that opens a embeded Google Map:
Intent driver = new Intent(getApplicationContext(), DriverActivity.class);
startActivity(driver);
But the app crashes, I've recently moved from Eclipse on my Windows to a Eclipse on Ubuntu. I can't see why the app won't change activity. The debugger opens layoutInflater.class and the message inside that windows is: Source not found
What's wrong and how do I fix it?
07-04 19:47:09.828: E/AndroidRuntime(30884): FATAL EXCEPTION: main
07-04 19:47:09.828: E/AndroidRuntime(30884): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.Activity.setContentView(Activity.java:1867)
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.codele.blackcab.DriverActivity.onCreate(DriverActivity.java:51)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.Activity.performCreate(Activity.java:5008)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.access$600(ActivityThread.java:138)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.os.Handler.dispatchMessage(Handler.java:99)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.os.Looper.loop(Looper.java:213)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.main(ActivityThread.java:4787)
07-04 19:47:09.828: E/AndroidRuntime(30884): at java.lang.reflect.Method.invokeNative(Native Method)
07-04 19:47:09.828: E/AndroidRuntime(30884): at java.lang.reflect.Method.invoke(Method.java:511)
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
07-04 19:47:09.828: E/AndroidRuntime(30884): at dalvik.system.NativeStart.main(Native Method)
Use this :
Intent driver = new Intent(this, DriverActivity.class);
startActivity(driver);

Android: how to refer to EditText view

I have the following layout:
<TextView
android:id = "#+id/HRNoninTextBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/exitbtn"
android:text="Heart Rate"
android:textSize = "20sp"/>
<EditText
android:id="#+id/labelNoninHeartRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:layout_alignParentRight="true">
</EditText>
from the code i refer to these views, form my activity, in this way:
TextView tvHr= (TextView)findViewById(R.id.HRNoninTextBox);
EditText etHr = (EditText)findViewById(R.id.labelNoninHeartRate);
the first one does not produce any error, while the second statement produce the following error:
01-09 13:24:57.599: W/dalvikvm(28816): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
01-09 13:24:57.619: E/AndroidRuntime(28816): FATAL EXCEPTION: main
01-09 13:24:57.619: E/AndroidRuntime(28816): java.lang.RuntimeException: Unable to start activity ComponentInfo{aid.assistant233/aid.assistant233.AidAssistant233Activity}: java.lang.ClassCastException: android.widget.TextView
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.os.Looper.loop(Looper.java:130)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread.main(ActivityThread.java:3691)
01-09 13:24:57.619: E/AndroidRuntime(28816): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 13:24:57.619: E/AndroidRuntime(28816): at java.lang.reflect.Method.invoke(Method.java:507)
01-09 13:24:57.619: E/AndroidRuntime(28816): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
01-09 13:24:57.619: E/AndroidRuntime(28816): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
01-09 13:24:57.619: E/AndroidRuntime(28816): at dalvik.system.NativeStart.main(Native Method)
01-09 13:24:57.619: E/AndroidRuntime(28816): Caused by: java.lang.ClassCastException: android.widget.TextView
01-09 13:24:57.619: E/AndroidRuntime(28816): at aid.assistant233.AidAssistant233Activity.onCreate(AidAssistant233Activity.java:331)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
01-09 13:24:57.619: E/AndroidRuntime(28816): ... 11 more
Where may be the problem?
Step1 : you can clean/build your project as everyone said . but If you are not getting your issue solve by clean/build then check my step2 for it.
Step:2:
I am not Sure But Can you please check your xml file once again?
this also could be happen if You've two elements with the same ID:
<TextView android:text="Hello Ahmedabad:"
android:id="#+id/txtahmedabad"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="#+id/txtahmedabad"
android:text="">
</EditText>
if this is so then Give them different IDs -
it could picking the first one (the TextView) which obviously can't be cast to an EditText.
Hope it will some how help you.

Null Pointer Exception in First Android App

I am trying to write my first Android app, and I'm having trouble. I wrote a simple Java program to find the factors of a number provided by the user, and I'd like to port it over to Java. I have an XML file for the interface, which seemed to run OK until I added the first Java class. Now it won't run, and log.cat says that there's a null pointer exception. So far, I only have stubs, but it seems like it should run OK with what I've done to this point. I'm including the log.cat text, but I'm too new it this to make much sense out of it.
There may be more than one problem. After adding the Java file I began to get run-time errors right away, but I don't think they were null pointer exceptions. I think that started when I made changes to fix what was already causing problems.
Any help is appreciated.
Here is the Java file:
import android.app.Activity; <br>
import android.os.Bundle; <br>
import android.widget.Button; <br>
import android.widget.EditText; <br>
import android.widget.TextView; <br>
public class AndroidFactoringActivity extends Activity {
// Instance Variables
EditText userNumber;
Button factorButton;
TextView resultsField;
int factorResults;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
factorButton = (Button) findViewById(R.id.factorButton);
userNumber = (EditText) findViewById(R.id.userNumber);
factorResults = 1;
resultsField.setText(String.valueOf(factorResults));
}
}
Here is main.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"
android:orientation="vertical" >
<TextView
android:id="#+id/askField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/ask"
android:textSize="24dp" />
<EditText
android:id="#+id/userNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
<Button
android:id="#+id/factorButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/click" />
<TextView
android:id="#+id/resultsField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/tell"
android:textSize="24dp" />
</LinearLayout>
Here are the log.cat results:
03-31 23:58:53.579: D/AndroidRuntime(2804): Shutting down VM
03-31 23:58:53.589: W/dalvikvm(2804): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
03-31 23:58:53.589: E/AndroidRuntime(2804): Uncaught handler: thread main exiting due to uncaught exception
03-31 23:58:53.650: E/AndroidRuntime(2804): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.dave_b.factoring/net.dave_b.factoring.AndroidFactoringActivity}: java.lang.NullPointerException
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.os.Handler.dispatchMessage(Handler.java:99)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.os.Looper.loop(Looper.java:123)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.main(ActivityThread.java:4363)
03-31 23:58:53.650: E/AndroidRuntime(2804): at java.lang.reflect.Method.invokeNative(Native Method)
03-31 23:58:53.650: E/AndroidRuntime(2804): at java.lang.reflect.Method.invoke(Method.java:521)
03-31 23:58:53.650: E/AndroidRuntime(2804): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-31 23:58:53.650: E/AndroidRuntime(2804): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-31 23:58:53.650: E/AndroidRuntime(2804): at dalvik.system.NativeStart.main(Native Method)
03-31 23:58:53.650: E/AndroidRuntime(2804): Caused by: java.lang.NullPointerException
03-31 23:58:53.650: E/AndroidRuntime(2804): at net.dave_b.factoring.AndroidFactoringActivity.onCreate(AndroidFactoringActivity.java:26)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
03-31 23:58:53.650: E/AndroidRuntime(2804): ... 11 more
03-31 23:58:53.679: I/dalvikvm(2804): threadid=7: reacting to signal 3
03-31 23:58:53.679: E/dalvikvm(2804): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
03-31 23:59:57.629: I/Process(2804): Sending signal. PID: 2804 SIG: 9
04-01 00:07:36.129: D/AndroidRuntime(3040): Shutting down VM
04-01 00:07:36.129: W/dalvikvm(3040): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-01 00:07:36.139: E/AndroidRuntime(3040): Uncaught handler: thread main exiting due to uncaught exception
04-01 00:07:36.159: E/AndroidRuntime(3040): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.dave_b.factoring/net.dave_b.factoring.AndroidFactoringActivity}: java.lang.NullPointerException
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.os.Looper.loop(Looper.java:123)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-01 00:07:36.159: E/AndroidRuntime(3040): at java.lang.reflect.Method.invokeNative(Native Method)
04-01 00:07:36.159: E/AndroidRuntime(3040): at java.lang.reflect.Method.invoke(Method.java:521)
04-01 00:07:36.159: E/AndroidRuntime(3040): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-01 00:07:36.159: E/AndroidRuntime(3040): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-01 00:07:36.159: E/AndroidRuntime(3040): at dalvik.system.NativeStart.main(Native Method)
04-01 00:07:36.159: E/AndroidRuntime(3040): Caused by: java.lang.NullPointerException
04-01 00:07:36.159: E/AndroidRuntime(3040): at net.dave_b.factoring.AndroidFactoringActivity.onCreate(AndroidFactoringActivity.java:26)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-01 00:07:36.159: E/AndroidRuntime(3040): ... 11 more
04-01 00:07:36.199: I/dalvikvm(3040): threadid=7: reacting to signal 3
04-01 00:07:36.199: E/dalvikvm(3040): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
04-01 00:07:40.329: I/Process(3040): Sending signal. PID: 3040 SIG: 9
resultsField.setText(String.valueOf(factorResults));
resultsField is null and you are trying to set value on null.
resultsField= (TextView ) findViewById(R.id.userNumber);
Get textview instance before setting value, otherwise resultsField will be null and all operations on null reference results in NullPointerException.
You got a null pointer because you didnt intialise the variable resultsField (you just declared it) .
As you used
userNumber = (EditText) findViewById(R.id.userNumber);
you must even initialise the reference resultsField.
This can be done using
resultsField= (TextView ) findViewById(R.id.resultsField);
in the onCreate() after the statement setContentView()
You need to initialize the userNumer and resultsFiled as follows
userNumber = (EditText) findViewById(R.id.userNumber);
resultsField= (TextView ) findViewById(R.id.resultsField);

My Android application has stopped unexpectedly

When I try to run my app on an emulator, my app comes up with an error message saying
The app has stopped unexpectedly. Please try again."
How do I fix this?
Here is my code:
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.DOLEnterprises.GTA5Guide"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name= "com.google.ads.AdActivity"
android:configChanges= "keyboard|keyboardHidden|orientation"
></activity>
<activity
android:name=".GTA5GuideActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The "Appname"Activity.java:
package com.DOLEnterprises.GTA5Guide;
import android.app.Activity;
import android.os.Bundle;
public class GTA5GuideActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads= "http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:scaleType="center"
android:src="#drawable/gtaapp" />
<com.google.ads.AdView android:id= "#+id/ad"
android:layout_width="wrap_content"
android:layout_height= "wrap_content"
ads:adUnitId= "soon"
ads:loadAdOnCreate= "a14f8315a6c11bf"
ads:adSize="BANNER"
/>
</LinearLayout>
The Logcat thing:
04-10 08:23:55.424: D/dalvikvm(224): GC freed 510 objects / 46816 bytes in 75ms
04-10 08:23:55.534: D/AndroidRuntime(224): Shutting down VM
04-10 08:23:55.534: W/dalvikvm(224): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-10 08:23:55.534: E/AndroidRuntime(224): Uncaught handler: thread main exiting due to uncaught exception
04-10 08:23:55.554: E/AndroidRuntime(224): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.DOLEnterprises.GTA5Guide/com.DOLEnterprises.GTA5Guide.GTA5GuideActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class com.google.ads.AdView
04-10 08:23:55.554: E/AndroidRuntime(224): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.os.Looper.loop(Looper.java:123)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-10 08:23:55.554: E/AndroidRuntime(224): at java.lang.reflect.Method.invokeNative(Native Method)
04-10 08:23:55.554: E/AndroidRuntime(224): at java.lang.reflect.Method.invoke(Method.java:521)
04-10 08:23:55.554: E/AndroidRuntime(224): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-10 08:23:55.554: E/AndroidRuntime(224): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-10 08:23:55.554: E/AndroidRuntime(224): at dalvik.system.NativeStart.main(Native Method)
04-10 08:23:55.554: E/AndroidRuntime(224): Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class com.google.ads.AdView
04-10 08:23:55.554: E/AndroidRuntime(224): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-10 08:23:55.554: E/AndroidRuntime(224): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.app.Activity.setContentView(Activity.java:1622)
04-10 08:23:55.554: E/AndroidRuntime(224): at com.DOLEnterprises.GTA5Guide.GTA5GuideActivity.onCreate(GTA5GuideActivity.java:11)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-10 08:23:55.554: E/AndroidRuntime(224): ... 11 more
04-10 08:23:55.554: E/AndroidRuntime(224): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader#44e8ca48
04-10 08:23:55.554: E/AndroidRuntime(224): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-10 08:23:55.554: E/AndroidRuntime(224): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-10 08:23:55.554: E/AndroidRuntime(224): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
04-10 08:23:55.554: E/AndroidRuntime(224): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
04-10 08:23:55.554: E/AndroidRuntime(224): ... 20 more
04-10 08:23:55.584: I/dalvikvm(224): threadid=7: reacting to signal 3
04-10 08:23:55.584: E/dalvikvm(224): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
04-10 08:24:22.804: D/dalvikvm(231): GC freed 537 objects / 47832 bytes in 68ms
04-10 08:24:22.913: D/AndroidRuntime(231): Shutting down VM
04-10 08:24:22.913: W/dalvikvm(231): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-10 08:24:22.913: E/AndroidRuntime(231): Uncaught handler: thread main exiting due to uncaught exception
04-10 08:24:22.933: E/AndroidRuntime(231): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.DOLEnterprises.GTA5Guide/com.DOLEnterprises.GTA5Guide.GTA5GuideActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class com.google.ads.AdView
04-10 08:24:22.933: E/AndroidRuntime(231): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.os.Looper.loop(Looper.java:123)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-10 08:24:22.933: E/AndroidRuntime(231): at java.lang.reflect.Method.invokeNative(Native Method)
04-10 08:24:22.933: E/AndroidRuntime(231): at java.lang.reflect.Method.invoke(Method.java:521)
04-10 08:24:22.933: E/AndroidRuntime(231): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-10 08:24:22.933: E/AndroidRuntime(231): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-10 08:24:22.933: E/AndroidRuntime(231): at dalvik.system.NativeStart.main(Native Method)
04-10 08:24:22.933: E/AndroidRuntime(231): Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class com.google.ads.AdView
04-10 08:24:22.933: E/AndroidRuntime(231): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-10 08:24:22.933: E/AndroidRuntime(231): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.app.Activity.setContentView(Activity.java:1622)
04-10 08:24:22.933: E/AndroidRuntime(231): at com.DOLEnterprises.GTA5Guide.GTA5GuideActivity.onCreate(GTA5GuideActivity.java:11)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-10 08:24:22.933: E/AndroidRuntime(231): ... 11 more
04-10 08:24:22.933: E/AndroidRuntime(231): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader#44e8ca28
04-10 08:24:22.933: E/AndroidRuntime(231): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-10 08:24:22.933: E/AndroidRuntime(231): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-10 08:24:22.933: E/AndroidRuntime(231): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
04-10 08:24:22.933: E/AndroidRuntime(231): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
04-10 08:24:22.933: E/AndroidRuntime(231): ... 20 more
04-10 08:24:22.953: I/dalvikvm(231): threadid=7: reacting to signal 3
04-10 08:24:22.953: E/dalvikvm(231): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
04-10 08:24:31.884: D/dalvikvm(237): GC freed 564 objects / 48880 bytes in 92ms
04-10 08:24:31.993: D/AndroidRuntime(237): Shutting down VM
04-10 08:24:31.993: W/dalvikvm(237): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-10 08:24:32.003: E/AndroidRuntime(237): Uncaught handler: thread main exiting due to uncaught exception
04-10 08:24:32.023: E/AndroidRuntime(237): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.DOLEnterprises.GTA5Guide/com.DOLEnterprises.GTA5Guide.GTA5GuideActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class com.google.ads.AdView
04-10 08:24:32.023: E/AndroidRuntime(237): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.os.Looper.loop(Looper.java:123)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-10 08:24:32.023: E/AndroidRuntime(237): at java.lang.reflect.Method.invokeNative(Native Method)
04-10 08:24:32.023: E/AndroidRuntime(237): at java.lang.reflect.Method.invoke(Method.java:521)
04-10 08:24:32.023: E/AndroidRuntime(237): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-10 08:24:32.023: E/AndroidRuntime(237): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-10 08:24:32.023: E/AndroidRuntime(237): at dalvik.system.NativeStart.main(Native Method)
04-10 08:24:32.023: E/AndroidRuntime(237): Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class com.google.ads.AdView
04-10 08:24:32.023: E/AndroidRuntime(237): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-10 08:24:32.023: E/AndroidRuntime(237): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.app.Activity.setContentView(Activity.java:1622)
04-10 08:24:32.023: E/AndroidRuntime(237): at com.DOLEnterprises.GTA5Guide.GTA5GuideActivity.onCreate(GTA5GuideActivity.java:11)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-10 08:24:32.023: E/AndroidRuntime(237): ... 11 more
04-10 08:24:32.023: E/AndroidRuntime(237): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader#44e8ca28
04-10 08:24:32.023: E/AndroidRuntime(237): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-10 08:24:32.023: E/AndroidRuntime(237): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-10 08:24:32.023: E/AndroidRuntime(237): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
04-10 08:24:32.023: E/AndroidRuntime(237): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
04-10 08:24:32.023: E/AndroidRuntime(237): ... 20 more
04-10 08:24:32.043: I/dalvikvm(237): threadid=7: reacting to signal 3
04-10 08:24:32.043: E/dalvikvm(237): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
---EDIT---
Are you sure you have downloaded the "Ad" library and included it in your project? Class not found suggests that you have not successfully linked it to your project. Also try rebuilding your project by following the steps below .
Try cleaning your project... Project > Clean > Choose your Project > Ok
Rerun your project.
it seems that error is caused due to Typos or casting ...... Check carefully for Typos and casting ....... check for library folder name ....
check out this
android:configChanges requieres all parameters to show ads in application
change the SDK version to 14 of your Application
mention it in your AndroidManifest.xml file
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

Categories

Resources