Bonjour
Tout allait bien, j'ai divisé mon programme en 2 activitée et maintenant quand j'appuis sur mes boutons ca plante... On dirait un manque de mémoire ou je ne sais quois. Mais si je manque de mémoire avec le peu que j'ai fait (ce qui me semble peu probable) alors mieux vaut abandonné le projet.
j'utilise
android:minSdkVersion="16"
android:targetSdkVersion="19"
Ma plus grosse image PNG fait 181*463 bytes.
Est-ce qu'il y a une limite dans le poids des images?
Est-ce qu'il y a de quois que j'ai mal initialisé ou que je devrais mieux géré... le MediaPlaye, le Thread, le ShareProfile...??
voici ce que mon logcat me donne
et voici ma premiere activitée.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 01-21 16:33:41.605: E/Trace(653): error opening trace file: No such file or directory (2) 01-21 16:33:42.834: D/dalvikvm(653): GC_FOR_ALLOC freed 39K, 3% free 10785K/11011K, paused 418ms, total 440ms 01-21 16:33:42.995: I/dalvikvm-heap(653): Grow heap (frag case) to 12.026MB for 1536016-byte allocation 01-21 16:33:43.495: D/dalvikvm(653): GC_CONCURRENT freed <1K, 3% free 12284K/12551K, paused 62ms+39ms, total 489ms 01-21 16:33:44.315: D/dalvikvm(653): GC_FOR_ALLOC freed 0K, 3% free 12284K/12551K, paused 37ms, total 38ms 01-21 16:33:44.377: I/dalvikvm-heap(653): Grow heap (frag case) to 17.885MB for 6144016-byte allocation 01-21 16:33:44.583: D/dalvikvm(653): GC_CONCURRENT freed 0K, 2% free 18284K/18567K, paused 28ms+61ms, total 203ms 01-21 16:33:47.365: D/dalvikvm(653): GC_FOR_ALLOC freed 1549K, 10% free 17418K/19207K, paused 53ms, total 54ms 01-21 16:33:47.396: I/dalvikvm-heap(653): Grow heap (frag case) to 19.478MB for 2557456-byte allocation 01-21 16:33:47.515: D/dalvikvm(653): GC_CONCURRENT freed <1K, 9% free 19915K/21767K, paused 34ms+7ms, total 116ms 01-21 16:33:48.225: D/dalvikvm(653): GC_FOR_ALLOC freed 628K, 11% free 19419K/21767K, paused 44ms, total 50ms 01-21 16:33:48.235: I/dalvikvm-heap(653): Grow heap (frag case) to 20.458MB for 1536016-byte allocation 01-21 16:33:48.604: D/dalvikvm(653): GC_FOR_ALLOC freed <1K, 11% free 20919K/23303K, paused 47ms, total 47ms 01-21 16:33:48.730: D/dalvikvm(653): GC_FOR_ALLOC freed 0K, 11% free 20919K/23303K, paused 90ms, total 90ms 01-21 16:33:48.815: I/dalvikvm-heap(653): Grow heap (frag case) to 26.317MB for 6144016-byte allocation 01-21 16:33:48.925: D/dalvikvm(653): GC_CONCURRENT freed 0K, 9% free 26919K/29319K, paused 26ms+18ms, total 108ms 01-21 16:33:50.265: D/gralloc_goldfish(653): Emulator without GPU emulation detected. 01-21 16:33:55.834: D/dalvikvm(653): GC_FOR_ALLOC freed 1677K, 10% free 26671K/29319K, paused 46ms, total 48ms 01-21 16:33:57.224: I/Choreographer(653): Skipped 46 frames! The application may be doing too much work on its main thread. 01-21 16:33:58.666: D/dalvikvm(653): GC_FOR_ALLOC freed 1711K, 13% free 25621K/29319K, paused 190ms, total 194ms 01-21 16:33:58.834: D/dalvikvm(653): GC_FOR_ALLOC freed 1K, 8% free 27120K/29319K, paused 43ms, total 44ms 01-21 16:33:58.894: I/dalvikvm-heap(653): Grow heap (frag case) to 32.374MB for 6144016-byte allocation 01-21 16:33:59.065: D/dalvikvm(653): GC_CONCURRENT freed 0K, 7% free 33120K/35335K, paused 74ms+21ms, total 178ms 01-21 16:34:00.355: I/Choreographer(653): Skipped 210 frames! The application may be doing too much work on its main thread. 01-21 16:34:06.287: D/dalvikvm(653): GC_FOR_ALLOC freed 1754K, 8% free 32663K/35335K, paused 54ms, total 84ms 01-21 16:34:06.665: D/dalvikvm(653): GC_FOR_ALLOC freed 14814K, 46% free 19349K/35335K, paused 47ms, total 48ms 01-21 16:34:06.675: I/dalvikvm-heap(653): Grow heap (frag case) to 24.784MB for 6144016-byte allocation 01-21 16:34:06.855: D/dalvikvm(653): GC_CONCURRENT freed <1K, 29% free 25348K/35335K, paused 75ms+20ms, total 178ms 01-21 16:34:07.975: D/dalvikvm(653): GC_FOR_ALLOC freed 1801K, 29% free 25329K/35335K, paused 46ms, total 51ms 01-21 16:34:08.195: D/AndroidRuntime(653): Shutting down VM 01-21 16:34:08.195: W/dalvikvm(653): threadid=1: thread exiting with uncaught exception (group=0x40a13300) 01-21 16:34:08.226: E/AndroidRuntime(653): FATAL EXCEPTION: main 01-21 16:34:08.226: E/AndroidRuntime(653): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application 01-21 16:34:08.226: E/AndroidRuntime(653): at android.view.ViewRootImpl.setView(ViewRootImpl.java:589) 01-21 16:34:08.226: E/AndroidRuntime(653): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:326) 01-21 16:34:08.226: E/AndroidRuntime(653): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224) 01-21 16:34:08.226: E/AndroidRuntime(653): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149) 01-21 16:34:08.226: E/AndroidRuntime(653): at android.app.Dialog.show(Dialog.java:277) 01-21 16:34:08.226: E/AndroidRuntime(653): at com.example.legendsofkings.City.Menu_Main(City.java:109) 01-21 16:34:08.226: E/AndroidRuntime(653): at com.example.legendsofkings.City$3.onClick(City.java:74) 01-21 16:34:08.226: E/AndroidRuntime(653): at android.view.View.performClick(View.java:4084) 01-21 16:34:08.226: E/AndroidRuntime(653): at android.view.View$PerformClick.run(View.java:16966) 01-21 16:34:08.226: E/AndroidRuntime(653): at android.os.Handler.handleCallback(Handler.java:615) 01-21 16:34:08.226: E/AndroidRuntime(653): at android.os.Handler.dispatchMessage(Handler.java:92) 01-21 16:34:08.226: E/AndroidRuntime(653): at android.os.Looper.loop(Looper.java:137) 01-21 16:34:08.226: E/AndroidRuntime(653): at android.app.ActivityThread.main(ActivityThread.java:4745) 01-21 16:34:08.226: E/AndroidRuntime(653): at java.lang.reflect.Method.invokeNative(Native Method) 01-21 16:34:08.226: E/AndroidRuntime(653): at java.lang.reflect.Method.invoke(Method.java:511) 01-21 16:34:08.226: E/AndroidRuntime(653): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 01-21 16:34:08.226: E/AndroidRuntime(653): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 01-21 16:34:08.226: E/AndroidRuntime(653): at dalvik.system.NativeStart.main(Native Method)
J'ai toujours cette erreur quand je met minSDK16 : error opening trace file: No such file or directory (2). mais pas quand je met SDK7.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480 package com.projet.jeu; import com.projet.jeu.R.id; import android.media.MediaPlayer; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.ScrollView; import android.widget.TextView; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Typeface; public class Welcome extends Activity { //les variables initiale a sauvegarder boolean newGame =true; String playerName =""; String playerPassword=""; String playerEmail=""; //les variables helper boolean playerNameOk = false; boolean passwordOk = false; boolean emailOk = false; String checkPass1; String checkPass2; //les widget TextView textWelcome; TextView textPlayerName; Button buttonPlay; Button buttonQuit; Button buttonReset; ImageView imageNews; TextView textPlayerNameInfo; EditText editPlayerName; TextView textPasswordInfo; EditText editPassword1; EditText editPassword2; TextView textEmailInfo; EditText editEmail; Button buttonNext; ScrollView scrollStory; TextView textStory; ImageButton buttonNext2; //les vues View viewMenuBackground; View viewWelcome; View viewNewProfil; View viewNewStory; RelativeLayout layoutNews; RelativeLayout layoutWelcomeBackground; //Les composantes MediaPlayer mPlayer = null; //Les Threads Thread autoScrollThread; //Les Animations Animation animationHideNews; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcome); layoutWelcomeBackground = (RelativeLayout)findViewById(R.id.LayoutWelcomeBackground); LoadPlayer(); setWelcome(); } public void LoadPlayer(){ SharedPreferences playerSettings = getSharedPreferences("PlayerSetting", 0); newGame = playerSettings.getBoolean("NewGame", newGame); playerName = playerSettings.getString("PlayerName", playerName); } public void setWelcome (){ viewWelcome = getLayoutInflater().inflate(R.layout.welcome_contenant, layoutWelcomeBackground,false); layoutWelcomeBackground.addView(viewWelcome); layoutNews = (RelativeLayout)findViewById(id.LayoutNews); textWelcome = (TextView)findViewById(id.textWelcome); textWelcome.setText(getString(R.string.textWelcomeBack) + " " + playerName); textPlayerName = (TextView)findViewById(id.textPlayerName); textPlayerName.setText(playerName); buttonPlay = (Button)findViewById(id.buttonPlay); if (newGame == true){buttonPlay.setText(R.string.textButtonPlay_new); } if (newGame == false){buttonPlay.setText(R.string.textButtonPlay_play); } buttonPlay.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View view, MotionEvent arg1) { buttonPlay.setBackgroundResource(R.drawable.button_intro_down); return false; } }); buttonPlay.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { animationHideNews = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.hide_news); layoutNews.startAnimation(animationHideNews); animationHideNews.setAnimationListener(new AnimationListener(){ @Override public void onAnimationEnd(Animation arg0) { if (newGame){ layoutWelcomeBackground.removeView(viewWelcome); NewProfile(); } if (!newGame){ Intent intentCity = new Intent(Welcome.this, City.class); startActivity(intentCity); finish(); } } @Override public void onAnimationRepeat(Animation arg0) { } @Override public void onAnimationStart(Animation arg0) { } }); } }); buttonQuit = (Button)findViewById(id.buttonQuit); buttonQuit.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { finish(); } }); buttonReset = (Button)findViewById(id.buttonReset); buttonReset.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { newGame = true; playerName = "New Player"; textWelcome.setText(getString(R.string.textWelcomeBack) + " " + playerName); textPlayerName.setText(playerName); buttonPlay.setText(R.string.textButtonPlay_new); SavePlayer(); LoadPlayer(); } }); } public void NewProfile (){ viewMenuBackground = getLayoutInflater().inflate(R.layout.menu_background, layoutWelcomeBackground,false); layoutWelcomeBackground.addView(viewMenuBackground); viewNewProfil = getLayoutInflater().inflate(R.layout.new_profile, layoutWelcomeBackground,false); layoutWelcomeBackground.addView(viewNewProfil); playSound(R.raw.guerre_amb); Typeface font = Typeface.createFromAsset(this.getAssets(), "fonts/Fairland.ttf"); TextView textMenuTitle = (TextView)findViewById(id.textNewProfilTitle); textMenuTitle.setTypeface(font); textPlayerNameInfo = (TextView)findViewById(id.textPlayerNameInfo); textPlayerNameInfo.setTextColor(0XFFFF0000); textPasswordInfo = (TextView)findViewById(id.textPasswordInfo); textPasswordInfo.setTextColor(0XFFFF0000); textEmailInfo = (TextView)findViewById(id.textEmailInfo); textEmailInfo.setTextColor(0XFFFF0000); editPlayerName = (EditText)findViewById(id.editPlayerName); editPlayerName.addTextChangedListener(new TextWatcher(){ @Override public void afterTextChanged(Editable arg0) { } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { playerName = String.valueOf(editPlayerName.getText()); textPlayerNameInfo.setTextColor(0XFF00FF00); textPlayerNameInfo.setText(R.string.textPlayerInfo_Ok); playerNameOk = true; if (playerNameOk && passwordOk && emailOk ){ buttonNext.setEnabled(true); } } }); editPassword1 = (EditText)findViewById(id.editPassword); editPassword1.addTextChangedListener(new TextWatcher(){ @Override public void afterTextChanged(Editable s) { checkPass1 = String.valueOf(editPassword1.getText()); checkPass2 = String.valueOf(editPassword2.getText()); if (checkPass1.equals(checkPass2)) { textPasswordInfo.setTextColor(0XFF00FF00); textPasswordInfo.setText(R.string.textPasswordInfo_Ok); passwordOk = true; } else { textPasswordInfo.setTextColor(0XFFFF0000); textPasswordInfo.setText(R.string.textPasswordInfo); passwordOk = false; } if (playerNameOk && passwordOk && emailOk){ buttonNext.setEnabled(true); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); editPassword2 = (EditText)findViewById(id.editPassword2); editPassword2.addTextChangedListener(new TextWatcher(){ @Override public void afterTextChanged(Editable s) { checkPass1 = String.valueOf(editPassword1.getText()); checkPass2 = String.valueOf(editPassword2.getText()); if (checkPass1.equals(checkPass2)) { textPasswordInfo.setTextColor(0XFF00FF00); textPasswordInfo.setText(R.string.textPasswordInfo_Ok); passwordOk = true; } else { textPasswordInfo.setTextColor(0XFFFF0000); textPasswordInfo.setText(R.string.textPasswordInfo); passwordOk = false; } if (playerNameOk && passwordOk && emailOk){ buttonNext.setEnabled(true); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); editEmail = (EditText)findViewById(id.editEmail); editEmail.addTextChangedListener(new TextWatcher(){ @Override public void afterTextChanged(Editable s) { textEmailInfo.setTextColor(0XFF00FF00); textEmailInfo.setText(R.string.textEmailInfo_OK); emailOk = true; if (playerNameOk && passwordOk && emailOk){ buttonNext.setEnabled(true); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before,int count) {} }); buttonNext = (Button)findViewById(id.buttonNewProfilNext); buttonNext.setEnabled(false); buttonNext.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { if (playerNameOk && passwordOk && emailOk){ layoutWelcomeBackground.removeView(viewNewProfil); Save(); Story(); } else { } } }); } public void Story (){ viewNewStory = getLayoutInflater().inflate(R.layout.new_story, layoutWelcomeBackground,false); layoutWelcomeBackground.addView(viewNewStory); playSound(R.raw.guerre_amb); Typeface font = Typeface.createFromAsset(this.getAssets(), "fonts/Fairland.ttf"); scrollStory = (ScrollView)findViewById(id.Scroll_Story); textStory = (TextView)findViewById(id.Text_Story); buttonNext2 = (ImageButton)findViewById(id.Button_Next); textStory.setTypeface(font); scrollStory.setSmoothScrollingEnabled(true); scrollStory.setVerticalScrollBarEnabled(false); TextAutoScroll(); } public void TextAutoScroll (){ autoScrollThread = new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(4000); for (int ScrollPos = 0 ; ScrollPos < textStory.getHeight();++ScrollPos){ final int ScrollValue = ScrollPos; Thread.sleep(50); runOnUiThread(new Runnable() { @Override public void run() { scrollStory.smoothScrollTo(0, ScrollValue); } }); } } catch (InterruptedException e) {return;} } }); autoScrollThread.start(); } private void playSound(int resId) { if(mPlayer != null) { mPlayer.stop(); mPlayer.release(); } mPlayer = MediaPlayer.create(this, resId); mPlayer.setLooping(true); mPlayer.start(); } public void click_ButtonNext(View view){ newGame = false; Save(); Intent intentCity = new Intent(Welcome.this, City.class); startActivity(intentCity); finish(); } public void Save(){ SharedPreferences playerSettings = getSharedPreferences("PlayerSetting", 0); SharedPreferences.Editor editor = playerSettings.edit(); editor.putBoolean("NewGame", newGame); editor.putString("PlayerName", playerName); editor.putString("PlayerPassword", playerPassword); editor.putString("PlayerEmail", playerEmail); editor.commit(); } public void SavePlayer(){ SharedPreferences playerSettings = getSharedPreferences("PlayerSetting", 0); SharedPreferences.Editor editor = playerSettings.edit(); editor.putBoolean("NewGame", newGame); editor.putString("PlayerName", playerName); editor.commit(); } @Override public void onResume() { super.onResume(); if(mPlayer != null) { mPlayer.start(); } } @Override public void onStop() { super.onStop(); if(mPlayer != null) { mPlayer.pause(); } } @Override public void onDestroy() { super.onDestroy(); if(mPlayer != null) { mPlayer.stop(); mPlayer.release(); mPlayer = null; } } }
Mon telephone continue de Détruire et recréé mon activitée chaque fois qu'il se verrouille si l'activitée est visible, la première et la deuxième aussi la.
Je ne suis pas du genre a abandonné mais il y a toujours un problème ou il deverait pas y en avoir. J'arrive pas a avancer dans mon projet je ne fait que déboguer. Soit que c'est moi qui comprend mal ou ya un sérieux problème avec eclipse. J'ai meme tout efface et recommencer a 0. Désinstaller reinstaller Eclipse et les SDK c'est pareille.
Merci de m'aider a déchifrer le logCat car je suis vraiment sur le point d'abandonné.
Partager