Ich versuche, eine Animation auf eine Schaltfläche klicken auszuführen .. Die Schritte sind wie auf die Schaltfläche klicken folgt ..java.lang.OutOfMemoryError bei android.graphics.BitmapFactory.nativeDecodeAsset (Mutter Methode)
- die Taste Bild ändert
- eine Animation spielt
- nächstes Layout angezeigt wird ..
Aber sind immer Ausnahme nicht genügend Arbeitsspeicher ..
Wenn die Animationsdatei nicht zum Projekt hinzugefügt wurde, trat kein Fehler auf. Aber seit dem Hinzufügen des Animes gibt es das Problem.
Ich bin mit drei Klassendateien hier (home_screen, button_anime und zu Hause)
home_screen.java empfängt die Schaltfläche Informationen klicken, ändert sich die Schaltfläche Bild und Transfers zum button_anime Klasse die Animationsdatei im button_anime.java initiiert wird und nach anime nächsten Layout spielt aus home.java angezeigt
Die Log-Katze wird wie folgt ..
E/AndroidRuntime(1255): java.lang.OutOfMemoryError
E/AndroidRuntime(1255): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
E/AndroidRuntime(1255): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
E/AndroidRuntime(1255): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
E/AndroidRuntime(1255): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
E/AndroidRuntime(1255): at android.content.res.Resources.loadDrawable(Resources.java:2110)
E/AndroidRuntime(1255): at android.content.res.Resources.getDrawable(Resources.java:700)
E/AndroidRuntime(1255): at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:282)
E/AndroidRuntime(1255): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937)
E/AndroidRuntime(1255): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
E/AndroidRuntime(1255): at android.content.res.Resources.loadDrawable(Resources.java:2092)
E/AndroidRuntime(1255): at android.content.res.Resources.getDrawable(Resources.java:700)
E/AndroidRuntime(1255): at android.view.View.setBackgroundResource(View.java:15303)
E/AndroidRuntime(1255): at com.quinoid.thomasinternational.Button_Anime.onCreate(Button_Anime.java:19)
E/AndroidRuntime(1255): at android.app.Activity.performCreate(Activity.java:5231)
E/AndroidRuntime(1255): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
E/AndroidRuntime(1255): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
E/AndroidRuntime(1255): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
E/AndroidRuntime(1255): at android.app.ActivityThread.access$800(ActivityThread.java:135)
E/AndroidRuntime(1255): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
E/AndroidRuntime(1255): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(1255): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(1255): at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime(1255): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(1255): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(1255): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime(1255): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime(1255): at dalvik.system.NativeStart.main(Native Method)
Mein home_screen.java
home.setOnClickListener(new OnClickListener() { <-- error happens somewhere here
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Bitmap b = BitmapFactory.decodeResource(getResources(),R.drawable.home1);
Drawable d = new BitmapDrawable(getResources(),b);
home.setBackgroundDrawable(d); <-- this dose not work..
Intent myIntent = new Intent(Home_Screen.this, Button_Anime.class);
startActivity(myIntent);
}
});
Sie haben keinen Speicher mehr. Es kann sein, dass die Bitmap zu groß ist, es kann sein, dass Sie irgendwo anders ein Leck haben. Sie müssen Ihren Speicherverbrauch in einem Heap-Profiler überprüfen, um zu sehen, was passiert. –
alle meine Bilder sind btw 30kb und 50kb .. so wie überprüfe ich meine heap rofiler ?? @GabeSechan – user3214173
Es ist ein in Eclipse eingebaut. Sie sollten nach Ausreißer von Klassen oder großen Zuordnungen suchen, die keinen Sinn ergeben. –