Android OS Forum banner

1 - 16 of 16 Posts

·
Developer
Joined
·
84 Posts
Discussion Starter · #1 ·
Starting this thread for quick posts on things we have learned from experience.

I'd prefer if posts remain short and scannable.

I'll start with this:

If you are requesting a result from an activity, make sure that activity is not set as singleinstance for launchmode or you will spend hours trying to figure out why your activity never returns a result.

The result will be canceled automatically if you specify android:launchmode="singleinstance" for said activity in your manifest.
 

·
Developer
Joined
·
84 Posts
Discussion Starter · #2 ·
Quick Tip:

If you're working in Eclipse with the SDK plugin... and things are lagging or you're just sick and tired of Eclipse warning you while you are trying to write (or are halfway through writing a line of code and Eclipse is bugging you about it)... change the build process to manual so Eclipse will stfu until you're ready for it to build/examine your code:

From the project menu, uncheck the "Build Automatically" item. You will see a new option appear on the main toolbar (just below the menus), it is a page with a "010" on it. You can then click that to build your project at your leisure.
 

·
Developer
Joined
·
84 Posts
Discussion Starter · #3 ·
If you are playing around with, say, an xml file... and save a few files to keep your work... then copy one of the saved files over to your main xml where the dirty work is and see A) a bunch of yellow underlines under all of your xml text, or
a lack of syntax highlighting altogether... close and re-open Eclipse to get rid of that crap.
 

·
Developer
Joined
·
84 Posts
Discussion Starter · #4 ·
Again, in Eclipse: If you change a bunch of your properties and have goofy shit going on with your manifest, right click on your project in package explorer and select Adroid Tools > Fix Project Properties.
 

·
Developer
Joined
·
84 Posts
Discussion Starter · #5 ·
Another Eclipse Tip: To change the build target SDK for your application, right click on the project in the package explorer, click properties, then select the android option. From there you can change your build target.
 

·
Developer
Joined
·
84 Posts
Discussion Starter · #6 ·
Again... Eclipse: Say you follow my advice from above, switch your build target to 1.6 from 2.1, then build (assuming you choose to build at your convenience)... now say you get errors (typical red x) with the 1.6 build because you have used APIs beyond that SDK version, say further that you decide "Eff it, I didn't want to support 1.6 anyway" and change your build target back to 2.1, then hit the build button... but you are still getting the same errors you were getting before...

Eclipse isn't re-building your project because no files have changed... open anything ( .xml, .java ) etc and put a space somewhere... then re-build... the errors will go away as Eclipse builds again.
 

·
Developer
Joined
·
84 Posts
Discussion Starter · #7 ·
Again, Eclipse: Say you want to create a new android project, so you choose File > New > Android Project... fill in the pertinent info, then create your project... but in package explorer you see an error (red X) next to your project name so you hit the build button... but the red X still remains.

The solution is the same as above... open a file, and add a space... as a for instance:

I created an app called Test, with "Project Name" Test, App Name: Test, Package Name: com.dustin.test and asked it to create an activity called Main

I would navigate (in package explorer) to src > com.dustin.test > Main.java and add a space to that file, then save, then build... by adding the space it forces Eclipse to rebuild the entire app.

You can always remove the space next time you build.
 

·
Developer
Joined
·
84 Posts
Discussion Starter · #8 ·
One last tip for the night:

In Eclipse: if you have "Automatic Build" turned off (see my recommendation above), and modify one of your resources files (an xml that contains values resources such as strings.xml, arrays, colors etc... it's nice to hit the build key after modding those before you try to include them in your java code so you have code completion (Eclipse won't complete your R.whatever unless you build after adding them).
 

·
Developer
Joined
·
84 Posts
Discussion Starter · #11 ·
Thanks guys... Hoping others will share their tips as well!
 

·
Developer
Joined
·
20 Posts
Excellent Eclipse tips!!!

anyone know how to keep the avd from losing connection to eclipse all the time? (debugger not found or something like that is the error message, it cant reconnect and fails) this happens even more when ddms is open. still trying to find a solution, that would be a great tip!
 

·
Developer
Joined
·
84 Posts
Discussion Starter · #13 ·
bandroidx said:
Excellent Eclipse tips!!!

anyone know how to keep the avd from losing connection to eclipse all the time? (debugger not found or something like that is the error message, it cant reconnect and fails) this happens even more when ddms is open. still trying to find a solution, that would be a great tip!
I usually just keep logcat output in a terminal window... since as you said Eclipse can be quirky.

I would like to see a solution too.
 

·
Premium Member
Joined
·
768 Posts
Having issues with R stuff in Eclipse, its just not working? check that Eclipse hasn't put in unnecessary imports for android.R when you hit Ctrl+O (Organize Imports). Then clean the project, and if needed, restart Eclipse.

I get this often, these steps usually fix the issue. Enjoy!

Sent from my Nexus S using RootzWiki Forums
 

·
Premium Member
Joined
·
1,768 Posts
personally I hate Eclipse

PROTIP:
gedit is the way to go syntax highlighting is superb

@Jonathon Grigg try compiling against the android source code

Code:
<br />
#set the top of the build folder<br />
export TOP=/path/to/source/code<br />
<br />
#tell it to compile against android source<br />
source $TOP/build/envsetup.sh<br />
<br />
#compile your app<br />
mm<br />
 
1 - 16 of 16 Posts
Top