Android Developer Toolkit が 22.6.1 にアップデートできないときの対処
Android SDKマネージャでAndroid SDK Toolsのアップデートを行ったら、
Android Developer Toolkitも更新するように表示されたので、
更新の確認からEclipseプラグインの更新を行おうとしたところ
No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.ddms,22.6.1.v201403111859-1066720
とエラーが発生し、更新できない&Androidプロジェクト全てがビルドエラー状態に。
サーバー側にデータが置かれてないのか、パスのスペルミスなのかは不明ですが、
新規にAndroid Developer Toolkitをインストールさせることで解決できた。
手順
- [ヘルプ]→[新規ソフトウェアのインストール]をクリック
- [追加]ボタンをクリック
- ロケーションに「https://dl-ssl.google.com/android/eclipse/」を入力し[OK]をクリック
- リスト内に表示された項目にチェックを入れ、[次へ]をクリック
- インストールダイアログの指示に従いインストール
AndroidはKitKat以降アプリからSDカードへの書き込み不可に?
2014/01/30 18:30 内容一部修正
KitKat端末では今後アプリからMicro SDカードへの書き込みができくなる模様 | juggly.cn
この記事もうちょっと詳しく調べてみた。
情報元ソース
元ソースはGoogle+でGoogle社のTod Liebeck氏書いた内容
KitKat will make your SD Card completely useless: per the Android API specification, apps can no longer write files to your SD card. And Samsung is following it.
This only applies to dual-storage devices, i.e., devices with a user-writable internal flash storage AND a removable SD card.
From http://source.android.com/devices/tech/storage/index.html:
"The WRITE_EXTERNAL_STORAGE permission must only grant write access to the primary external storage on a device. Apps must not be allowed to write to secondary external storage devices, except in their package-specific directories as allowed by synthesized permissions."
If your device has user-accessible internal flash storage, your SD Card is a "secondary external storage device".
What this means is that with KitKat, applications will no longer be able create, modify, or remove files and folders on your external SD card. As a for-instance, you can no longer use a file manager to copy files from your computer to the SD card over a network. This ability, which has existed since the beginning of Android, has been taken away.
The only stated reason for this removal of functionality is that, "Restricting writes in this way ensures the system can clean up files when applications are uninstalled." I do not pretend to understand this logic. Apps are still allowed to write in arbitrary directories on the primary storage (with the appropriate permission), but are denied the same access to external storage.
Samsung has implemented this feature with their KitKat OTA updates. Note3 users are now complaining that FX File Explorer can no longer write to their external SD cards. There are solutions to this problem for users with root access. Users without root access appear to be screwed.
I'm not quite certain how Google intends for you to place files on your SD card. Perhaps you have to use proprietary Google apps that contain permissions unavailable to the rest of the developer world. Perhaps you're supposed to put everything on the cloud and pay carrier data fees to get it there. Perhaps you're supposed to use some kind of WIRE to attach your WIRELESS device to your computer and have the computer do that work for you.
In my opinion this is a horrible misstep by Google and the Android Open Source Project. Functionality has been removed without reason, to the severe detriment of users and developers alike.
I apologize for not bringing this to everyone's attention when KitKat 4.4 was released, but it was not mentioned in the Android 4.4 changes document: http://developer.android.com/about/versions/android-4.4.html. It's only mentioned in the article on source.android.com. I was only made aware of its existence from user reports as a result of Samsung implementing this change in its KitKat OTA updates.
要約
翻訳ミスがあるかもしれないので注意してね。
KitKatから仕様変更
- アプリはSDカードへの書き込みが完全にできなくなる
- (例)ファイルマネージャーアプリでファイルをSDカードに保存できなくなる
- サムスンはGALAXY Note3のアップデートで追従した
デュアルストレージデバイスが対象
仕様決定理由
- 書込みを制限させ、アプリのアンインストール時に完全にクリーンアップできるから
修正について
完全に書き込みができないのではなく、
SD内のアプリケーションのパッケージ固有ディレクトリ[SD\Android\data\パッケージ名\]
なら保存できるってのが正確な仕様のようです。
The WRITE_EXTERNAL_STORAGE permission must only grant write access to the primary external storage on a device. Apps must not be allowed to write to secondary external storage devices, except in their package-specific directories as allowed by synthesized permissions. Restricting writes in this way ensures the system can clean up files when applications are uninstalled.
External Storage Technical Information | Android Developers
Tod Liebeck氏が
KitKat will make your SD Card completely useless
「KitKatではSDカードが完全に使えなくなる」
って書いていて矛盾してるのは記述ミスなんだろうか?
Androidで外部保存域の空き容量を取得する
Androidで無造作にデータを保存して、
空き容量が無いってことをしないために。
検索でよく引っかかったのが
StatFsクラスのgetAvailableBlocksメソッドを使う以下の例
long freeByteSize = 0; String state = Environment.getExternalStorageState(); //外部保存領域が使用可能かチェック if(Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { //サイズ取得 StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath()); freeByteSize = (long)statFs.getBlockSize() * (long)statFs.getAvailableBlocks(); }
しかしこのソースEclipse(ADT)では、
メソッド getBlockSize() は型 StatFs で使用すべきではありません
メソッド getAvailableBlocks() は型 StatFs で使用すべきではありません
と警告を受けます。
警告は無視しても作れますが気になるので別の方法を調べたところ、
どうやらAndroid API 9からは FileクラスのgetFreeSpaceが使えるらしい。
long freeByteSize = 0; String state = Environment.getExternalStorageState(); //外部保存領域が使用可能かチェック if(Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { //サイズ取得 freeByteSize = Environment.getExternalStorageDirectory().getFreeSpace(); }
これで警告も消えて一安心。
参考
http://stackoverflow.com/questions/8133417/android-get-free-size-of-internal-external-memory
http://www.techdoctranslator.com/android/guide/data-storage
Android4.4(KitKat)でsendBroadcastの強制マウントメディアスキャンを行うと落ちる
Androidアプリ内で作成した画像等のデータファイルをストレージに保存したのにファイルが確認できない。
って時に使うように紹介されている魔法のコード
sendBroadcast( new Intent( Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory() ) );
これAndroid4.4ではエラーを吐きます。
解決策
http://www.taosoftware.co.jp/blog/2013/11/android44kitkattpacketcapture.html