Unable to instantiate activity componentinfo ошибка

I was trying to run a sample code
While launching the application in the android 1.5 emulator , I got these errors….
Any one have some hint..?

ERROR from LogCat:

01-13 02:28:08.392: ERROR/AndroidRuntime(2888): FATAL EXCEPTION: main
01-13 02:28:08.392: ERROR/AndroidRuntime(2888): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.s.android.test/com.s.android.test.MainActivity}: java.lang.ClassNotFoundException: com.s.android.test.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.s.android.test-2.apk]
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1544)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at android.os.Looper.loop(Looper.java:123)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at android.app.ActivityThread.main(ActivityThread.java:3647)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at java.lang.reflect.Method.invokeNative(Native Method)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at java.lang.reflect.Method.invoke(Method.java:507)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at dalvik.system.NativeStart.main(Native Method)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888): Caused by: java.lang.ClassNotFoundException: com.s.android.test.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.s.android.test-2.apk]
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1536)
01-13 02:28:08.392: ERROR/AndroidRuntime(2888):     ... 11 more
01-13 02:28:08.407: WARN/ActivityManager(112):   Force finishing activity com.s.android.test/.MainActivity

Edit
This error happens to most of the beginners, the thing is that you have to add all your activities in the Manifest file.

Braiam's user avatar

asked Jan 14, 2011 at 5:37

rahul's user avatar

4

It is a problem of your Intent.

Please add your Activity in your AndroidManifest.xml.

When you want to make a new activity, you should register it in your AndroidManifest.xml.

Mohsen Kamrani's user avatar

answered Jan 14, 2011 at 6:45

Tanmay Mandal's user avatar

Tanmay MandalTanmay Mandal

39.8k12 gold badges51 silver badges48 bronze badges

5

You may be trying to find the view before onCreate() which is incorrect.

public class MainActivity extends Activity {

  ImageView mainImage = (ImageView) findViewById(R.id.imageViewMain); //incorrect

  @Override
  protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }
  ...
}

answered Nov 18, 2013 at 13:50

SMUsamaShah's user avatar

SMUsamaShahSMUsamaShah

7,57722 gold badges88 silver badges130 bronze badges

3

There is another way to get an java.lang.RuntimeException: Unable to instantiate activity ComponentInfo exception and that is the activity that you are trying to start is abstract. I made this stupid mistake once and its very easy to overlook.

answered Dec 6, 2011 at 15:38

Kevin's user avatar

KevinKevin

1,72513 silver badges16 bronze badges

4

In my case I forgot to add the google maps library

<application>
    ....

    <uses-library android:name="com.google.android.maps" />
</application>

Also, check that you’re not missing the preceding dot before the activity path

<activity android:name=".activities.MainActivity"/>

answered Apr 29, 2011 at 10:43

Maragues's user avatar

MaraguesMaragues

37.7k14 gold badges94 silver badges96 bronze badges

1

Image

It also happens because of this issue. I unchecked the jars that needed be exported to the apk and this same thing happened. Please tick the jars that your app Needs to run.

answered Jul 2, 2013 at 11:35

meowmeowbeans's user avatar

1

This might not be relevant to the actual question, but in my instance, I tried to implement Kotlin and left out apply plugin: 'kotlin-android'. The error happened because it could not recognize the MainActivity in as a .kt file.

Hope it helps someone.

answered Dec 13, 2016 at 18:08

Muz's user avatar

MuzMuz

5,8163 gold badges47 silver badges65 bronze badges

2

I encountered this problem too, but in a slightly different way. Here was my scenario:

App detail:

  • Using ActionBarSherlock as a library
  • Using android-support-v4-r7-googlemaps.jar in the ActionBarSherlock library so I could use a «map fragment» in my primary project
  • Added the jar to the build path of my primary project
  • Included the <uses-library android:name="com.google.android.maps" /> in the manifests of both the library project and my primary project (this may not be necessary in the library?)
  • The manifest in the primary project had the proper activity definition and all of the appropriate properties
  • I didn’t have an abstract activity or any of the other gotchas I’ve seen on Stack Overflow pertaining to this problem.

However, I still encountered the error described in the original post and could not get it to go away. The problem though, was slightly different in one regard:

  • It only affected a fresh install of the application to my device. Any time the app installed for the first time, I would get the error preceded by several «warnings» of: Unable to resolve superclass of FragmentActivity
  • Those warnings traced back to the ActionBarSherlock library
  • The app would force close and crash.
  • If I immediately rebuilt and redeployed the app, it worked fine.
  • The only time it crashed was on a totally fresh install. If I uninstalled the app, built and deployed again from Eclipse, it would crash. Build/deploy a second time, it would work fine.

How I fixed it:

  • In the ActionBarSherlock library project, I added the android-support-v4-r7-googlemaps.jar to the build path
  • This step alone did not fix the problem

  • Once the jar was added to the build path, I had change the order on the Java Build Path > Order and Export tab — I set the JAR to the first item in the list (it was the last after the /src and /gen items).

  • I then rebuilt and redeployed the app to my device — it worked as expected on a fresh install. Just to be certain, I uninstalled it again 2-3 times and reinstalled — still worked as expected.

This may be a total rookie mistake, but I spent quite a while digging through posts and my code to figure it out, so hopefully it can be helpful to someone else. May not fix all situations, but in this particular case, that ended up being the solution to my problem.

answered Oct 12, 2012 at 12:29

Kyle's user avatar

KyleKyle

6065 silver badges16 bronze badges

1

This error can also be the ultimate sign of a dumb mistake (like when I — I mean, cough, like when a friend of mine who showed me their code once) where they try to execute code outside of a method like trying to do this:

SQLiteDatabase db = openOrCreateDatabase("DB", MODE_PRIVATE, null); //trying to perform function where you can only set up objects, primitives, etc

@Override
public void onCreate(Bundle savedInstanceState) {
....
}

rather than this:

SQLiteDatabase db;

@Override
public void onCreate(Bundle savedInstanceState) {
db = openOrCreateDatabase("DB", MODE_PRIVATE, null);
....
}

answered Oct 29, 2013 at 20:15

Chris Klingler's user avatar

Chris KlinglerChris Klingler

5,2482 gold badges37 silver badges43 bronze badges

1

For me, my package string in AndroidManifest.xml was incorrect (copied from a tutorial).
Make sure the package string in this file is the same as where your main activity is, e.g.

 package="com.example.app"

An easy way to do this is to open the AndroidManifest.xml file in the «Manifest» tab, and type it in the text box next to Package, or use the Browse button.

Also, the package string for my activity was wrong, e.g.

<activity android:name="com.example.app.MainActivity" android:label="@string/app_name">

I (stupidly) got the same error weeks later when I renamed my package name. If you do this, make sure you update the AndroidManifest.xml file too.

Jared Burrows's user avatar

Jared Burrows

54.1k24 gold badges151 silver badges185 bronze badges

answered Aug 27, 2012 at 8:36

satyrFrost's user avatar

satyrFrostsatyrFrost

3938 silver badges17 bronze badges

1

I got rid of this problem by deleting the Bin and Gen folder from project(which automatically come back when the project will build) and then cleaning the project from ->Menu -> Project -> clean.

Thanks.

answered Apr 6, 2013 at 10:07

Jagdeep Singh's user avatar

Jagdeep SinghJagdeep Singh

1,2001 gold badge16 silver badges34 bronze badges

Simply Clean your working project or restart eclipse. Then run your project. it will work.

answered Jul 16, 2014 at 6:01

Emran Hamza's user avatar

Emran HamzaEmran Hamza

3,8191 gold badge24 silver badges20 bronze badges

1

In my case I haven’t set the setContentView(R.layout.main);

If you create a new class do not foget to set this in on onCreate(Bundle savedInstanceState) method.

I have done this stupid mistake several times.

answered Jan 25, 2012 at 6:59

saji159's user avatar

saji159saji159

3287 silver badges14 bronze badges

For me it was different from any of the above,

The activity was declared as abstract, That is why giving the error.
Once it removed it worked.

Earlier

     public abstract class SampleActivity extends AppcompatActivity{
     }

After removal

     public class SampleActivity extends AppcompatActivity{
     }

answered Jan 9, 2020 at 12:30

Thriveni's user avatar

ThriveniThriveni

7429 silver badges11 bronze badges

0

Ok, I am fairly experienced on the iPhone but new to android. I got this issue when I had:

Button infoButton = (Button)findViewById(R.id.InfoButton);

this line of code above:

@Override
public void onCreate (Bundle savedInstanceState) {
}

May be I am sleep deprived :P

answered Jun 19, 2012 at 15:09

iSee's user avatar

iSeeiSee

6041 gold badge14 silver badges31 bronze badges

1

In my case, I was trying to initialize the components(UI) even before the onCreate is called for the Activity.

Make sure your UI components are initialized/linked in the onCreate method after setContentView

NB: This is my first mistake while learning Android programming.

answered Apr 12, 2019 at 16:20

Anup H's user avatar

Anup HAnup H

5197 silver badges10 bronze badges

1

Make sure MainActivity is not «abstract».

abstract class MainActivity : AppCompatActivity()

just remove the abstract

class MainActivity : AppCompatActivity() {

answered Sep 29, 2021 at 11:54

Amit Singh's user avatar

Amit SinghAmit Singh

5595 silver badges6 bronze badges

I recently encountered this with fresh re-install of Eclipse. Turns out my Compiler compliance level was set to Java 1.7 and project required 1.6.

In Eclipse:
Project -> Properties -> Java Compiler -> JDK Compliance

answered Oct 24, 2012 at 7:24

J.G.Sebring's user avatar

J.G.SebringJ.G.Sebring

5,9241 gold badge31 silver badges42 bronze badges

Whow are there lots of ways to get this error!.

I will add another given none of the others either applied or were the cause.

I forgot the ‘public‘ in the declaration of my activity class! It was package private.

I had been writing so much Bluetooth code that habit caused me to create an activity class that was package private.

Says something about the obscurity of this error message.

answered Jul 25, 2020 at 0:40

Brian Reinhold's user avatar

Brian ReinholdBrian Reinhold

2,3133 gold badges27 silver badges45 bronze badges

Got this problem, and fixed it by setting the «launch mode» property of the activity.

answered Apr 6, 2012 at 13:28

Zorglube's user avatar

Another reason of this problem may be a missing library.

Go to Properties -> Android and check that you add the libraries correctly

answered Mar 7, 2013 at 10:39

ayalcinkaya's user avatar

ayalcinkayaayalcinkaya

3,28328 silver badges25 bronze badges

1

I had the same problem, but I had my activity declared in the Manifest file, with the correct name.

My problem was that I didn’t have to imported a third party libraries in a «libs» folder, and I needed reference them in my proyect (Right-click, properties, Java Build Path, Libraries, Add Jar…).

answered Jun 11, 2013 at 16:49

Maria Mercedes Wyss Alvarez's user avatar

This can happen if your activity class is inside a default package. I fixed it by moving the activity class to a new package. and changing the manifest.xml

before

activity android:name=".MainActivity" 

after

activity android:name="new_package.MainActivity"

Rohit5k2's user avatar

Rohit5k2

17.9k8 gold badges45 silver badges57 bronze badges

answered Jun 7, 2014 at 18:02

Satthy's user avatar

SatthySatthy

1091 gold badge3 silver badges10 bronze badges

1

As suggested by djjeck in comment in this answer I missed to put public modifier for my class.

It should be

public class MyActivity extends AppCompatActivity {

It may help some like me.

answered Nov 13, 2017 at 12:36

Shailendra Madda's user avatar

Shailendra MaddaShailendra Madda

20.5k15 gold badges98 silver badges137 bronze badges

In my case I forget to make MainActivity class as public.

Other solutions:

  1. Add activity in Manifest file

  2. Verify all access modifiers

answered Aug 19, 2020 at 10:03

manoj kiran's user avatar

This happens to me fairly frequently when using the NDK. I found that it is necessary for me to do a «Clean» in Eclipse after every time I do a ndk-build. Hope it helps anyone :)

answered Jan 23, 2012 at 17:04

kizzx2's user avatar

kizzx2kizzx2

18.7k14 gold badges76 silver badges82 bronze badges

This error also occurs when you use of ActionBarActivity but assigned a non AppCompat style.

To fix this just set your apps style parent to an Theme.AppCompat one like this.:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
</style>

answered Dec 5, 2013 at 9:14

Ostkontentitan's user avatar

OstkontentitanOstkontentitan

6,9005 gold badges53 silver badges71 bronze badges

1

Right click on project > properties > android > and try with different version of the android earlier i was doing with android 4.4 then i changed to android 4.3 and it worked !

answered Mar 9, 2014 at 10:51

nikhilgotan's user avatar

Most the time If Activity name changed reflected all over the project except the AndroidManifest.xml file.

You just need to Add the name in manifest manually.

<activity
android:name="Activity_Class_Name"
android:label="@string/app_name">
</activity>

Anand Dwivedi's user avatar

answered Mar 4, 2013 at 8:48

Swapnil Kotwal's user avatar

Swapnil KotwalSwapnil Kotwal

5,4185 gold badges47 silver badges90 bronze badges

I had the same issue (Unable to instantiate Activity) :

FIRST reason :

I was accessing

Camera mCamera;
Camera.Parameters params = mCamera.getParameters();

before

mCamera = Camera.open();

So right way of doing is, open the camera first and then access parameters.

SECOND reason : Declare your activity in the manifest file

<activity android:name=".activities.MainActivity"/>

THIRD reason :
Declare Camera permission in your manifest file.

<uses-feature android:name="android.hardware.Camera"></uses-feature>
<uses-permission android:name="android.permission.CAMERA" />

Hope this helps

answered May 11, 2016 at 20:17

Sdembla's user avatar

SdemblaSdembla

1,61913 silver badges13 bronze badges

In my case, I was trying to embed the Facebook SDK and I was having the wrong Application ID; thus the error was popping up. In your manifest file, you should have the proper meta data:

<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />

answered Jul 9, 2016 at 14:52

Menelaos Kotsollaris's user avatar

0

Cheshire_161

0 / 0 / 0

Регистрация: 28.01.2016

Сообщений: 18

1

08.02.2016, 10:47. Показов 6240. Ответов 9

Метки activity, java, java android (Все метки)


Студворк — интернет-сервис помощи студентам

Добрый день!
Уже все перепробовал, серверы гугла скоро в ребут уйдут…

Компилит без ошибок, но в эмуле при переходе на этот активити — выкидывает приложение.
«Unable to instantiate activity ComponentInfo Caused by: java.lang.NullPointerException at android.app.Activity.findViewById» — из лога.
Лог ошибки:

Кликните здесь для просмотра всего текста

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.cheshire161gmail.guessthefilm/com.cheshire161gmail.guessthefilm.Main2Activity}: java.lang.NullPointerException
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
                                                                                     at android.app.ActivityThread.access$600(ActivityThread.java:130)
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                     at android.os.Looper.loop(Looper.java:137)
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                                     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:786)
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                                     at dalvik.system.NativeStart.main(Native Method)
                                                                                  Caused by: java.lang.NullPointerException
                                                                                     at android.app.Activity.findViewById(Activity.java:1825)
                                                                                     at com.cheshire161gmail.guessthefilm.Main2Activity.<init>(Main2Activity.java:18)
                                                                                     at java.lang.Class.newInstanceImpl(Native Method)
                                                                                     at java.lang.Class.newInstance(Class.java:1319)
                                                                                     at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)*
                                                                                     at android.app.ActivityThread.access$600(ActivityThread.java:130)*
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)*
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:99)*
                                                                                     at android.os.Looper.loop(Looper.java:137)*
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:4745)*
                                                                                     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:786)*
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)*
                                                                                     at dalvik.system.NativeStart.main(Native Method)*

Вот код Main2Activity :

Кликните здесь для просмотра всего текста

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
 
 
 
 
public class Main2Activity extends AppCompatActivity {
 
    private Toolbar toolbar;
    String strName = "q";
    int i = 1;
    TextView textQuest = (TextView) findViewById(R.id.textView2);
    public int result = 0;
    Intent intent2 = new Intent(this, Main22Activity.class);
    Intent intent = new Intent(Main2Activity.this, Main22Activity.class);
    Intent intent3 = new Intent(Main2Activity.this, Main3Activity.class);
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        toolbar = (Toolbar) findViewById(R.id.my_toolbar);
        setSupportActionBar(toolbar);
        textQuest.setText(R.string.q1);
 
    }
 
    public void onY(View view) {
        if (i<40) {
            i++;
            result++;
            textQuest.setText(strName + i);
            intent2.putExtra("name", result);
            }
        else{
            intent2.putExtra("name",result);
            startActivity(intent);}
        }
 
    public void onN(View view) {
        if (i<40){
            i++;
            TextView textQuest = (TextView) findViewById(R.id.textView2);
        textQuest.setText(strName + i);
            intent2.putExtra("name", result);}
        else {
            intent2.putExtra("name",result);
            startActivity(intent);}
    }
 
    public void onBack(View view) {
        startActivity(intent3);
    }
}

Вот код Main22Activity (если нужен):

Кликните здесь для просмотра всего текста

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
 
public class Main22Activity extends AppCompatActivity {
    TextView textRes = (TextView) findViewById(R.id.textView3);
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main22);
        Intent intent2 = getIntent();
        String name = intent2.getStringExtra("name");
        textRes.setText(name);
    }
}

Вот манифест:

Кликните здесь для просмотра всего текста

XML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cheshire161gmail.guessthefilm">
 
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:windowNoTitle="true">
 
        <activity
            android:name=".MainActivity"
            android:theme="@style/AppTheme.Launcher">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Main2Activity" />
        <activity android:name=".Main3Activity" />
        <activity android:name=".Main22Activity"/>
    </application>
 
</manifest>



0



390 / 336 / 82

Регистрация: 17.10.2014

Сообщений: 1,005

08.02.2016, 10:55

2

Лог по всей видимости не соответствует коду, так как жалуется на 18 строку, и findViewById

Цитата
Сообщение от Cheshire_161
Посмотреть сообщение

Caused by: java.lang.NullPointerException
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *at android.app.Activity.findViewById(Activity.java:1825)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *at com.cheshire161gmail.guessthefilm.Main2Activity.<init>(Main2Activity.java:18)

но скорее всего в разметке нет TextView c id=textView2.



0



Cheshire_161

0 / 0 / 0

Регистрация: 28.01.2016

Сообщений: 18

08.02.2016, 11:11

 [ТС]

3

androbro, Есть такой TextView:

XML
1
2
3
4
5
6
7
<TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/textView2"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true" />

По поводу 18 строки, может я не последний свой вариант скопировал, я там менял местами строчку эту, во всяком случае суть от этого не меняется, ошибка всегда та же, лог точно отсюда



0



androbro

390 / 336 / 82

Регистрация: 17.10.2014

Сообщений: 1,005

08.02.2016, 11:17

4

Цитата
Сообщение от Cheshire_161
Посмотреть сообщение

может я не последний свой вариант скопировал,

ну так приведите актуальный код, который соответствует логу.

Добавлено через 3 минуты
Cheshire_161, ааа, постойте ка, Вы строчку то эту в onCreate() перенесите:

Java
1
   TextView textQuest = (TextView) findViewById(R.id.textView2);

нельзя искать элемент вьюшку до того как будет основной лейаут привязан



0



Cheshire_161

0 / 0 / 0

Регистрация: 28.01.2016

Сообщений: 18

08.02.2016, 11:25

 [ТС]

5

androbro,

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.cheshire161gmail.guessthefilm;
 
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
 
 
 
 
public class Main2Activity extends AppCompatActivity {
 
    private Toolbar toolbar;
    String strName = "q";
    int i = 1;
    TextView textQuest = (TextView) findViewById(R.id.textView2);
    public int result = 0;
    Intent intent2 = new Intent(this, Main22Activity.class);
    Intent intent = new Intent(Main2Activity.this, Main22Activity.class);
    Intent intent3 = new Intent(Main2Activity.this, Main3Activity.class);
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        toolbar = (Toolbar) findViewById(R.id.my_toolbar);
        setSupportActionBar(toolbar);
        textQuest.setText(R.string.q1);
 
    }
 
    public void onY(View view) {
        if (i<40) {
            i++;
            result++;
            textQuest.setText(strName + i);
            intent2.putExtra("name", result);
        }
        else{
            intent2.putExtra("name",result);
            startActivity(intent);}
    }
 
    public void onN(View view) {
        if (i<40){
            i++;
            TextView textQuest = (TextView) findViewById(R.id.textView2);
            textQuest.setText(strName + i);
            intent2.putExtra("name", result);}
        else {
            intent2.putExtra("name",result);
            startActivity(intent);}
    }
 
    public void onBack(View view) {
        startActivity(intent3);
    }
}

Теперь это 18ая строка))

Добавлено через 3 минуты
androbro, так а если я перенесу в onCreate у меня дальше в обработчиках кнопки не будет работать textQuest



0



2882 / 2294 / 769

Регистрация: 12.05.2014

Сообщений: 7,978

08.02.2016, 11:27

6

так же ка и тулбар — объявление в шапке, а инициализация в onCreate()
что тут непонятного?



1



androbro

390 / 336 / 82

Регистрация: 17.10.2014

Сообщений: 1,005

08.02.2016, 11:30

7

Лучший ответ Сообщение было отмечено Cheshire_161 как решение

Решение

Цитата
Сообщение от Cheshire_161
Посмотреть сообщение

androbro, так а если я перенесу в onCreate у меня дальше в обработчиках кнопки не будет работать textQuest

ну так объявление оставьте там же:

Java
1
TextView textQuest;

а инициализируйте в onCreate():

Java
1
textQuest = (TextView) findViewById(R.id.textView2);



1



Cheshire_161

0 / 0 / 0

Регистрация: 28.01.2016

Сообщений: 18

08.02.2016, 11:40

 [ТС]

8

androbro, теперь жалуется на Intent…

Java
1
2
3
4
5
Caused by: java.lang.NullPointerException
                                                                                     at android.content.ContextWrapper.getPackageName(ContextWrapper.java:127)
                                                                                     at android.content.ComponentName.<init>(ComponentName.java:75)
                                                                                     at android.content.Intent.<init>(Intent.java:3301)
                                                                                     at com.cheshire161gmail.guessthefilm.Main2Activity.<init>(Main2Activity.java:20)



0



390 / 336 / 82

Регистрация: 17.10.2014

Сообщений: 1,005

08.02.2016, 11:43

9

Цитата
Сообщение от Cheshire_161
Посмотреть сообщение

теперь жалуется на Intent…

ну так если жалуется, поступаем и с интентом аналогичным образом.



0



0 / 0 / 0

Регистрация: 28.01.2016

Сообщений: 18

08.02.2016, 11:49

 [ТС]

10

androbro, Паблито, такая ошибка глупая оказывается))) Спасибо, помогло!



0



Resolve Java.Lang.RuntimeException: Unable to Instantiate Activity ComponentInfo

Today, we will learn about another runtime exception that says Unable to instantiate activity ComponentInfo.

We will explore different possible reasons that result in java.lang.RuntimeException: Unable to instantiate activity ComponentInfo. Finally, we will have a solution to eradicate it.

Resolve the java.lang.RuntimeException: Unable to instantiate activity ComponentInfo Error

Example Code for Error Demonstration (MainActivity.java file):

public class MainActivity extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }
  //write your remaining code here
}

Example Code (AndroidManifest.xml file):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.app">

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.App"
        tools:targetApi="31">

        <activity
            android:name="MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

When we try to run this while launching an application in the android emulator, we get the error saying java.lang.RuntimeException: Unable to instantiate activity ComponentInfo.

There are a few possible causes that we must consider to resolve this. All of them are listed below.

  • Make sure that your Activity is added to the AndroidManifest.xml file. Why is it necessary?

    It is because whenever we want to make a new Activity, we must register in our AndroidManifest.xml file. Also, verify all the access modifiers.

  • We also get this error when we try to view before onCreate(), which is incorrect and results in an error stating unable to instantiate activity component info error.

  • Another reason for getting java.lang.RuntimeException: Unable to instantiate activity ComponentInfo is that we have added our Activity in AndroidManifest.xml, which is declared as abstract. In other words, we can say that the Activity we are trying to access is declared abstract.

  • Make sure that we are not missing a preceding dot before an activity path (this thing is causing an error in the example code given above).

  • We also have to face this error if we did not declare our MainActivity.java file as public. Also, check if your file is in the right package or not.

Now, we know all the possible reasons. How can we fix it?

See the following solution.

Example Code for Solution (MainActivity.java file):

public class MainActivity extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }
  //write your remaining code here
}

Example Code (AndroidManifest.xml file):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.app">

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.App"
        tools:targetApi="31">

        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

We have added a preceding dot before an activity path. We also confirm that our MainActivity.java file is declared as public, and we are not trying to access an Activity declared as abstract.

Be careful of all the points given as causes because those points are actual solutions if we consider them.

tns-core-modules 6.0.4 
tns-android 6.0.1  
Will emit event runOnDeviceExecuted with data { projectDir:
   'C:\Users\unite',
  deviceIdentifier: '52033ae5f42a146f',
  applicationIdentifier: 'org.nativescript.Unite',
  syncedFiles:
   [ 'C:\Users\unite\platforms\android\app\src\main\assets\app\runtime.js' ],
  isFullSync: true }
Will send the following information to Google Analytics: { type: 'googleAnalyticsData',
  category: 'CLI',
  googleAnalyticsDataType: 'event',
  action: 'Performance',
  label: 'RunController__refreshApplicationWithoutDebug',
  customDimensions: { cd2: 'Angular', cd9: 'false', cd5: 'Unknown' },
  value: 3751 }
Successfully synced application org.nativescript.Unite on device 52033ae5f42a146f.
Will emit event runOnDeviceStarted with data { projectDir:
   'C:\Users\unite',
  deviceIdentifier: '52033ae5f42a146f',
  applicationIdentifier: 'org.nativescript.Unite' }
System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to instantiate activity ComponentInfo{org.nativescript.Unite/com.tns.NativeScriptActivity}: java.lang.ClassNotFoundException: Didn't find class "com.tns.NativeScriptActivity" on path: DexPathList[[zip file "/data/app/org.nativescript.Unite-N8LvQmyn0YOtygBLHss0Mw==/base.apk"],nativeLibraryDirectories=[/data/app/org.nativescript.Unite-N8LvQmyn0YOtygBLHss0Mw==/lib/arm, /data/app/org.nativescript.Unite-N8LvQmyn0YOtygBLHss0Mw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]
System.err: 
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.nativescript.Unite/com.tns.NativeScriptActivity}: java.lang.ClassNotFoundException: Didn't find class "com.tns.NativeScriptActivity" on path: DexPathList[[zip file "/data/app/org.nativescript.Unite-N8LvQmyn0YOtygBLHss0Mw==/base.apk"],nativeLibraryDirectories=[/data/app/org.nativescript.Unite-N8LvQmyn0YOtygBLHss0Mw==/lib/arm, /data/app/org.nativescript.Unite-N8LvQmyn0YOtygBLHss0Mw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]
System.err: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2850)
System.err: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3059)
System.err: 	at android.app.ActivityThread.-wrap11(Unknown Source:0)
System.err: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
System.err: 	at android.os.Handler.dispatchMessage(Handler.java:106)
System.err: 	at android.os.Looper.loop(Looper.java:164)
System.err: 	at android.app.ActivityThread.main(ActivityThread.java:7000)
System.err: 	at java.lang.reflect.Method.invoke(Native Method)
System.err: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.tns.NativeScriptActivity" on path: DexPathList[[zip file "/data/app/org.nativescript.Unite-N8LvQmyn0YOtygBLHss0Mw==/base.apk"],nativeLibraryDirectories=[/data/app/org.nativescript.Unite-N8LvQmyn0YOtygBLHss0Mw==/lib/arm, /data/app/org.nativescript.Unite-N8LvQmyn0YOtygBLHss0Mw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]
System.err: 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
System.err: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
System.err: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
System.err: 	at android.app.Instrumentation.newActivity(Instrumentation.java:1182)
System.err: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2840)
System.err: 	... 9 more

Answer by Pablo Benton

Meta Stack Overflow

,

Stack Overflow

help
chat

,Stack Overflow en español,Stack Overflow на русском

Replace this

<activity
        android:name="amitechnologies.products.apps.equalizeraudioplayer.v3.view.LoaderOfAllMediaFiles"         
</activity>

with this

 <activity
        android:name=".amitechnologies.products.apps.equalizeraudioplayer.v3.view.LoaderOfAllMediaFiles"         
 </activity>

Answer by Camilla Ferguson

At the time you want to create a new activity, you must register it in your AndroidManifest.xml.,There is another method to obtain an java.lang.RuntimeException: Unable to instantiate activity Component Info exception and that is the activity that you are attempting to begin is abstract. I made this stupid mistake at one time and its very simple to overlook.,
backup a table in sql
,Further, the package string for my activity was wrong, for example

You may be attempting to find the view before onCreate() which is incorrect.

public class MainActivity extends Activity {

  ImageView mainImage = (ImageView) findViewById(R.id.imageViewMain); //incorrect

  @Override
  protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }
  ...
}

In my instance I forgot to include the google maps library

<application>
    ....

    <uses-library android:name="com.google.android.maps" />
</application>

Further, check that you’re not missing the former dot prior the activity path

<activity android:name=".activities.MainActivity"/>

This error can also be the ultimate sign of a dumb mistake (like when I — I imply, cough, like at the time a friend of mine who showed me their code once) where they attempt to execute code outside of a method like attempting to do this:

SQLiteDatabase db = openOrCreateDatabase("DB", MODE_PRIVATE, null); //trying to perform function where you can only set up objects, primitives, etc

@Override
public void onCreate(Bundle savedInstanceState) {
....
}

Rather than this:

SQLiteDatabase db;

@Override
public void onCreate(Bundle savedInstanceState) {
db = openOrCreateDatabase("DB", MODE_PRIVATE, null);
....
}

For me, my package string in AndroidManifest.xml was inaccurate . Ensure that the package string in this file is the similar as where your main activity is, for example

 package="com.example.app"

Further, the package string for my activity was wrong, for example

<activity android:name="com.example.app.MainActivity" android:label="@string/app_name">

In case this is the instance, you require to include an extra configuration in the webpack.config.js file. To resolve the incident include `MainActivity: ./activity’, to the entry in webpack.config.js like this:

const entry = {
    // Discover entry module from package.json
    bundle: `./${nsWebpack.getEntryModule()}`,
 
    // Vendor entry with third-party libraries
    vendor: `./vendor`,
 
    /// HERE
    MainActivity: './activity',
 
    // Entry for stylesheet with global application styles
    [mainSheet]: `./${mainSheet}`,
};

Answer by Greyson Stafford

If you add any files,it will delete all existing files related to this question-(questions only answer remains unchanged),Note** this option does not delete the question immediately,Since others contribution also matters and security reasons.Your request will be Queued.We will review the question and remove.It may take some days.,If you add any files,it will delete all existing files related to this answer-(only this answer),in my aplication i wanna to view a slide pictures as the marquee with the text view (put here with images instead of the text view ), i have this code already from the internet but at the run time i have a run time exception which is » unable to instantiate activity componentinfo»
i try to fix the problem by right click on the project and then goes to properties then at java build path do some thing ,, and then clean the project but also i still have the same problem ,, i have been restarted the emulator and eclipse but also this isn’t useful for me what must i do to run this code ??

this is my code:

            package com.example.marquee;

        import java.util.Timer;
        import java.util.TimerTask;

        import android.app.Activity;
        import android.os.Bundle;
        import android.os.Handler;
        import android.view.View;
        import android.widget.ImageView;

        public class AutoSlider extends Activity {

            public int currentimageindex=0;
            Timer timer;
            TimerTask task;
            ImageView slidingimage;

            int[] IMAGE_IDS = {R.drawable.ic_launcher, R.drawable.yt, R.drawable.yt,
                    R.drawable.s};

            @Override
            protected void onCreate(Bundle savedInstanceState) 
        {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
                final Handler mHandler = new Handler();

                // Create runnable for posting
                final Runnable mUpdateResults = new Runnable() {
                    public void run() {

                        AnimateandSlideShow();

                    }
                };

                int delay = 1000; // delay for 1 sec.

                int period = 8000; // repeat every 4 sec.

                Timer timer = new Timer();

                timer.scheduleAtFixedRate(new TimerTask() {

                public void run() {

                     mHandler.post(mUpdateResults);

                }

                }, delay, period);

            }

            public void onClick(View v) {

                finish();
                android.os.Process.killProcess(android.os.Process.myPid());
              }
               private void AnimateandSlideShow() {

                slidingimage = (ImageView)findViewById(R.id.imageView1);
                slidingimage.setImageResource(IMAGE_IDS[currentimageindex%IMAGE_IDS.length]);

                currentimageindex++;

              }}

Answer by Malaysia Bullock

I was having the same problem and your comment about starting from scratch prompted the answer – you just need to do a clean build.,If you find copyright violations, you can contact us at info-generacodice.com to request the removal of the content.,You cant cast your class Prefs to Activity,The Contents are licensed under creative commons.

Prefs.java:

   package org.example.sudoku;

    import android.os.Bundle;
    import android.preference.PreferenceFragment;
    //import android.preference.PreferenceActivity;


    public class Prefs extends PreferenceFragment {
        public void onCreate(Bundle saveInstanceState) {
            super.onCreate(saveInstanceState);
            addPreferencesFromResource(R.xml.settings); 
        }

    }

Sudoku.java:

       package org.example.sudoku;
        import android.app.Activity;
        import android.os.Bundle;

        import android.content.Intent;
        import android.view.View;
        import android.view.View.OnClickListener;

        import android.view.Menu;
        import android.view.MenuInflater;
        import android.view.MenuItem;


        public class Sudoku extends Activity implements OnClickListener{

            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                // Set up click listeners for all the buttons

                View continueButton = findViewById(R.id.continue_button);
                    continueButton.setOnClickListener(this);
                View newButton = findViewById(R.id.new_button);
                    newButton.setOnClickListener(this);
                View aboutButton = findViewById(R.id.about_button);
                    aboutButton.setOnClickListener(this);
                View exitButton = findViewById(R.id.exit_button);
                    exitButton.setOnClickListener(this);
            }

            public void onClick(View v) {
                switch (v.getId())
                {
                case R.id.about_button:
                    Intent i = new Intent(this, About.class);
                    startActivity(i);
                    break;
                }
        }

            @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            super.onCreateOptionsMenu(menu);
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.menu, menu);
            return true;    

        }


        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            switch(item.getItemId()) {
            case R.id.settings:
                //startActivity(new Intent(this, Prefs.class));
                Intent intent = new Intent(this, Prefs.class);
                startActivity(intent);
                return true;
            }
            return false;


        }
        }

AndroidManifest.xml:

    <?xml version="1.0" encoding="UTF-8"?>
        <menu xmlns:android="http://schemas.android.com/apk/res/android">
            <item android:id="@+id/settings"
                android:title="@string/settings_label"
                android:alphabeticShortcut="@string/settings_shortcut" />



        </menu>

        <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="org.example.sudoku"
        android:versionCode="1"
        android:versionName="1.0" >

        <uses-sdk android:minSdkVersion="15" />

        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
            <activity
                android:name=".Sudoku"
                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=".About"
                    android:label="@string/about_title"
                    android:theme="@android:style/Theme.Dialog">

            </activity>
            <activity android:name=".Prefs"
                    android:label="@string/settings_title">

            </activity>
        </application>

    </manifest>

strings.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>

        <string name="hello">Hello World, Sudoku!</string>
        <string name="app_name">Sudoku Game</string>
        <string name="continue_label">Continue</string>
        <string name="new_game_label">New Game</string>
        <string name="about_label">About</string>
        <string name="exit_label">Exit</string>
        <string name="about_text">Sudoku is a logic-based number placement puzzle. Starting with a partially completed 9x9 grid so that each row, each column, and each of the 3x3 boxes(also called <i>block</i>) contains the digits 1 to 9 exactly once</string>
        <string name="about_title">About Android Sudoku</string>

        <string name="settings_label">Settings
            </string>
        <string name="settings_title">Sudoku Settings</string>
        <string name="settings_shortcut">s</string>
        <string name="music_title">Music</string>
        <string name="music_summary">Play Background Music</string>
        <string name="hints_title">Hints</string>
        <string name="hints_summary">Show hints during play</string>


        </resources>

settings.xml:

    <code>
    <?xml version="1.0" encoding="utf-8"?>
        <PreferenceScreen
        xmlns:android="http://schemas.android.com/apk/res/android">
        <PreferenceCategory
                android:title="@string/settings_title"> 
        <CheckboxPreference
            android:key="music"
            android:title="@string/music_title"
            android:summary="@string/music_summary"
            android:defaultValue="true" />
        <CheckBoxPreference
            android:key="hints"
            android:title="@string/hints_title"
            android:summary="@string/hints_summary"
            android:defaultValue="true" />
        </PreferenceCategory>
        </PreferenceScreen>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/app_name"
            android:gravity="center"
            android:layout_marginBottom="20dip"
            android:textSize="24.5sp"
             />
        <TableLayout 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="center"
            android:stretchColumns="*">
            <TableRow>

                <Button 
            android:id="@+id/continue_button"
            android:text="@string/continue_label"
            />
            <Button 
            android:id="@+id/new_button"
            android:text="@string/new_game_label"
            />
            </TableRow>
            <TableRow >
            <Button 
            android:id="@+id/about_button"
            android:text="@string/about_label"
            />

            <Button 
            android:id="@+id/exit_button"
            android:text="@string/exit_label"
            />
            </TableRow>
            </TableLayout>

    </LinearLayout>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/app_name"
            android:gravity="center"
            android:layout_marginBottom="20dip"
            android:textSize="24.5sp"
             />
        <TableLayout 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="center"
            android:stretchColumns="*">
            <TableRow>

                <Button 
            android:id="@+id/continue_button"
            android:text="@string/continue_label"
            />
            <Button 
            android:id="@+id/new_button"
            android:text="@string/new_game_label"
            />
            </TableRow>
            <TableRow >
            <Button 
            android:id="@+id/about_button"
            android:text="@string/about_label"
            />

            <Button 
            android:id="@+id/exit_button"
            android:text="@string/exit_label"
            />
            </TableRow>
            </TableLayout>

    </LinearLayout>

Here is all the error messages I am recieving:

    05-18 12:37:16.781: E/AndroidRuntime(623): FATAL EXCEPTION: main
    05-18 12:37:16.781: E/AndroidRuntime(623): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.example.sudoku/org.example.sudoku.Prefs}: java.lang.ClassCastException: org.example.sudoku.Prefs cannot be cast to android.app.Activity
    05-18 12:37:16.781: E/AndroidRuntime(623):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at android.os.Handler.dispatchMessage(Handler.java:99)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at android.os.Looper.loop(Looper.java:137)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at android.app.ActivityThread.main(ActivityThread.java:4424)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at java.lang.reflect.Method.invokeNative(Native Method)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at java.lang.reflect.Method.invoke(Method.java:511)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at dalvik.system.NativeStart.main(Native Method)
    05-18 12:37:16.781: E/AndroidRuntime(623): Caused by: java.lang.ClassCastException: org.example.sudoku.Prefs cannot be cast to android.app.Activity
    05-18 12:37:16.781: E/AndroidRuntime(623):  at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
    05-18 12:37:16.781: E/AndroidRuntime(623):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
    05-18 12:37:16.781: E/AndroidRuntime(623):  ... 11 more

Понравилась статья? Поделить с друзьями:
  • U201f ford ошибка
  • Unable to initialize graphics system ошибка
  • U1540 ошибка опель инсигния
  • Unable to find spawn biome ошибка
  • U1540 ошибка опель астра j