unable to start toste...

java - Android studio strange spinner adapter error - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
J it only takes a minute:
Hello I am trying to use spinner dropdown list. But I get strange error while doing it here are the codes
Naryste.java
public class Naryste extends Activity {
private ImageV
private String[]
private TypedA
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
states = getResources().getStringArray(R.array.Senioras);
spinner = (Spinner) findViewById(R.id.country_spinner);
ArrayAdapter&String& dataAdapter = new ArrayAdapter&String&(this,
android.R.layout.simple_spinner_item, states);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);
&?xml version="1.0" encoding="utf-8"?&
&LinearLayout xmlns:android="/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dip" &
tools:context=".Naryste" &
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Pasirinkite"
android:textAppearance="?android:attr/textAppearanceLarge" /&
android:id="@+id/country_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content" /&
&/LinearLayout&
&?xml version="1.0" encoding="utf-8"?&
&resources&
&string name="app_name"&LoginRegister&/string&
&string name="hello_world"&Hello world!&/string&
&string name="action_settings"&Settings&/string&
&string name="title_activity_login"&Login&/string&
&string name="title_activity_register"&Register&/string&
&string name="title_activity_naryste"&Naryste&/string&
&string-array name="Senioras"&
&item&1 m?n&/item&
&item&3 m?n&/item&
&item&6 m?n&/item&
&item&12 m?n&/item&
&/string-array&
&string-array name="Vaikas"&
&item&1 m?n&/item&
&item&3 m?n&/item&
&item&6 m?n&/item&
&item&12 m?n&/item&
&/string-array&
&string-array name="Suauges"&
&item&1 m?n&/item&
&item&3 m?n&/item&
&item&6 m?n&/item&
&item&12 m?n&/item&
&/string-array&
&/resources&
06-02 11:33:37.912
/com.tonikamitv.loginregister E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tonikamitv.loginregister/com.tonikamitv.loginregister.Naryste}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2114)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.tonikamitv.loginregister.Naryste.onCreate(Naryste.java:30)
at android.app.Activity.performCreate(Activity.java:5203)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2078)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
1,76342646
Check your xml file whether you have set the layout file in setContentView method is correct or not for the Activity you are using spinner.
3,62832042
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .24976
Stack Overflow works best with JavaScript enabledjava.lang.RuntimeException: Unable to start activity ComponentInfo Android Eclipse - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
J it only takes a minute:
I know a bunch of people have asked this same thing but I just don't know what's going on. I'm trying to make a calculator in Eclipse, but I keep getting a list of errors.
There are no errors in the file that the program notices, although there is an error in the layout.xml but it hasn't caused a problem before so that shouldn't cause a problem.
07-30 08:19:50.470: D/AndroidRuntime(2071): Shutting down VM
07-30 08:19:50.470: W/dalvikvm(2071): threadid=1: thread exiting with uncaught
exception (group=0x40a421f8)
07-30 08:19:50.480: E/AndroidRuntime(2071): FATAL EXCEPTION: main
07-30 08:19:50.480: E/AndroidRuntime(2071): java.lang.RuntimeException: Unable to start
ComponentInfo{com.example.se.miun.chris.calculator/com.example.se.miun.chris.
calculator.MainActivity}: java.lang.NullPointerException
07-30 08:19:50.480: E/AndroidRuntime(2071):
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
07-30 08:19:50.480: E/AndroidRuntime(2071):
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-30 08:19:50.480: E/AndroidRuntime(2071):
android.app.ActivityThread.access$600(ActivityThread.java:123)
07-30 08:19:50.480: E/AndroidRuntime(2071):
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147
07-30 08:19:50.480: E/AndroidRuntime(2071):
android.os.Handler.dispatchMessage(Handler.java:99)
07-30 08:19:50.480: E/AndroidRuntime(2071):
android.os.Looper.loop(Looper.java:137)
07-30 08:19:50.480: E/AndroidRuntime(2071):
android.app.ActivityThread.main(ActivityThread.java:4424)
07-30 08:19:50.480: E/AndroidRuntime(2071):
java.lang.reflect.Method.invokeNative(Native Method)
07-30 08:19:50.480: E/AndroidRuntime(2071):
java.lang.reflect.Method.invoke(Method.java:511)
07-30 08:19:50.480: E/AndroidRuntime(2071):
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-30 08:19:50.480: E/AndroidRuntime(2071):
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-30 08:19:50.480: E/AndroidRuntime(2071):
dalvik.system.NativeStart.main(Native Method)
07-30 08:19:50.480: E/AndroidRuntime(2071): Caused by: java.lang.NullPointerException
07-30 08:19:50.480: E/AndroidRuntime(2071):
com.example.se.miun.chris.calculator.MainActivity.onCreate(MainActivity.java:60)
07-30 08:19:50.480: E/AndroidRuntime(2071):
android.app.Activity.performCreate(Activity.java:4465)
07-30 08:19:50.480: E/AndroidRuntime(2071):
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-30 08:19:50.480: E/AndroidRuntime(2071):
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-30 08:19:50.480: E/AndroidRuntime(2071):
... 11 more
This is my coding. It doesn't really do anything yet, but I wanted to just run it to see if it encountered any errors. This is the mainActivity.java file.
import android.os.B
import android.app.A
import android.text.E
import android.view.M
import android.view.V
import android.view.View.OnClickL
import android.widget.B
import android.widget.TextV
public class MainActivity extends Activity implements OnClickListener {
TextView TextB
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Seven = (Button)findViewById(R.id.NumberSeven);
Seven.setOnClickListener(this);
Eight = (Button)findViewById(R.id.NumberEight);
Eight.setOnClickListener(this);
Nine = (Button)findViewById(R.id.NumberNine);
Nine.setOnClickListener(this);
Four = (Button)findViewById(R.id.NumberFour);
Four.setOnClickListener(this);
Five = (Button)findViewById(R.id.NumberFive);
Five.setOnClickListener(this);
Six = (Button)findViewById(R.id.NumberSix);
Six.setOnClickListener(this);
One = (Button)findViewById(R.id.NumberOne);
One.setOnClickListener(this);
Two = (Button)findViewById(R.id.NumberTwo);
Two.setOnClickListener(this);
Three = (Button)findViewById(R.id.NumberThree);
Three.setOnClickListener(this);
Zero = (Button)findViewById(R.id.NumberZero);
Zero.setOnClickListener(this);
Point = (Button)findViewById(R.id.Point);
Point.setOnClickListener(this);
Negative = (Button)findViewById(R.id.NNegative);
Negative.setOnClickListener(this);
TextBox = (TextView)findViewById(R.id.Screen);
x = (Integer)
y = (Integer)
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
public void onClick(View One) {
if(z == null){
TextBox.setText(x);
TextBox.setText("diggity");
else if(z != null) {
TextBox.setText(x);
TextBox.setText(z);
TextBox.setText(y);
line 60: x = (Integer)
This line will compile to this bytecode (disassembled by javap):
aconst_null
checkcast #2; //class java/lang/Integer
invokevirtual
#3; //Method java/lang/Integer.intValue:()I
Third line will cause a NullPointerException becouse Integer object is actually your null constant :)
Primitive data types (int, long etc.) is the only non-object types in Java. null is used to show that the current variable (Object variable) is not backed by the actual object (no memory was allocated). For primitive types memory allocates immediately so they cant have this null state.
So you should check for "if(x == 0)" or define it as Integer.
P.S. And don't cast null to anything :)
It's like this
you're not getting much errors because the application can't launch. it cannot launch because it's onCreate() cannot finish.
onCreate() cannot finish because of a nullPointerException.
you cast null into integer twice, instead of simply instantiating a new integer which will default to 0. once you get rid of that, it should work.
E/AndroidRuntime(2071): Caused by: java.lang.NullPointerException
E/AndroidRuntime(2071):
MainActivity.onCreate(MainActivity.java:60)
and i bet that this is line 60
x = (Integer)
so change it to
x = new Integer();
4,04311136
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .24976
Stack Overflow works best with JavaScript enabledUnable to start steam: To run Steam, you must first connect to the Internet - Arqade
to customize your list.
Arqade is a question and answer site for passionate videogamers on all platforms. J it only takes a minute:
Here's how it works:
Anybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
Only a messagebox comes up: "Steam.exe (main exception): To run Steam, you must first connect to the Internet"
It worked earlier
Other connections are working (http, ***, skype)
Firewall not blocking
Router not blocking (don't need port forwarding afaik)
Did not found solution or any usable hint on the net so far.
Steam.exe version is 1.0.1065.11
Any suggestions?
As the Steam errors are quite vague, and can refer to a lot of different things, there's not an exact solution. However, the best way to troubleshoot it, is by eliminating various causes.
The most common issues can be solved deleting the ClientRegistry.blob file and force Steam to download a new and fresh copy of it.
The clientregistry.blob is a file for the program Steam. The file holds your registration data for your games. If you delete it the file will be restored and you will have all of your default settings on all games installed (like your name, spray, binds, etc)
Go to C:\Program Files\Steam (or the Steam directory that was specified during installation).
Locate ClientRegistry.blob and delete or rename the file to ClientRegistryOld.blob.
Next time you start Steam, the file will be forced to download.
Another common issue is the update list can become corrupt, this is solvable by deleting the AppUpdateStats.blob file and forcing Steam to download a new and fresh copy.
Go to C:\Program Files\Steam (or the Steam directory that was specified during installation).
Locate AppUpdateStats.blob and delete or rename the file to AppUpdateStatsOld.blob.
Next time you start Steam, the file will be forced to download.
If none of the above work, you should try to start Steam on another computer on the same network, to check for router problems.
If Steam doesn't start on another computer on the same network, it indicates that there is a problem with the router.
Your router might need port forwarding.
is a great site for tutorials on how to forward ports on a lot of routers.
If Steam starts on another computer on the same network. It's something with your computer that's causing issue.
If you have a firewall, try disabling it and start Steam.
If Steam starts your firewall might be blocking it. If you are using Windows Firewall, navigate to Control Panel\All Control Panel Items\Windows Firewall\ and press the "Advanced Settings" button on the left side. Then press the "Restore Default Policy" as
If you are using another firewall, please consult the firewalls manual to figure out how to restore the default settings.
Some programs may interfere with Steam and it's connectivity.
Check your latest installed programs with
for programs that might interfere.
Some Spyware, Adware, and Viruses also interfere with Steam.
Scan your computer for viruses, spyware and adware with an Anti-Virus program of your chose. If would recommend the , if you are in need of a Anti-Virus program.
10.4k115281
The answer to most problems with Steam is to close Steam (shouldn't be a problem for you :P), then go into your Steam Folder (default C:\Program Files\Steam) and delete "clientregistry.blob".
This fixes most login problems, offline mode not working etc, because it causes Steam to re-update to the latest update (should be very quick as it mostly just verifies the files you've already updated).
23.6k2699164
I found that PeerBlock 1.1 was causing this issue on my Win7 machine.
Disabling peer block fixed the issue for me.
I am using a Billion BiPac 7404VGOX and I had to change the firewall general policy here:
Configuration
-General Settings
-Policy (changed from Medium security level to Low security level)
I tried everything else(deleting files / reinstall / firewall off / av off/ NAT settings).
5,542544104
protected by ♦
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10
on this site (the ).
Would you like to answer one of these
Not the answer you're looking for?
Browse other questions tagged
rev .24976
Arqade works best with JavaScript enabled

参考资料

 

随机推荐