ANR Absturz :(

  • 10 Antworten
  • Letztes Antwortdatum
ChrisiBoy

ChrisiBoy

Erfahrenes Mitglied
30
Also bei meiner App im google Play store kommt ab und zu der aufhängungsfehler ANR:
Code:
 DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x2aad2248 self=0xcf50
  | sysTid=13463 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1876218976
  at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
  at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
  at java.io.FileOutputStream.(FileOutputStream.java:94)
  at java.io.FileOutputStream.(FileOutputStream.java:66)
  at at.meineapp.ZipDL.unzipEntry(ZipDL.java:-1)
  at at.meineapp.ZipDL.unzip(ZipDL.java:-1)
  at at.meineapp.ViewMaps.onContextItemSelected(ViewDL.java:-1)
  at android.app.Activity.onMenuItemSelected(Activity.java:2209)
  at com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback.onMenuItemSelected(PhoneWindow.java:2839)
  at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:147)
  at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
  at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:137)
  at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:878)
  at android.widget.AdapterView.performItemClick(AdapterView.java:288)
  at android.widget.ListView.performItemClick(ListView.java:3514)
  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1908)
  at android.os.Handler.handleCallback(Handler.java:587)
  at android.os.Handler.dispatchMessage(Handler.java:92)
  at android.os.Looper.loop(Looper.java:123)
  at android.app.ActivityThread.main(ActivityThread.java:3701)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:507)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
  at dalvik.system.NativeStart.main(Native Method)

"Binder Thread #2" prio=5 tid=8 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x2afc4e98 self=0x128eb0
  | sysTid=13470 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=589728
  at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #1" prio=5 tid=7 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x2afc4dd0 self=0x8fd10
  | sysTid=13469 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1578192
  at dalvik.system.NativeStart.run(Native Method)

"Compiler" daemon prio=5 tid=6 VMWAIT
  | group="system" sCount=1 dsCount=0 obj=0x2afc0e90 self=0x287030
  | sysTid=13468 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1008752
  at dalvik.system.NativeStart.run(Native Method)

"JDWP" daemon prio=5 tid=5 VMWAIT
  | group="system" sCount=1 dsCount=0 obj=0x2afc0de0 self=0x181f28
  | sysTid=13467 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1008688
  at dalvik.system.NativeStart.run(Native Method)

"Signal Catcher" daemon prio=5 tid=4 RUNNABLE
  | group="system" sCount=0 dsCount=0 obj=0x2afc0d20 self=0x181df0
  | sysTid=13466 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1169984
  at dalvik.system.NativeStart.run(Native Method)

"GC" daemon prio=5 tid=3 VMWAIT
  | group="system" sCount=1 dsCount=0 obj=0x2afc0c78 self=0x11e058
  | sysTid=13465 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1169392
  at dalvik.system.NativeStart.run(Native Method)

"HeapWorker" daemon prio=5 tid=2 VMWAIT
  | group="system" sCount=1 dsCount=0 obj=0x2afc0bc0 self=0x181310
  | sysTid=13464 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1169328
  at dalvik.system.NativeStart.run(Native Method)
Weiß jemand eine Lösung?

Gesendet von meinem GT-I9100 mit der Android-Hilfe.de App
 
Zuletzt bearbeitet:
Unzip klingt nach etwas, dass länger läuft - und damit in einen AsyncTask gehört...

Gesendet von meinem MB525 mit Tapatalk 2
 
  • Danke
Reaktionen: ChrisiBoy
Also um genauer zu sein Wird eine Datei (~0.8mb) mit einem Asynctask runtergeladen und danach kann man sie auf anfrage auch un-zippen und das soll also auch in einem Asynctask Geschehen?

Sent from my GT-I9100 using Android-Hilfe.de App
 
Alle längeren prozeduren wie auch das "unzippen" gehören in einen Thread oder Async Task.
=> Ja unbedingt!
 
  • Danke
Reaktionen: ChrisiBoy und GENiALi
Erdal.Cam schrieb:
Alle längeren prozeduren wie auch das "unzippen" gehören in einen Thread oder Async Task.
=> Ja unbedingt!

Also ich mache es momentan auf diesen weg:
Code:
 public static void unzip(File src, File dest){
maps = new File(dest, "/");

maps.mkdirs();

try {
ZipFile zipfile = new ZipFile(src);
for (Enumeration<? extends ZipEntry> e = zipfile.entries(); e.hasMoreElements();) {
ZipEntry entry = (ZipEntry) e.nextElement();
unzipEntry(zipfile, entry, dest);
}
zipfile.close();
} catch (Exception e) {

}
}

private static void unzipEntry(ZipFile zipfile, ZipEntry entry, File outputDir)
throws IOException {



if (entry.isDirectory()) {
return;
}


File outputFile;
if(entry.getName().contains("numbers.dat")){
outputFile = new File(maps, "numbers.dat");
}else if(entry.getName().contains("data.dat")){
outputFile = new File(maps, "data.dat");
}else if(entry.getName().contains("level.dat")){
outputFile = new File(maps, "level.dat");
}else{
return;
}

/*
if(outputFile.exists()){
outputFile.delete();
}
if (!outputFile.getParentFile().exists()) {
ZipUtils.createDir(outputFile.getParentFile());
}*/

BufferedInputStream inputStream = new BufferedInputStream(
zipfile.getInputStream(entry));
FileOutputStream outputStream = 
new FileOutputStream(outputFile);

try {
copy(inputStream, outputStream);
} finally {

outputStream.close();
inputStream.close();
}
}

public static void copy(InputStream in, OutputStream out)
throws IOException {
if (in == null) {

}
if (out == null) {

}

// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
//out.close();
}
}

Gesendet von meinem GT-I9100 mit der Android-Hilfe.de App
 
So wie ich das sehe muss du doch nur den Aufruf "unzip(File src, File dest);"
in einen Thread/Async Task verfrachten...
Wo ist jetzt deine Frage?
 
Da ich blutiger Anfänger bin habe ich leider keine Ahnung wie ich den Aufruf in einen thread verfrachte

Gesendet von meinem GT-I9100 mit der Android-Hilfe.de App
 
naja ganz trivial wärs mit

new Thread() {
public void run() {
aufruf();
}
}.start();


besser wärs mit einem AsyncTask - da gibts viele infos im Netz dazu
 
ChrisiBoy schrieb:
Da ich blutiger Anfänger bin habe ich leider keine Ahnung wie ich den Aufruf in einen thread verfrachte

Gesendet von meinem GT-I9100 mit der Android-Hilfe.de App

Weiter oben hast du doch schon geschrieben, dass du den Download mit einem AsyncTask machst - wo genau ist jetzt dein Problem?

Gesendet von meinem MB525 mit Tapatalk 2
 
Das ich das unzippen in einem Asynctask/Thread machen will

Gesendet von meinem GT-I9100 mit der Android-Hilfe.de App
 
swordi schrieb:
naja ganz trivial wärs mit

new Thread() {
public void run() {
aufruf();
}
}.start();


besser wärs mit einem AsyncTask - da gibts viele infos im Netz dazu

Was ist eig. Der Unterschied zwischen einem Asynctask und einem Thread?

Gesendet von meinem GT-I9100 mit der Android-Hilfe.de App
 
Zurück
Oben Unten