2 Replies Latest reply on Jul 29, 2016 4:36 AM by Klaus Heim

    TC70 logging crash to file with logcat

    Klaus Heim

      We used the following code to log crashes of out app to a logfile:

       

      public class App extends Application {

       

         @Override
         public void onCreate() {

       

      int stringId = this.getApplicationInfo().labelRes;

      String appName = this.getString(stringId);

      final String fn = getExternalCacheDir() + "/" + appName + "-log.txt";

      File filename = new File(fn);

      cmd = "logcat -v time -n 2 -r 1024 -f " + filename.getAbsolutePath();

       

      try {

         p = Runtime.getRuntime().exec(cmd);

      } catch (IOException e) {
         e.printStackTrace();

      }

         }

       

      }
      The logfile is stored in folder /storage/sdcard0/Android/data/com.tup.crashreport/cache. We developed under Android 4.4.3 on TC50 and everything works as designed.
      With TC70 under Android 4.4.2 the logfile is not created (only the folder) and we got the warning "W/ContextImpl: Failed to ensure directory: /storage/sdcard0/Android/data/com.tup.crashreport/cache".
      Why does TC70 fail to store the logfile?
        • Re: TC70 logging crash to file with logcat
          Pietro Francesco Maggi

          Hi Klaus,

          Is your application asking for the permission to write to the external storage?

           

          <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

           

          The original build of the TC70, even if based on Android v4.4.2, does have some special settings that make it handle the external storage in a similar way to Android 4.3 and older versions.

           

          So, even if, on Android KK, the permission is not needed to write in your own package folder (I imagine that your app package is com.tup.crashreport), you may need that setting on the original TC70 BSP.

          My suggestion would be to update your TC70 to a newer build if this can be an option.

           

          Best regards

          ~Pietro