Community
http://developer.android.com/resources/community-groups.html
Android mail list: android-developers@googlegroups.com
View topics in mail list:
- http://groups.google.com/group/android-developers/topics
Popular Forums:
- Android Development Community | Android Tutorials
http://www.anddev.org/
- xda-developers
http://forum.xda-developers.com/
- Development
- [Issue] Application crush when return from predefined interface
[Solution 1] You may forgot to call the method of predefined super class
i.e.: In your Activity, if you override onDestroy as following:
class YourActivity extends Activity
{
protected void onDestroy()
{
}
}
when the activity is destroyed, application will crash, in order to resolve this issue, you must modify the code snip to:
class YourActivity extends Activity
{
protected void onDestroy()
{
super.onDestroy(); //Call the same method of super class
}
}
- [Issue] Explain view's attributes
android:gravity: Define which direction to align control's contents.
- [Issue] How to get and Set system property
[Solution] Use methods System.getProperty(xxx) and System.setProperty(xxx), following properties can be got and set:
java.vendor.url
java.class.path
user.home
java.class.version
os.version
java.vendor
user.dir
user.timezone
path.separator
os.name
os.arch
line.separator
file.separator
user.name
java.version
java.home
- [Issue] How to get popular directories and their stat
[Sulotion] Call method android.os.Environment, following directories can be received:
a) root directory
b) external storage directory
c) data directory
d) download cache directory
e) external storage state,
Note: USB mass storage path is /sdcard
- [Issue] How to access resource in package in Acrivity
- Get resource value
getResources().getString(resID); //resID looks like R.string.str_id
- Get resource id from name
getResources().getIdentifier("name", "string", getPackageName());
getResources().getIdentifier("name", "drawable", getPackageName());
- [Issue] How to get and set environment variables
[Solution] To get the value of the specified environment variables, just use System.getenv(xxx); But you can't set environment variable in Java code directly, you need to use jni to call C function 'setenv'.
- [Issue] How to know byte order of device
[Solution] Call method ByteOrder.nativeOrder();
- [Issue] How to read files in the directories res/raw
[Sulotion]
Resources res = getResources();
InputStream is = res.openRawResource(R.raw.xxx);
- [Issue] How to display horizontal bar in widget
[Solution] Use a view which background is filled with the specified color.
......
......
android:background="#FF909090" />
......
Comments:
1) A control View with the specified background is shown as a bar
2) The View must be declared within TableLayout
3)
If your want to implement the horizontal bar with left/right edges
fading just like ListView's divider, you only need to set
android:background to "?android:attr/listDivider"
- [Issue] How to change contents of TextView
- Set text view to be editable
TextView textView = findViewById(xxx);
textView.setText(textView.getText(), TextView.BufferType.EDITABLE);
- Change contents
textView.setText(xxx);
textView.append(xxx); - [Issue] Customize View
- Define customized view class as following
package com.test.customized;
import xxxxxx;
class CustomizedTextView
{
private static String HEADER = "(Warning)";
private static String RETURN = "\n";
public TextView(Context context)
{
super(context);
}
public TextView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public TextView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
}
public void append(CharSequence text, int start, int end)
{
super.append(HEADER, 0, HEADERS.length());
super.append(text, start, end);
super.append(RETURN, 0, RETURN.length());
}
}
- Use the customized view as following
xmlns:android=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Hello, Android"/>
- [Issue] How to use multiple Activity
[Solution] Please refer to:
http://blog.csdn.net/Class_Raito/archive/2008/11/27/3390737.aspx - [Issue] How to launch activity
[Solution]
Launch application
1) From shell
usage: am [start|instrument]
am start [-a ] [-d ] [-t ]
[-c [-c ] ...]
[-e [-e ...]
[-n ] [-D] []
am instrument [-e ] [-p ]
[-w]
For example, launch an application whose manifest are:
Command is: #am start -n net.xiashou.android/net.xiashou.android.HelloAndroid
Other usage:
a) Launch browser to open an URI: #am start -a android.intent.action.VIEW -d
b) Call out: #am start -a android.intent.action.CALL -d tel:10086
c) Launch google map to locate TianJing: #am start -a android.intent.action.VIEW
geo:0,0?q=tianjin
2) From on activate:
Use Intent.
For example, launch an activate whose manifest is:
package="koushikdutta.superuser" android:versionCode="1"
android:versionName="1.0.0">
android:label="@string/superuser_permissions_name"
android:description="@string/superuser_permissions_description"
android:protectionLevel="dangerous" />
android:debuggable="true">
android:label="Superuser" android:permission="android.permission.ACCESS_SUPERUSER">
Launch code is:
Intent intent = new Intent("android.intent.action.superuser");
startActivityForResult(intent, SUPERUSER_REQUEST);
- [Issue] How to close current Activity and remove it from Activity
history stack when you switch to other Activity
[Solution] Call
"finish()" in current Activity's methods. - [Issue] How to use class "Cursor"
[Solution] Cursor stores the results of database query, such as
ContentResolver.query(xxxxx), Cursor contains M(Rows) x N (Columns) eluments,
each column has its name and value, we can get them by calling
getColumnName() and getString/getInt()/getLong()/getShort()..... etc
respectively. - [Issue] How to send Http request
[Solution] Use folloing code:
(refer to
http://blog.atrexis.com/index.cfm/2008/6/20/Sending-HTTP-requests-in-Android
http://dev.shufou.com/?p=28
)
URL url = new URL("");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setConnectTimeout(10000);
conn.setRequestMethod(HttpURLConnection.GET);
conn.setRequestProperty("accept", "*/*");
String location = conn.getRequestProperty("location");
int resCode = conn.getResponseCode();
InputStream stream = conn.getInputStream();
- [Issue] Java Network exception
- When establish network connection using socket, SocketException is
throwed, and exception readable string is: "java.net.SocketException:Connection reset".
Solution: add android.permission.INTERNET to application manifest
- Android java.net.SocketException: The connection was reset
Reason: The time out value is too long, try 10 seconds.
- [Issue] How to communicate in between threads
[Solution] Use classes Handler & Runnable & Thread
1) Handler: Provide a type of message process policy, each Handler instance is bound to a single thread and that thread's message queue. A Handler instance just like HWnd of Microsoft Windows, but different from Windows, both Message and the specified object -- Runnable can be send to destination thread's message queue. If Message will be send, Handler must be extended to overload member function handleMessage(Message); If Runnable will be send, Runnable must be extended to overload member function run().
2) Runnable: Just declare a uniform interface.
3) Thread: A Thread is a unit of concurrent execution. Througn Thread, we can avoid performing long-running operations directly in the UI thread — the main thread of an application where the UI is run — or your application may be blocked and become unresponsive
4) Sample:
public class MyActivity extends Activity
{
private Handler m_handler;
private TextView m_textView;
class MyHandler extends Handler
{
public void handleMessage()
{
//Flash UI
m_textView.setText("xxxx");
}
}
class MyThread extends Thread
{
public void run()
{
Message msg = handler.obtainMessage();
msg.what = xxx;
msg.obj = xxx;
msg.sentToTarget();
}
}
public void onDestroy()
{
super.onDestroy();
m_handler = null;
m_textView = null;
}
public void onCreate(xxx)
{
......
m_textView.findViewById(...);
m_handler = new MyHandler();
MyThread thread = new MyThread();
thread.start();
}
}
- [Issue] How to uninstall package programmatically
[Sulotion]
Uri uri = Uri.fromParts("package", strPackageName, null); //strPackageName is package name which will be uninstalled
Intent it = new Intent(Intent.ACTION_DELETE, uri);
startActivity(it);
Notes: must request to use permission "android.permission.DELETE_PACKAGES""
- Kill Process
- [Issue] How to terminate process
[Solution] Use following statement to kill current process:
android.os.Process.killProcess(android.os.Process.myPid());
or
System.exit(-1); - How to know application is restarted (killed and launched again)
You can check in Activity.onCreate
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
final String PREF_FILE = "cfg";
final String PREF_PREV_PID = "prevPid";
SharedPreferences pref = getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE);
if (savedInstanceState == null)
{
pref.edit().putInt(PREF_PREV_PID, android.os.Process.myPid()).commit();
}
else
{
int curPid, prevPid;
curPid = android.os.Process.myPid();
prevPid = pref.getInt(PREF_PREV_PID, 0);
if (prePid == 0 || curPid == prevPid)
{
//Is not killed, maybe activity is restarted after configuration changed
}
else
{
//Restarted after killed, by SIGTERM, SIGKILL, or after crashed
}
}
}
- App is killed with SIGTERM or SIGKILL
When you restart the app from
Program list, the previous top activity will be created and shown, the
parameter of interface onCreate is not null then.
If you want to auto
launch app once it is killed, just define a service, and implement
onStartCommand as following, and start the service when app is launched
with interface 'startService(Intent intent)'.
public int onStartCommand(Intent intent, int flags, int startId)
{
if (intent == null) //intent == null means the service is restarted
after killed, if it is started with startService in your code, intent !=
null
{
//Launch app here
stopSelf();
}
return 1; //If you don't want Android system to restart the app after it is killed, just return 2;
} - xxx
- [Issue] How to execute P/V operation (mutex, synchronize)
[Soluction] Use class ConditionVariable or Semaphore
- Atomic (Thread-safe) programming
- AtomicBoolean
- AtomicInteger
- AtomicLong
- AtomicReference
- AtomicIntegerArray
- AtomicLongArray
- AtomicReferenceArray
- Request to use necessary permission
If necessary permission is not
requested in AndroidManifest.xml, when application is running, it will
abort with messages "Source not found" in DEBUG mode, or abort with
messages "The application xxx has stopped unexpectedly. Please try
again" in RELEASE mode.
- [Issue] How to Get Android package information in Activity
The Android package
information contains all contents defined in AndroidManifest.xml, Such
as versionName, versionCode, activities, services, providers, services,
signatures etc.
PackageInfo pkgInfo =
getPackageManager().getPackageInfo(getPackageName(), flags);//flags is
different for different package information
i.e. get versionName
PackageInfo pkgInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String verName = pkgInfo.versionName;
Please refer to following online document to get more details
- [Issue] How to define language(International) and screen orientation(Portrait/Landscape) dependent resource
[Solution] Please refer to http://code.google.com/intl/zh-CN/android/devel/resources-i18n.html
Language tag: http://code.google.com/apis/adsense/developer/adsense_api_locales.html
- [Issue] Activity gets restarted once screen orientation changed
[Sulution] Add android:configChanges="keyboardHidden|orientation"
to your manifest file, if you don't want Activity to be restarted once other configurations are changed, juse append other proper items to android:configChanges, more details about android:configChanges, please refer to http://developer.android.com/intl/zh-CN/reference/android/R.attr.html#configChanges, then search keywords "configChanges" - [Issue] What is deployed after application is installed
[Solution]
After application is installed,
1) .apk will be copied to /data/app
2) An empty directory with the same name as package name of .apk will be created in /data/data
3) /data/system/packages.xml will be updated
(More details, please refer to Android Package Installation http://blog.csdn.net/loughsky/archive/2008/11/14/3298868.aspx )
- Implment schedule task
Use AlarmManager.
Sample:
mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent i=new Intent(context, OnAlarmReceiver.class);
PendingIntent pi=PendingIntent.getBroadcast(context, 0, i, 0); //or call getService/getActivity for Service/Activity intent
mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), PERIOD, pi);
In this example, I am using setRepeating(). If you want a one-shot alarm, you would just use set(). Be sure to give the time for the alarm to start in the same time base as you use in the initial parameter to set(). In my example above, I am using AlarmManager.ELAPSED_REALTIME_WAKEUP, so my time base is SystemClock.elapsedRealtime().
- Get packages information
Use PackageManager.
Use PackageManager.getPackageManager to get package manager instance.
The installation file name is PackageManager.getPackageManager.applicationInfo.sourceDir
- List all media files
i.e.:
Uri[] uriMedia = {
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
MediaStore.Images.Media.INTERNAL_CONTENT_URI,
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
MediaStore.Audio.Media.INTERNAL_CONTENT_URI,
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
MediaStore.Video.Media.INTERNAL_CONTENT_URI
};
for (int i = 0; i < uriMedia.length; i++)
{
Cursor cur = resolver.query (uriMedia[i], null, null, null, null);
while (cur.moveToNext())
{
String strFileName = cur.getString(cur.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA));
//All supported cursor columns are MediaStore.MediaColumns, MediaStore.MediaColumns, MediaStore.Audio.AudioColumns, MediaStore.Video.ViceoColumns, MediaStore.Images.ImagesColumns
}
}
Sample:
- Add scroll bar
Add ScrollView out of target view, i.e
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
android:id="@+id/headertable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1"
android:collapseColumns="2"/>
android:layout_width="fill_parent"
android:layout_height="wrap_content">
>
Issue: if scroll bar overwrap contents within the scrollview, you can add android:scrollbarStype="insideInset" to ScrollView, i.e.
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbarStype="insideInset"
>
or set dynamic in source code as:
findViewById(R.id.scroll_view_id).setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
- Can't get phone number use TelephonyManger
- Verify proper permissions is declared in manifest file
- Check whether getLine1Number() returns null ?
- Verify the setting application (go to Settings > About phone > Status > (My) phone number). You should be able to see your phone number.
- In cases where you have the radio switched off you cannot read the
phone number from your SIM card or the SIM card is not available at all, for example, the phone network is switch to Airplane mode.
- ...
- Get subscriber id
- Verify proper permissions is declared in manifest file
- The phone network is available.
- You can access the website and input the IMSI to verify:
- ...
- How to know which table is created in datebase, and what columns the table contains.
i.e. Get to know table details in /data/data/com.google.providers.telephony/databases/mmssms.db.
Solution:
1, adb pull /data/data/com.google.providers.telephony/databases/mmssms.db .
2, strings mmssms.db > tmp.txt
3, vi tmp.txt, and search 'CREATE TABLE'
- Backward Compatibility for Application
http://developer.android.com/resources/articles/backward-compatibility.html
- Input Methods
http://developer.android.com/resources/articles/creating-input-method.html
- Relayout UI
- Change Layout Attributes
RelativeLayout layout = (RelativeLayout) findViewById(R.id.xxxx);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)layout.gerLayoutParams();
params.addRules(xxx, xxx);
layout.addLayoutParams(params);
layout.requestLayout(); - Dynamic Add/Remove SubViews
Layout layout = (Layout)findViewById(xxxx);
layout.removeAllViews(); or
layout.removeViewAt(xxx); or
layout.removeView(xxx);
....
layout.addView(xxx); or
layout.addViewAt(xxx);
================================
or View view = fineViewById(xxxx);
view.setVisible(View.GONE);
The layout will relayout and align automatically.
- Change button's image
call setCompondDrawablesWithIntrinsicBounds
- The title of TableHost can't be shown (it background's color is the same as foreground's)
It may caused by sdb version. that is you build application with higher Android SDK, but in AndroidManifest file, you specified lower SDK version using
- Launch an Activity from background to foreground
you can't switch your activity from background to foreground in Activity, you must do this in Service.
1st Way:
Intent intent = new Intent(parentIntnet, target.class);
intent.setAction(xxxx);
intent.addCategory(xxx);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
startActivity(intent);
2nd way:
Intent intent = new Intent(this, TergatActivity.class)
intent.setFlags(Intnet.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(intent); //Must set flags Intnet.FLAG_ACTIVITY_NEW_TASK to intent;
- Activity is restarted automatically
In following situations, Activity will be restarted automatically.
- Memory is low
Override onLowMemory method to see if it is called before Activity is restarted. If this method is called, your application uses too much memory.
In such situation, you must optimize your application to decrease low memory usage.
- Configuration is changed
- in AndroidManifest.xml, add android:configChanges attributes in Activity elements, and set it to all available value (About available value, please refer to http://developer.android.com/guide/topics/manifest/activity-element.html ), ie. android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
- Override method onConfigurationChanged(Configuration newConfig) to see if it is called. If it is called, it is configuration changing to cause your Activity restarted.
In such situlation, you can set proper android:configChanges (First, add all available value to android:configChanges, then decrease it from android:configChanges one by one) to prevent your Activity to be restarted.
- How to use Android internal package
such as com.android.internal.*
[Solution]
Get source code of internal package and depended packages, then add the source code to you project.
[ie] To use internal class ITelephony
- Prepare ITelephony.aidl
Download iTelephony.aidl from
then
add that file to src/com/android/internal/telephony/ of your project - Write code
import com.android.internal.telephony.ITelephony;
......
ITelephony telephonyService = ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONE_SERVICE);
//Call method of ITelephony
telephonyService.endCall();
- xxx
- When to start an activity via method startActivityForResult, don't set flag FLAG_ACTIVITY_NEW_TASK
- DateFormat
DateFormat can be found in packages java.text and android.text.format. If you want to refer to the user configured date format, you need to use the class DateFormat in the package android.text.format by invoking the metohd getDateFormat(context);
- Get locale
Use Locale class
- The ways to monitor process is created
- Use i-notifi (FileObserver) to monitor /proc/loadavg
- Run logcat and parse output log records
try
{
String line;
Process p = Runtime.getRuntime().exec("logcat");
BufferedReader input = new BufferedReader (new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) //If no data is available,
this function will hang until the process is terminated.
{
System.out.println(line);
}
input.close();
}
catch (Exception err)
{
err.printStackTrace();
}
- xxx
- The difference between padding and margin
The padding space is belong of the View, while the space of margin is not. Padding means set extra space from contensts, while margin means add extra space from UI component.
- Color
Many color is pre-defined, such as Color.RED, Color.GREEN, Color.BLUE etc.
- How to process un-catched exception yourself
Refer to http://blogold.chinaunix.net/u/9577/showart_2323574.html
- ...
- Debug
- adb
- Open shell of mobile device from host
Run "adb shell" on terminal on your host computer which is connected to your mobile device.
- Get system log
Run "adb logcat" on terminal on your host computer which is connected to your mobile device, then system logs generated on mobile device sill display on the terminal.
- ,,,
- Debug on device
- Set build mode to "Debug" on Eclipse before build
- Select the checkbox "Settings->Applications->Unknown sources" on mobile device
- Select the checkbox "Settings->Applications->Development->USB debugging" on mobile device
- Set USB Mode
- Drag status bar to open prompt
- Press USB Connection to select mode
- StrictMode
StrictMode is a developer tool which detects things: - Detect when an
Closeable
or other
object with a explict termination method is finalized
without having been closed. - Detect when an
SQLiteCursor
or other
SQLite object is finalized without having been closed. - Enable detection of disk reads.
- Enable detection of disk writes.
- Enable detection of network operations.
- ......
- [Issue] How to list all GUI objects
[Solution]
Make sure you have a dev device/emulator (if you see "1", you're out of luck):
$ adb shell getprop ro.secure
0
Start the server:
$ adb shell service call window 1 i32 4939
You should see the following result (the "1" means the server is running):
Result: Parcel(00000000 00000001 '........')
Install the port forwarding:
$ adb forward tcp:4939 tcp:4939
Connect to the server:
$ telnet localhost 4939
Now, you can use one of two commands (type enter after each command):
- LIST will show the list of windows:
LIST
43514758 com.android.launcher/com.android.launcher.Launcher
4359e4d0 TrackingView
435b00a0 StatusBarExpanded
43463710 StatusBar
43484c58 Keyguard
DONE.
- DUMP will show the views and their properties for a given window.
For instance, DUMP 43514758 will show the views contained in the
window com.android.launcher/com.android.launcher.Launcher. You can
also use DUMP -1 or DUMP ffffffff to dump the foreground window. I
recommend that version. The dump may take a while go be generated and
it looks like this:
DUMP -1
com.android.internal.policy.impl.KeyguardViewManager$KeyguardViewHost@434d8220
getDescendantFocusability()=24,FOCUS_BEFORE_DESCENDANTS
getPersistentDrawingCache()=9,SCROLLING
isAlwaysDrawnWithCacheEnabled()=4,true
isAnimationCacheEnabled()=4,true
isChildrenDrawnWithCacheEnabled()=5,false mMinWidth=1,0 mMinHeight=1,0
mMeasuredWidth=3,320 mMeasuredHeight=3,455 mPaddingBottom=1,0
mPaddingLeft=1,0 mPaddingRight=1,0 mPaddingTop=1,0 mLeft=1,0
mID=5,NO_ID mPrivateFlags=4,3248 mRight=3,320 mScrollX=1,0
mScrollY=1,0 mBottom=3,455 mTop=1,0 mUserPaddingBottom=1,0
mUserPaddingRight=1,0 mViewFlags=9,402653312 getBaseline()=2,-1
getHeight()=3,455 layout_height=11,FILL_PARENT
layout_width=11,FILL_PARENT getTag()=4,null getVisibility()=7,VISIBLE
getWidth()=3,320 hasFocus()=4,true isClickable()=5,false
isDrawingCacheEnabled()=5,false isEnabled()=4,true
isFocusable()=5,false isFocusableInTouchMode()=5,false
isFocused()=5,false isHapticFeedbackEnabled()=4,true
isInTouchMode()=4,true isSelected()=5,false
isSoundEffectsEnabled()=4,true willNotCacheDrawing()=5,false
willNotDraw()=4,true
...
DONE.
The format is simple. Each View is defined on a line of text which
ends with \n. The indent at the beginning of the line indicates the
depth of the child in the hierarchy. For instance, no indent == root,
1 space == child of the root, 2 spaces == child of a child of the
root, etc.
className@id followed by a list of properties. A property has the
following format: name=X,data where X is the number of characters in
the data.
- Useful debug tools
- am
Log into the shell of mobile device, then type the following command on shell:
- Run application:
$am start -n /.
- Enter debug mode when run app, just add -D before -n, i.e.
$am start -D -n com.mydomain.test/com.mydomain.test.Main
- Trigger broadcast
am start -a
i.e.:
am start -a android.intent.action.MEDIA_BUTTON
- ...
- [Issue] When you compile your project, following error message is shown
invalid resource directory name
The project cannot be built until build path errors are resolved
[Solution] Invalid file may exist under directory 'res/' and/or its sub-directory. For example, a .txt file exists in the directory res/. Just find the invalid file then remove it.
- When to launch activity, the following error occurs:
Java.lang.SecurityException: permission Denial: Starting intent {flg=xxx cmp=xxxx xxxx} for null (pid=xxx uid=xxx) requires null
[Reason]In eclair, the CropImage activity has no intent-filter associated with it, so it is not exported. This means it cannot be launched by components of other applications. If this is what you are trying to do, then that would explain the failure.
[Solution]
1st way: add android:exported="true" to all activity/service/receiver
2nd way: Add intent-filter to all activity/service/receiver, such as
- ...
- SDKs Issue
- [Issue] SDK 1.5 build error
[2009-07-01 15:13:50 - HelloWorld] no classfiles specified
[2009-07-01 15:13:50 - HelloWorld] Conversion to Dalvik format failed with error 1
[Solution]:
Step 1: Right click->project -> properties -> android -> project build target to set target to SDK 1.5
Step 2: Click Project, then press F5 to reload project files. - [Issue] SDK 2.1 no available targets
[Solution] On Eclipse, click Window -> Android SDK and AVD Manager -> Installed Packages -> Update All, (Or click Window -> Android SDK and AVD Manager -> Available Packages to install necessory sdk first.)
- [Issue] Build error: Project XXX is missing required source folder: 'gen'。
[Solution] Remove R.java, then flash project, and build again.
- [Issue] Create AVD (Android Virtual Devices) for Eclipse
[Solution] click Window -> Android SDK and AVD Manager
-> Ivirtual Devices,
- Error sulition when to install ADT
for eclipse 3.5
Use Window > Preferences > Install/Update > Available Software Sites to add the following
- ......
- NDK Issue
- [Issue] Install NDK error
When install NDK with command:
$ ./build/host-setup.sh
Following error message display:
Detecting host toolchain.
./host-setup.sh: 57: force_32bit_binaries: not found
./host-setup.sh: 58: setup_toolchain: not found
./host-setup.sh: 60: cannot create : Directory nonexistent
Can't create directory for host config file: out/host
[Solution]
$ cd /bin
$ rm sh
$ ln -s bash sh
or change the first line of file ./build/host-setup.sh to "#!/bin/bash"
- Enulator
- [Issue] How to switch screen orientation
[Solution] Ctrl + F11 - ...
- Android Phone Using
- [Issue] While mobile device is connected to host pc, the popup windows can't get response on host pc
[Solution] just kill process f-spot.exe on host pc
- [Issue] How to login into mobile device with telnet
[Solution]
1) Reboot device
2) Open terminal
3) run 'cd /; cd system; cd bin; telnet' on device
4) telnet on remove computer.
- ...
- Build with Eclipse
- [Issue] When build application,following error message display
ERROR:
Application does not specify a
android.test.InstrumentationTestRunner
instrumentation or does not declare
uses-library android.test.runner
[Solution 1]
- Add following code to AndroidManifest.
android:targetPackage="your.package"
android:label="your tests label" />
- Right click project on Project Explorer Panel on Eclipse, then click "Run" > "Run Configurations...", then select "android.test.InstrumentationTestRunner" in Instrumentation TestRunner.
[Solution 2]
When to run application via Eclipse, don't select "xxx JUnit Test" on "Run As" dialog. Or right click project on Project Explorer Panel on Eclipse, then create a new Run/Debug configure file under the categories except "xxx JUint Test"
- ...
- Sign package
- keytool error
[Issue]
c:\3960\glassfish\domains\domain1\config>keytool -genkey -keyalg RSA -keystore a
mkeystore.jks -validity 365 -alias "fam8" -dname "amqa-x2100-01.red.iplanet.com,
ou=identity,o=sun.com,L=santa clara, ST=CA, C=US"
Enter keystore password:
Re-enter new password:
keytool error: java.io.IOException: Incorrect AVA format
[Solution]
dname format is wrong, it shold be
Should be "cn=amqa-x2100-01.red.iplanet.co..........."
- ...
- Sign Application
- Manual of keytool
- How to access Android resource
with android.R.xxx, i.e. android.R.string.xxx, android.R.drawable.xxx
- App stores
- SK Telecom store (TStore)
- Publish & Market
- Run
[Q]Unable to execute dex: wrapper was not properly loaded first
[A]找到Eclipse目录下eclipse.ini文件,将最后两句改为
-Xms128m
-Xmx512m
重启eclipse
然后project->clean一下就OK了 - ...
阅读(16625) | 评论(0) | 转发(0) |