2013-09-25 8 views
6

Beispiel mit Roboguice umgewandelt werden.
Dieser Code erhält ClassCastException.java.lang.ClassCastException: android.app.Application kann nicht in roboguice.application.RoboApplication

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); 
} 

Alle JAR-Dateien sind bereits enthalten.

Mein manifest.xml hier ist ..

dies hier finden.

<?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> 

keine Änderungen in manifest.xml. bei Bedarf dann sagen.

+0

bitte posten Sie Ihre manifest.xml –

+1

@BirajZalavadia Ich habe manifest.xml hinzugefügt –

+1

@BirajZalavadia Arbeitete Anwendung, danke. –

Antwort

19

Versuchen Sie, diese Art und Weise

<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" >