Search code examples
androidfileattachmentbug-reportinginstabug

Instabug not sending attachements


I changed to instabug v2 from v1 recently and I do not get my attachments anymore. this is how I initialise:

 try {
        instabug =   new Instabug.Builder(this, "API_KEY")
                .setDebugEnabled(true)
                .setEmailFieldRequired(true)
                .setFloatingButtonOffsetFromTop(400)
                .setShouldShowIntroDialog(true)
                .setColorTheme(IBGColorTheme.IBGColorThemeLight)
                .setCommentFieldRequired(true)
                .setInvocationEvent(IBGInvocationEvent.IBGInvocationEventShake)
                .build();
        instabug.setPrimaryColor(getResources().getColor(R.color.background));
        instabug.setPreSendingRunnable(new Runnable() {
            @Override
            public void run() {
                Log.i("","entered pre sending runnable");
                String[] files = new String[2];
                files[0] = Environment.getExternalStorageDirectory() + "/Passenger/passenger_log.txt";
                files[1] = Environment.getExternalStorageDirectory() + "/Passenger/passenger_log2.txt";
                Compress compress = new Compress(files, Environment.getExternalStorageDirectory() + "/Passenger/log.zip");
                compress.zip(new CrudStateCallback() {
                    @Override
                    public void onResponse(String string) {
                        Log.i("", "ended making the archive");
                    }
                });
            }
        });
        instabug.setFileAttachment(Uri.parse(Environment.getExternalStorageDirectory() + "/Passenger/log.zip"));
    }catch (Exception e){
        Log.e("","error instabug:" + e.getMessage());
        Utils.appendLog("In case instabug crashes asyncTask process, will not crash app",true);
    }

Before, on v1 I had this in the manifest, which is not recognised anymore:

   <service android:name="com.instabug.library.network.UploadCacheService"/>
 <receiver android:name="com.instabug.library.network.InstabugNetworkReceiver">
        <intent-filter>
            <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
        </intent-filter>
    </receiver>

Should I put something instead?


Solution

  • the URI apparently was incorrect. This fixes it:

       File file = new File(Environment.getExternalStorageDirectory() + "/Passenger/log.zip");
            Uri uri = Uri.fromFile(file);
            Log.i("","instabug uri is:" + uri);
            instabug.setFileAttachment(uri);