Autore Topic: [android 2.3.3] come leggere il LOGCAT?  (Letto 922 volte)

Offline heartread

  • Nuovo arrivato
  • *
  • Post: 4
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    lg 550
[android 2.3.3] come leggere il LOGCAT?
« il: 31 Gennaio 2012, 09:53:56 CET »
0
ciao,
sono alle prime armi con lo sviluppo su Android e devo dire che trovo molto ostico interpretare il logcat (forse anche dovuto al fatto che sono stato molto vizianto nelle applicazioni VB.NET ad avere un debugger  veramente efficiente).

Ecco il problema
dalla rete a titolo di esempio ho prelevato un codice per avere delle coordinate in GPS. (i filess manifest  e layout sono stati aggiornati).
nonostante non ho nessun errore o warning da eclipse, sia sul simulatore che sul telefono il codice genera il seguente errore:
The Application MMGGAAA (process test.mg) has stopped unexpectedly. Please try again.


allego LOG CAT e codice Java .



Codice: [Seleziona]
01-31 09:44:53.977: D/dalvikvm(348): GC_EXPLICIT freed 82K, 54% free 2587K/5575K, external 2186K/2730K, paused 55ms
01-31 09:44:59.087: D/AndroidRuntime(408): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
01-31 09:44:59.087: D/AndroidRuntime(408): CheckJNI is ON
01-31 09:44:59.817: D/AndroidRuntime(408): Calling main entry com.android.commands.pm.Pm
01-31 09:44:59.847: D/AndroidRuntime(408): Shutting down VM
01-31 09:44:59.857: D/dalvikvm(408): GC_CONCURRENT freed 100K, 72% free 291K/1024K, external 0K/0K, paused 2ms+1ms
01-31 09:44:59.857: D/dalvikvm(408): Debugger has detached; object registry had 1 entries
01-31 09:44:59.887: I/AndroidRuntime(408): NOTE: attach of thread 'Binder Thread #3' failed
01-31 09:44:59.917: D/dalvikvm(253): GC_EXPLICIT freed 3K, 54% free 2544K/5511K, external 1625K/2137K, paused 992ms
01-31 09:45:00.528: D/AndroidRuntime(419): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
01-31 09:45:00.528: D/AndroidRuntime(419): CheckJNI is ON
01-31 09:45:01.257: D/AndroidRuntime(419): Calling main entry com.android.commands.pm.Pm
01-31 09:45:01.428: D/dalvikvm(253): GC_EXPLICIT freed 4K, 54% free 2544K/5511K, external 1625K/2137K, paused 49ms
01-31 09:45:01.439: W/ActivityManager(69): No content provider found for:
01-31 09:45:01.448: W/ActivityManager(69): No content provider found for:
01-31 09:45:01.468: D/PackageParser(69): Scanning package: /data/app/vmdl339063796.tmp
01-31 09:45:01.548: D/PackageManager(69): Scanning package test.mg
01-31 09:45:01.559: I/PackageManager(69): Unpacking native libraries for /data/app/test.mg-1.apk
01-31 09:45:01.578: D/installd(35): DexInv: --- BEGIN '/data/app/test.mg-1.apk' ---
01-31 09:45:01.758: D/dalvikvm(428): DexOpt: load 37ms, verify+opt 52ms
01-31 09:45:01.768: D/installd(35): DexInv: --- END '/data/app/test.mg-1.apk' (success) ---
01-31 09:45:01.768: D/PackageManager(69):   Activities: test.mg.MgActivity
01-31 09:45:01.788: I/ActivityManager(69): Force stopping package test.mg uid=10035
01-31 09:45:01.948: I/installd(35): move /data/dalvik-cache/data@app@test.mg-1.apk@classes.dex -> /data/dalvik-cache/data@app@test.mg-1.apk@classes.dex
01-31 09:45:01.948: D/PackageManager(69): New package installed in /data/app/test.mg-1.apk
01-31 09:45:02.207: W/RecognitionManagerService(69): no available voice recognition services found
01-31 09:45:02.518: D/dalvikvm(69): GC_EXPLICIT freed 623K, 48% free 4328K/8263K, external 3511K/3903K, paused 89ms
01-31 09:45:02.528: D/AndroidRuntime(419): Shutting down VM
01-31 09:45:02.558: D/dalvikvm(419): GC_CONCURRENT freed 101K, 72% free 295K/1024K, external 0K/0K, paused 2ms+8ms
01-31 09:45:02.568: I/AndroidRuntime(419): NOTE: attach of thread 'Binder Thread #3' failed
01-31 09:45:02.568: D/jdwp(419): Got wake-up signal, bailing out of select
01-31 09:45:02.568: D/dalvikvm(419): Debugger has detached; object registry had 1 entries
01-31 09:45:03.208: D/AndroidRuntime(433): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
01-31 09:45:03.208: D/AndroidRuntime(433): CheckJNI is ON
01-31 09:45:04.138: D/AndroidRuntime(433): Calling main entry com.android.commands.am.Am
01-31 09:45:04.179: I/ActivityManager(69): Force stopping package test.mg uid=10035
01-31 09:45:04.179: I/ActivityManager(69): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=test.mg/.MgActivity } from pid 433
01-31 09:45:04.378: D/AndroidRuntime(433): Shutting down VM
01-31 09:45:04.428: D/dalvikvm(433): GC_CONCURRENT freed 102K, 69% free 322K/1024K, external 0K/0K, paused 2ms+2ms
01-31 09:45:04.438: I/AndroidRuntime(433): NOTE: attach of thread 'Binder Thread #3' failed
01-31 09:45:04.478: I/ActivityManager(69): Start proc test.mg for activity test.mg/.MgActivity: pid=441 uid=10035 gids={}
01-31 09:45:04.520: D/jdwp(433): Got wake-up signal, bailing out of select
01-31 09:45:04.520: D/dalvikvm(433): Debugger has detached; object registry had 1 entries
01-31 09:45:04.837: D/dalvikvm(33): GC_EXPLICIT freed 10K, 53% free 2538K/5379K, external 1625K/2137K, paused 339ms
01-31 09:45:04.977: D/dalvikvm(33): GC_EXPLICIT freed <1K, 53% free 2538K/5379K, external 1625K/2137K, paused 144ms
01-31 09:45:05.189: D/dalvikvm(33): GC_EXPLICIT freed <1K, 53% free 2538K/5379K, external 1625K/2137K, paused 198ms
01-31 09:45:05.237: W/ActivityThread(441): Application test.mg is waiting for the debugger on port 8100...
01-31 09:45:05.257: I/System.out(441): Sending WAIT chunk
01-31 09:45:05.267: I/dalvikvm(441): Debugger is active
01-31 09:45:05.467: I/System.out(441): Debugger has connected
01-31 09:45:05.467: I/System.out(441): waiting for debugger to settle...
01-31 09:45:05.667: I/System.out(441): waiting for debugger to settle...
01-31 09:45:05.890: I/System.out(441): waiting for debugger to settle...
01-31 09:45:06.087: I/System.out(441): waiting for debugger to settle...
01-31 09:45:06.288: I/System.out(441): waiting for debugger to settle...
01-31 09:45:06.497: I/System.out(441): waiting for debugger to settle...
01-31 09:45:06.697: I/System.out(441): waiting for debugger to settle...
01-31 09:45:06.897: I/System.out(441): waiting for debugger to settle...
01-31 09:45:07.099: I/System.out(441): waiting for debugger to settle...
01-31 09:45:07.298: I/System.out(441): waiting for debugger to settle...
01-31 09:45:07.507: I/System.out(441): debugger has settled (1476)
01-31 09:45:08.538: I/inizio(441): 1
01-31 09:45:08.547: I/inizio(441): 2
01-31 09:45:08.577: I/inizio(441): 5
01-31 09:45:14.272: W/ActivityManager(69): Launch timeout has expired, giving up wake lock!
01-31 09:45:15.081: W/ActivityManager(69): Activity idle timeout for HistoryRecord{40540878 test.mg/.MgActivity}
01-31 09:45:20.158: D/dalvikvm(314): GC_EXPLICIT freed 3K, 54% free 2537K/5511K, external 1625K/2137K, paused 42ms


Codice (Java): [Seleziona]
package test.mg;

import android.app.Activity;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class MgActivity extends Activity implements LocationListener {
        private LocationManager myManager;
        private TextView tv;

        /**********************************************************************
         * Activity overrides below
         **********************************************************************/

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                Log.i("inizio", "1");
                // get a handle to our TextView so we can write to it later
                tv = (TextView) findViewById(R.id.editText1);
                Log.i("inizio", "2");
                // set up the LocationManager
                myManager = (LocationManager) getSystemService(LOCATION_SERVICE);
                Log.i("inizio", "5");
        }

        @Override
        protected void onDestroy() {
                stopListening();
                super.onDestroy();
        }

        @Override
        protected void onPause() {
                stopListening();
                super.onPause();
        }

        @Override
        protected void onResume() {
                startListening();
                super.onResume();
        }

        /**********************************************************************
         * helpers for starting/stopping monitoring of GPS changes below
         **********************************************************************/

        private void startListening() {
                myManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                                this);
                Log.i("inizio", "4");
        }

        private void stopListening() {
                if (myManager != null)
                        myManager.removeUpdates(this);
        }

        /**********************************************************************
         * LocationListener overrides below
         **********************************************************************/

        @Override
        public void onLocationChanged(Location location) {
                // we got new location info. lets display it in the textview
                String s = "";
                s += "Time: " + location.getTime() + "\n";
                s += "\tLatitude:  " + location.getLatitude() + "\n";
                s += "\tLongitude: " + location.getLongitude() + "\n";
                s += "\tAccuracy:  " + location.getAccuracy() + "\n";
                Log.i("inizio", "3");
                tv.setText(s);
        }

        @Override
        public void onProviderDisabled(String provider) {
        }

        @Override
        public void onProviderEnabled(String provider) {
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
        }
}

Offline bradipao

  • Moderatore globale
  • Utente storico
  • *****
  • Post: 4043
  • keep it simple
  • Respect: +567
    • Github
    • Google+
    • bradipao
    • Mostra profilo
  • Dispositivo Android:
    Nexus 5
  • Play Store ID:
    Bradipao
  • Sistema operativo:
    W7
Re:[android 2.3.3] come leggere il LOGCAT?
« Risposta #1 il: 31 Gennaio 2012, 10:12:38 CET »
0
Fino al punto 5 ci arriva... ti appare niente sullo schermo o crasha senza che appaia niente?

Altra domanda: hai messo i permessi per il servizio LOCATION nel manifest?
NON rispondo a domande nei messaggi privati
Bradipao @ Play Store

Offline Giovanni D'Addabbo

  • Utente normale
  • ***
  • Post: 163
  • Respect: +8
    • Google+
    • giovannid
    • giovanni.daddabbo
    • magoscuro
    • Mostra profilo
    • Rhubbit.it - Sviluppo app Android/iOs
  • Dispositivo Android:
    Nexus 5
  • Play Store ID:
    Rhubbit srl
  • Sistema operativo:
    Windows/Mac/Linux
R: [android 2.3.3] come leggere il LOGCAT?
« Risposta #2 il: 31 Gennaio 2012, 16:23:46 CET »
0
Altra domanda ...hai provato il debugger di eclipse?

Inviato dal mio GT-I9100 usando Tapatalk

Offline heartread

  • Nuovo arrivato
  • *
  • Post: 4
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    lg 550
Re:[android 2.3.3] come leggere il LOGCAT?
« Risposta #3 il: 31 Gennaio 2012, 19:00:27 CET »
0
nel mio file manifest ho inserito anche qualche permesso in piu

Codice (XML): [Seleziona]
 <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_GPS" />

l'applicazione parte,    evidenzia un messaggio di errore  e rimane l'activity bloccata.

non so cosa tu intendi come debug di eclipse.  forse lo uso senza saperlo  (ddms, adc) e visto la mia poca conoscenza di questa filosofia di debug, non so come approcciarla in modo costruttivo.

Esiste una guida al debug ?
per me capire come ottenere un buon debug è la base di partenza.

grazie in anticipo