UPDATE 3: It all seems to have been caused by updating OTA to KitKat 4.4. The power to stop and clear data from a GMail application fixed the problem. Not very convenient OTA update result.
UPDATE 2: The crash is only related to the new Gmail file processing in Android 4.4 KitKat. When you add any type of file as an attachment other than an image or video, GMail crashes when you send an email message. Why remove the functionality of your application?
Does anyone know where to report GMail errors? I can reproduce the crashes simply using GMail (not my own code):
Create New Email
Add attachment (only 2 options: "Attach image" or "Attach video")
Choose one of them.
Select a file browser (e.g. ES Explorer) to select zip / apk / ... (or another file that is not an image / video)
Gmail failed to send mail.
UPDATE:
The crash happens on my serving Nexus 4 (OTA) KitKat. However, the same code works on my Samsung Galaxy S2, running CM10.2 at night (Jelly Bean), works great. It also works on the Samsung Galaxy Tab 2 4.0.4 tab.
Is GMail broken on KitKat?
Nexus 4 has GMail version 4.6.1 (920375) Galaxy S2 has GMail version 4.6 (836823)
Original question (resolved, see update 3):
I have the following code in an android application:
Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_EMAIL, new String[]{" xxx@gmail.com "}); email.putExtra(Intent.EXTRA_SUBJECT, "MetroNavigator data"); email.setType("application/zip"); email.putExtra(Intent.EXTRA_TEXT, "This email contains tracking data generated by the MetroNavigator app."); email.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath())); startActivity(Intent.createChooser(email, "Choose a mail client to send the data:"));
This seems great, because the zip file was added to the letter correctly (you can see that since GMail mentions the size of the file, which is not there if the file path is incorrect).
Screenshot: (I do not have 10 benchmarks, but cannot insert) http://i.imgur.com/UkMQZLG.png
However, when sending mail, a GMail failure leads to the following output:
11-23 12:22:38.451 31900-32089/? E/AndroidRuntime﹕ FATAL EXCEPTION: SyncAdapterThread-1 Process: com.google.android.gm, PID: 31900 java.lang.NullPointerException at android.content.ContentResolver.openInputStream(ContentResolver.java:613) at com.google.android.gm.provider.MailEngine$PublicMailStore.getInputStreamForUploadedAttachment(MailEngine.java:5591) at com.google.android.gm.provider.MailSync$AttachmentPartSource.newInputStream(MailSync.java:3968) at com.google.android.gm.provider.MailSync$AttachmentPartSource.<init>(MailSync.java:3941) at com.google.android.gm.provider.MailSync$ProtoOperationSink.messageSavedOrSent(MailSync.java:3708) at com.google.android.gm.provider.Operations.provideNormalOperations(Operations.java:586) at com.google.android.gm.provider.MailEngine$PublicMailStore.provideOperations(MailEngine.java:5290) at com.google.android.gm.provider.MailSync.nextSyncRequest(MailSync.java:853) at com.google.android.gm.provider.MailEngine.runSyncLoop(MailEngine.java:2217) at com.google.android.gm.provider.MailEngine.sync(MailEngine.java:2014) at com.google.android.gm.provider.MailEngine.performBackgroundSync(MailEngine.java:1936) at com.google.android.gm.provider.MailSyncAdapterService$SyncAdapterImpl.onPerformLoggedSync(MailSyncAdapterService.java:58) at com.google.android.common.LoggingThreadedSyncAdapter.onPerformSync(LoggingThreadedSyncAdapter.java:33) at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259)
I read other questions related to attachments that you cannot download an attachment from internal storage, but I use
Environment.getExternalStorageDirectory().toString();
as the basis for each path and I included
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
in my manifest. Also this is a GMail app that crashes, not mine. Any ideas? Is this a bug in GMail?
I would have liked some input.
Thanks in advance,
Thomas