搜尋此網誌

2014年9月20日 星期六

[問題] 解決 Eclipse 新建Android Project 專案時出現 Errors running builder 'Android Resource Manager' on project '專案名稱'


最近入手2014  MacBookPro Retina,在建置android 開發專案時碰到了下列狀況

1.create android project 出現 Errors running builder 'Android Resource Manager' on project '專案名稱'

2.Project has no default.properties file! Edit the project properties to set one.

原因:
我使用的 eclipse 是 Kepler,在安裝Google ADT Plugin發現eclipse Marketplace 有提供於是我就安裝了,悲劇開始

解決方法:
用Install new software方式安裝,開新專案後,該自動產生的檔案都產生了
https://dl-ssl.google.com/android/eclipse/





2012年10月9日 星期二

[問題] 解決 Eclipse 無法抓到 SAMSUNG Android 手機問題

參考文章 http://theunlockr.com/2009/10/06/how-to-set-up-adb-usb-drivers-for-android-devices/

HTC 和 Sony 只要裝各自的軟體 原則上可以讓 Eclipse 抓到手機 (HTC Sync, Sony PC Companion)

ASUS 的 也只要裝官網提供的Drive (先安裝 Akamai 才會下載的了 ASUS_Android_USB_drivers_for_Windows_XXXXXXXX.rar)

但 Samsung 裝自家的 Kies 是無效的,解決方式 裝 PdaNet 照安裝步驟 安裝就可以解決此問題

PdaNet 下載 http://www.junefabrics.com/android/download.php

之前是亂裝網路上抓來的 Drive 有安裝成功,但在換另一台電腦安裝就一直抓不到

LG 目前只有一個同事有手機(P970),目前用PdaNet是抓不到的

2012年7月18日 星期三

[問題] Ignoring InnerClasses attribute for an anonymous inner class

在 eclipse 的 console 出現 Ignoring InnerClasses attribute for an anonymous inner class

此錯誤可能發生在 import 外部 jar 檔時

官方解決方法

To fix this problem, simply delete the debug.keystore file. The default storage location for AVDs is in ~/.android/avd on OS X and Linux, in C:\Documents and Settings\\.android\ on Windows XP, and in C:\Users\\.android\ on Windows Vista.
The next time you build, the build tools will regenerate a new keystore and debug key

也就是刪除在
C:\Documents and Settings\[UserName]\.android 下面的 debug.keystore 檔
(找不到 .android 要看 AVD 裝那個目錄下, 預設是 C:\Documents and Settings\[UserName]\.android)

刪除後在 Run As -> Android Application 執行, 就不會出線現錯誤訊息了

P.S. eclipse 工具列的 Windows -> Preferences -> Android -> Build 裡面有 debug.keystore 的位置




2012年7月13日 星期五

[問題] import jar 檔

我是在 ADT Plugin 20 才發現這個問題的,也許這已經改很久只是我不知道

最近新開的一個 Android Project  因為要 import jar 所以從 Java Bulid Path 中的 Libraries tab 中的

Add JARs , 來 import jar 檔

但在執行過程中會發生 java.lang.NoClassDefFoundError 這個問題

找了很久,一直找不到問題出在那,後來發現新增了一個 "libs"的資料夾

於是我試著把要 import 的 jar 要放到這裡面,結果就可以了正常執行




2011年5月21日 星期六

Android course note 5/15

something can download
http://esl.tl.ntu.edu.tw/AndroidAppProgramming2011/


src: java source

res: resource

R.layout.main: res/layout/main.xml

2011年4月12日 星期二

[Android] 檢查SD卡是否可以讀寫

出自官方的程式碼
//sdcard是否安裝
boolean mExternalStorageAvailable = false;
//sdcar是否可以寫入
boolean mExternalStorageWriteable = false;

String state = Environment.getExternalStorageState();

if(Environment.MEDIA_MOUNTED.equals(state)) {
  //可以讀取和寫入sdcar
  // We can read and write the media
  mExternalStorageAvailable = mExternalStorageWriteable = true;

} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
  //只能讀不能寫
  // We can only read the media
  mExternalStorageAvailable = true;
  mExternalStorageWriteable = false;

} else {
  //其他原因
  // Something else is wrong. It may be one of many other states, but all we need
  // to know is we can neither read nor write
  mExternalStorageAvailable = mExternalStorageWriteable = false;
}

引用來源

[Android] 使用 getResources 讀取 res/ 下的檔案(ex: .jpg or .xml)

把資源檔案放到eclipse android專案的/res/drawable下,那麼就可以在程式中使用getResources,以openRawResource方法讀取在/res/drawable/view_1.jpg,經過R.java編碼後會以R.drawable.view_1來代表view_1.jpg

下面這個範例是,利用InputStream讀取/res/drawable/view_1.jsp,轉存成rename.jsp到/sdcard下面

InputStream is = getResources().openRawResource(R.drawable.view_1);
File myTempFile = new File("/sdcard/", "rename.jpg");
 
FileOutputStream fos = new FileOutputStream(myTempFile);
 
byte buf[] = new byte[1024];
 
do {
 
  int numread = is.read(buf);
  if (numread <= 0) {
    break;
  }
  fos.write(buf, 0, numread);
 
} while (true);

is.close();

標籤