java.lang.ClassCastException: android.app.Application cannot be cast to roboguice.application.RoboApplication
Asked Answered
C

2

8

example using roboguice.
This code get ClassCastException.

public class MainActivity extends RoboActivity{

    @InjectView(R.id.text)
    TextView name;
    @InjectView(R.id.imageView1)
    ImageView imageView;
    Drawable icon;
    @InjectResource(R.string.app_name)
    String myName;



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

all jar files are already included.

My manifest.xml is here..

find this here.

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.roboguice.MainActivity"
            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>

no changes in manifest.xml. if required then say.

Contretemps answered 25/9, 2013 at 10:50 Comment(3)
please post your manifest.xmlAngel
@BirajZalavadia I added manifest.xmlContretemps
@BirajZalavadia Worked application, thanks.Contretemps
A
23

Try this way

<application
        android:name="roboguice.application.RoboApplication" // UPDATE HERE
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
Angel answered 25/9, 2013 at 11:11 Comment(0)
A
1

Add this following line in application tag in AndroidManifest.xml android:name="roboguice.application.RoboApplication"

@see [More details][1] http://code.google.com/p/roboguice/source/browse/roboguice/src/main/java/roboguice/application/RoboApplication.java?r=b6ae6aeaf9417826a2359fd779814af839557ca1

Androgen answered 22/2, 2014 at 7:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.