Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Eclipse, Android and Maven: Part 7 - Global properties and settings for Maven

For those who work on projects with multiple developers such as open source projects, you'd realise that the way I've currently set up Maven is not very good for multi-developer projects.

It's also not a good idea to have passwords or computer specific SDK locations in your pom.xml file because each developer will need to change the pom.xml in order to compile the code.

If you're fine with using script files to pass arguments to Maven then that's fine. Otherwise, you can set up the Maven global settings.xml file.

Contents

Machine specific Maven settings

It can be located in either:

  • %M2_HOME%/conf/settings.xml
  • %USERPROFILE%\.m2\settings.xml (aka ~/.m2/settings.xml)

Either way, the guts of it looks the same.

Open up your settings.xml file (you may need to create it for the user specific one).

I use this to store the location of my Android SDK home folder, Android SDK Maven repository and information such as keystore file and passwords.

The profile named "variables" sets up some properties for us which is automatically filled into your pom.xml file when needed.

The Android Maven repository is set up so you don't have to do it in every pom.xml file you work on.

And lastly, active profiles tells Maven to always use these the variables profile.

Once you're done, you'll need to reload the settings into Eclipse (if you don't want to restart).

  • Preferences
  • Maven
  • User settings
  • Click "Reindex" to update the settings

And that's it! We've finally reached the end of the Maven journey!

ostrich-skiing

Time to go full pro at Maven now! I mean if an ostrich can ski that good, what's YOUR excuse?

Source

Eclipse, Android and Maven: Part 5 - How to debug your Android app with Maven?

We can see the light at the end of the tunnel now. I'll tell you the steps required, and then describe the nitty gritty details after for those who are interested.

Contents

How to debug with Maven?

  • First of all, connect your test Android device or start the emulator (preferably Genymotion)
  • Place this command into a batch/shell file called "mvn-debug.bat" because you'll run it quite regularly.
mvn package android:deploy android:run -U
  • While you're waiting for it to finish compiling and deploying, set Eclipse into DDMS perspective mode so you can see stuff like the activity log and devices tabs.
  • Each time you start a new Eclipse session, you'll have to tell it once (manually) to debug your app. (I haven't found a way around this yet)
  • Find the "Devices" tab.
  • When your app starts it'll display a message "Waiting for debugger" and wait there.
  • Find and select your app in the devices tab. If you enabled debugging in your app manifest file, it should have a red debug icon next to it, circled in red.
  • Click on the green debug icon in the devices tab toolbar circled in orange. You'll only need to do this the first time debugging.
  • Now you should be debugging like you were before Maven.
  • When you need to debug again in the same session, just run the "mvn-debug.bat" script and it'll start itself. No need to enable debugging again for this session.

image

What actually happened?

  • package: This goal compiles your app and spits out an APK to the "target" folder.
  • android:deploy: This goal uploads your newly compiled APK to the connected device. If there is no device, the build status will be "FAILED" so don't be alarmed if you see that.
  • android:run: This command runs your app on the device.
  • -U: As mentioned in the last tutorial, the -U flag tells Maven to fetch dependencies from the source. This is optional, so use it depending on your circumstances.
  • Because the build and deploy is done outside of Eclipse, it doesn't really have a way of knowing when to attach to ADB for debugging. That's why you have to tell it to debug separately.

Sources

Eclipse, Android and Maven: Part 4 - Share a library project using a local Maven repository

While you're converting your app to a Maven project, you'll soon realise that you need to tackle any shared libraries first. If you've got more than a couple of apps, it's likely you've created a common library between them to keep your code DRY (don't repeat yourself).

(Sorry for interlinked Part 3 and Part 4, but it's just the nature of this process)

Contents

The problem with Maven (and Gradle)

The way Maven works is it downloads shared libraries from a repository of code and attaches it to your code when needed. The problem with privately shared libraries is that you need to push it to a place that Maven can access.

A few answers on StackOverflow say you have to push your private library to a public Maven repository. To me, that's just not acceptable! A workflow should not force private code to be accessible to the public. Not to mention you'll clutter up public repos with code that should not be there in the first place and waste good namespaces. In short no, this is a shit solution.

A other sources suggested making a local repository. That sounds much more reasonable but how do I make that available across multiple dev machines?

Using Google's Support library from the Android SDK local repository

Most likely you're using Google's Android support libraries, so you'll also need to include the SDK local repository as a source for Maven.

First of all, make sure you have the files in the first place.

  • Fire up the Android SDK Manager
  • Scroll down to Extras and make sure "Android Support Repository" is ticked
  • Click Install

image

To include the local repository as a source, paste this under the <project> element.

<project ...>
<repositories>
<!-- Include Android Support Repository so we can access support-v4 and appcompat-v7 aar -->
<repository>
<id>google-sdk-support</id>
<url>file://D:/Android/sdk/extras/android/m2repository/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
</repositories>
</project>

As you can see in  the <url>element, the value can also be a local file system. If we can somehow replicate that structure we can safely share our code, privately.

To gain some inspiration, I studied the local Maven repository found in the Android SDK under "android-sdk\extras\android\m2repository\" and found an answer!

Setting up a local repository for your library

Knowing that Google can make their libraries accessible locally, I decided to make my own library accessible to other projects using this local repository method.

The only difference is that I'm creating a folder called "local-repo" within the root of the library project. This way, projects that use this shared library can refer to it using relative paths.

Initially I tried using the exec-maven plugin to manually move the main artefact to a common folder, but it just wouldn't work from within the Eclipse IDE. It'd work from the command line, but it's too much work compared  to install:install-file" which does just that with far less configuration. Gotta use the right tool for the right job!

So I set up the goals so it'd run "package" to first create the APK, and then using the "install:install-file" goal from the Maven Install plugin, pushes the main artefact (AAR, JAR, etc) into the local-repo repository in a structure which Maven can use.

I stored this command into "mvn-update-local-repo.bat" (excuse the poor naming) in the root folder of the project and run it whenever I need to push something to the local repo.

mvn package install:install-file -DlocalRepositoryPath=local-repo
-DcreateChecksum=true -Dpackaging=aar
-Dfile=target\twig-android-library.aar
-DgroupId=org.twig.common -DartifactId=twig-android-library
-Dversion=1.0.0-SNAPSHOT

The script pushes the file target\twig-android-library.aar to the repository "local-repo". It specifies that it's v1.0.0-SNAPSHOT.

This should be made more flexible by reading the pom.xml file, but haven't found a way yet.

Snapshot builds and caching

Snapshot builds are fetched only once a day. If you're testing and making multiple changes in the same day, use the -U arg to any mvn command to force Maven to fetch from the source, rather than once a day.

Why is this important?

Because each time you build your APK project, the shared library's AAR files from your local-repo are automatically cached in %USERPROFILE%\.m2\repository (aka ~\.m2\repository).

If fixing bugs in your library, Maven is going to use the cached copy so your changes won't be compiled into the APK unless you specify the -U option.

Using your shared library from an app project

So now you're ready to use the shared library in your APK project.

Edit your pom.xml file and look under <projects><repositories>.

Add another <repository> entry for your shared library.

This example assumes that your app project and shared library projects are on the same folder level.

<repository>
<id>twig-android-library</id>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
<url>${project.baseUri}../twig-android-library/local-repo</url>
</repository>

And there you have it, we've safely passed another hurdle without breaking any monitors.

Now you're ready to debug!

Figuring out the cryptic ClassNotFoundException: Didn't find class on path: DexPathList [zip file], nativeLibraryDirectories=[ /vendor/lib, /system/lib]

Fortunately this is a simple one. It's due to the incompatible versioning of libraries used between the Android Support Library and the Android Support v7 Compat library.

Make sure the support library project you've associated with your APK project is the same version as the support library you declared in the pom.xml dependencies.

This should clear you of any more cryptic errors.

Sources

Eclipse, Android and Maven: Part 3 - Converting an existing Android project to a Maven project

Once you get the hang of creating and compiling a Maven project, it's pretty easy to convert an existing project to a Maven one. Just follow a few basic steps and make sure the code compiles properly before continuing.

You'll need a "pom.xml" file in the root of your project. Just use the generic pom.xml file I shared earlier in Part 2 - Compiling and building your APK .

Contents

Steps to convert your project

The first thing you should do is replace as many lib/jar files as you can with their Maven dependency equivalent as covered in Part 2 of the tutorial. Visit the project's website and find the details as most of them will be available on Maven.

If you're using a shared library project then skim the points below before reading Part 4, which explains how to share library projects. You'll need to convert library projects first.

Once the pom.xml file is ready:

  • Right-click on your project > Configure > Convert to Maven project
  • It will now do things to your project and touch it in strange places.
  • Project > Clean to remove all the extra crud.
  • Maven > Update project to sync the settings and download dependencies
  • Run the mvn-debug script

OR

  • Build by right clicking on the project > Debug > Maven build
  • As before, enter in "package" as the goal.

 

You'll probably get some project specific errors so fix them as they come. Keep at it. Make sure it validates within Eclipse before continuing!

I know these steps are fairly generalised, but that's the main things to look for.

Women, children and library projects first

The pom.xml file for your library project should be very similar to the pom.xml for an APK project, with two minor differences.

Rather than using the <packaging> type "apk", we'll use "aar" instead which compiles to an Android ARchive format.

The other small difference is that it doesn't need to be signed for release builds.

Once your library projects are compiling cleanly, skip forward to the next tutorial to Part 4 for a moment to see how to include them into your APK project using local Maven repositories.

The tutorial also covers how you should include Google's support library in your code from the Android SDK.

Sorry for interlinked Part 3 and Part 4, but it's just the nature of this process.

Eclipse, Android and Maven: Part 2 - Compiling and building your APK

Now that you have Eclipse set up properly, you're ready to start building a project!

You should create a new project and learn how it works before you start migrating an existing project.

Contents

Creating a new Maven Android project

  • File > New > Other > Maven > Maven Project > Next > Next.
  • For "Catalog", select  Android (You'll need to be online for this to work)
  • Select "android-quickstart"
  • Next
  • Group ID is the package name portion of your app, such as "org.companyname"
  • Artifact ID is your app's compilation name, such as "codepeeker".
  • Version is pretty much the SEMVER version number. Snapshot indicates it's a dev build of sorts that's constantly pushing a compiled library to a repo. I usually set my version to 1.0.0 for new projects.
  • For more on naming conventions, see Maven – Guide to Naming Conventions
  • Package is prefilled as you enter in your Group and Artifact information.
  • Change platform to the Android API version needed.
  • Click finish when done.

image

  • And the result is this... a broken project.
image Same as regular Android development
gen: As before, this is the generated files folder.
src: Where your source files go
assets: Asset files
bin: Binary files. APK file no longer goes here!
res: Resource files. Feel free to remove all the ones you don't need. 

New folders
target: This is where you can find your APK file once it has been compiled.

New files
pom.xml: The configuration file which tells Maven how to build your project.

 

Ignoring the consume-aar goal

The pom.xml file generated for you is broken by default. At the bottom of pom.xml, you'll see this lint error:

Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:consume-aar (execution: default-consume-aar, phase: compile)

image

You can use the suggestions by clicking the red cross on the left to either:

  • Option 1: Mark it as ignored in pom.xml (preferred, but makes the XML messy)
  • Option 2: Ignore permanently in Eclipse (not advised if you work with other people or compile with command line)

Note: If neither of these options are available to you, close pom.xml, right-click it in the file explorer and select Open With > Maven POM Editor.

image

Choosing Option 1 will add the following <plugin> XML to ignore the consume-arr build goal (under build > pluginManagement > plugins). Don't copy paste, just let Eclipse do it for you.

This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.

Here's one I prepared earlier

I've created a generic pom.xml that works great as a base for most Android app projects. Just fill in the important parts and the rest should be fairly straight forward. Main things to change are:

<groupId>org.twig.apps</groupId>
<artifactId>d2_runewords</artifactId>
<version>1.0.0</version>
<name>Diablo 2 Runewords</name>
  • The platform version (Android API level).
<sdk>
<platform>16</platform>
</sdk>
  • Make changes to anything under <properties> to suit your system setup such as "android.sdk.path". These are Maven variables which you can access using ${varname}.
  • Added a jarsigner plugin so the Android APK is signed when we're ready to release.

A few other things I had to configure are:

  • Java version 1.6 as a minimum for annotation processing (butterknife, parceler, android annotations, etc)
  • I've configured the Android SDK local repository so you can easily use the support libraries. (More about that in Part 3)
  • The way you include dependencies is via dependencies > dependency
  • defaultGoal tells the script what to do and in what order. The "package" goal creates the APK and "android:deploy" pushes it to the device for testing.

Here's the file:

Whenever you make changes to pom.xml, you may need to keep the project in sync with it. Right click on your project > Maven > Update project (or Alt+F5 for those keyboard savvy users). This ensures the Eclipse project has the same configuration as the Maven pom.xml file, dependencies are pre-downloaded ready for compilation and stuff like that.

Compiling from command line

Personally I much prefer compiling from command line. It avoids a lot of the unnecessary complexities and repetitive confirmations involved with the Eclipse UI when it comes to debugging.

I created a script/batch file that contains the following command:

mvn package android:deploy android:run

What this does is compile your APK (package), push the APK to the emulator (android:deploy) and then start it (android:run).

I saved it in the same folder as your project and named it "mvn-debug.bat". Just run that whenever you want to debug your app. It's a lot less trouble than going through the "Eclipse way".

At this point you should be able to compile an APK file and find it in the "target" folder.

Compiling the Eclipse way

Now the Eclipse way...

  • Right-click on your project > Debug > Maven build.
  • Type in "package android:deploy android:run" as a goal.
  • Click "Debug"
  • Check the Maven console to see the log.
  • If everything went according to plan, you should now have a healthy baby APK sitting in your target folder.

image

image

Adding dependencies

Now the main purpose of this lengthy exercise is to easily add new dependencies and removing the complicated mess involved with annotation settings.

The best way of finding the dependency groupID and artifactID is looking up the project homepage and copying the install instructions. For example Butterknife. Here's the Gradle version:

compile 'com.jakewharton:butterknife:6.0.0'

Compared to the Maven version:

<dependency>
<groupId>com.jakewharton</groupId>
<artifactId>butterknife</artifactId>
<version>6.0.0</version>
</dependency>

It's pretty easy to translate the Gradle version to Maven, so if the project doesn't provide the Maven dependency XML you can just convert it yourself.

Under the <dependencies> tag, add in your dependency.

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>

<!-- New dependency here -->
<dependency>
<groupId>com.jakewharton</groupId>
<artifactId>butterknife</artifactId>
<version>6.0.0</version>
</dependency>
<!-- /copy -->
</dependencies>

Optional: For some libraries which require multiple dependencies to be the same version (support-v4 and appcompat-v7), I like to have a dependency version under <properties>, so it's easy to find and change:

<android.support.version>19.1.0</android.support.version>

And replace the dependency version with:

<version>${android.support.version}</version>

Once you save pom.xml, update your project and it should automatically fetch any files needed from the Maven repository.

Perform a build to confirm everything is working fine.

Sources

Eclipse, Android and Maven: Part 1 - Installing Maven for Eclipse

Sadly, this tutorial series is far longer than it should be because of the sheer number of things that can go wrong during this process. I spent about a few days all up getting the whole process ironed out smoothly enough for A to Z Android APK development and release.

Some people may be wondering why I don't just use Android Studio because Gradle is awesome. I do, at home and yes, Gradle is good and I love the update process but I feel Android Studio still isn't quite there yet. There's still no one-button deploy+debug (something so trivial that happens so often in Android development) and it's constantly destroying my CPU/battery life while I'm travelling. That's just not feasible.

Note: Before you start, back up your Eclipse folder. If history is anything to go by, something may go wrong even if you did everything correctly. This quick backup can save you hours of configuration if something does go pear shaped.

Contents

Downloads

  • Eclipse v3.8.2 (I've found these instructions don't work for Eclipse below 3.8, unsure about v4.x+)
  • Java 7 JDK (not JRE. Java 6 is ok, but not Java 8)
  • Download Maven 3.2.3 (Binary zip).
  • While that's downloading, using the Eclipse software installer: Download Maven for Eclipse (m2e-apt) via http://download.eclipse.org/technology/m2e/releases
  • Untick "Show only the latest versions of available software"
  • Install "m2e - Maven Integration for Eclipse v1.4.1.20140328-1905".
    Don't use the latest version 1.5.0, it'll cause this error:

Cannot complete the install because one or more required items could not be found.
  Software being installed: m2e - Maven Integration for Eclipse (includes Incubating components) 1.5.0.20140606-0033 (org.eclipse.m2e.feature.feature.group 1.5.0.20140606-0033)
  Missing requirement: Maven Integration for Eclipse 1.5.0.20140606-0033 (org.eclipse.m2e.core 1.5.0.20140606-0033) requires 'bundle com.google.guava [14.0.1,16.0.0)' but it could not be found
  Cannot satisfy dependency:
    From: Maven Integration for Eclipse (Editors) 1.5.0.20140606-0033 (org.eclipse.m2e.editor 1.5.0.20140606-0033)
    To: bundle org.eclipse.m2e.core [1.5.0,1.6.0)
  Cannot satisfy dependency:
    From: m2e - Maven Integration for Eclipse (includes Incubating components) 1.5.0.20140606-0033 (org.eclipse.m2e.feature.feature.group 1.5.0.20140606-0033)
    To: org.eclipse.m2e.editor [1.5.0.20140606-0033]

  • Restart Eclipse when done.
  • Again using the Eclipse software installer: Download Android for Maven (Android Connector) from http://rgladwell.github.io/m2e-android/updates/. This lets you create Android projects using Maven.
  • Restart Eclipse when done.

Setting up Eclipse for Maven

The plugin com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2 requires Maven version 3.1.1

The android-maven-eclipse plugin has an implementation of Maven built into it. That implementation is for an older API and no longer compatible with the builds that we need (AAR support is needed for Android's appcompat-v7 and shared libraries).

  • Extract "apache-maven-3.2.3.zip" to "C:\Development\Java\apache-maven-3.2.3\" (You can put this anywhere, but adjust the instructions to match your folder)
  • In Eclipse, go to Preferences > Maven > Installations > Add > C:\Development\Java\apache-maven-3.2.3\
  • OK to save

Make sure you're using the right runtime environment.

  • Open up Preferences > Java > Installed JREs
  • If "JRE" is ticked then you've got the wrong runtime environment installed. What you need for development is a JDK, and Java 7 (or 6) is the version you need (Android doesn't support Java 8 yet).
  • Click on Search and find your Java installation folder, normally C:\Program Files\Java
  • Search should now fill in some JREs for you.
  • If no JDK's appear, you'll have to download a Java7 JDK and repeat the search after it's installed.
  • Select the JDK and click OK to save.

image

If you didn't set this up correctly, it will cause the following error:

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

This might sound silly, but open up Preferences again. This step needed the JDK to be set up properly in order to work.

Now we're going to select which environment is executed. This prevents the stupidly undescriptive "The method of type new must override a superclass method" error when trying to compile your code.

  • Go to Preferences > Java > Installed JREs > Execution Environments.
  • Make sure that you have "JavaSE-1.7" (or JavaSE-1.6 if you're using Java 6) and that the "Compatible JREs" column shows the JDK option.
  • Tick it, then OK to save.

image

System environment variables

One final step for the future is to set some system environment variables.

  • Start menu > type in "system environment variables"
  • Click on "Edit the system environment variables"
  • Click on "Environment variables"
  • Click new on either user or system variable
  • Firstly, set "M2_HOME" to "C:\Development\Java\apache-maven-3.2.3" (no trailing slash)
  • Now edit "Path" and add "%M2_HOME%\bin" at the end.

This will let you run "mvn" from any command prompt, which is needed for building, deploying and debugging later on.

Now you're finally to start converting your Android project to Maven.

Sources

Eclipse: Hide pyc files from Open Resource Window

Something that's been bothering me for some time now is the fact pyc files appear in Eclipse's "Open Resource" popup when using PyDev.

image

Although they don't show in the project explorer, there's absolutely no reason for them to appear in the resource popup. So, in order to remove them you'll have to:

  • Right click on your project (it seems you only have to do this once)
  • Click Properties
  • Go to Resource > Resource Filters
  • Click "Add"
  • Filter type: Exclude all
  • Applies to: Files
  • Click "All children (recursive)"
  • File and folder attributes: Name matches *.pyc
  • OK to apply and save thoroughly

 

image
Your settings should look a little something like this.

Although I've only done this once, it seems that it applies to all my projects. Could be wrong, but I don't remember having to do it for all my projects.

Source

Sublime Text 2 / Eclipse: View the same file in two different places simultaneously

One of the more interesting features of Sublime Text 2 was the ability to view a file in two places at once. I saw this in a video tutorial on Lynda and wondered if it was possible to do in Eclipse also.

This becomes VERY useful when editing HTML files where CSS/JS declarations are in the header and the content is in the body.

Sublime Text 2

Since I saw this feature here first, I'll write about it Sublime before Eclipse.

Open up the file you wish to edit. Then click on File > "New view into file".

Eclipse

My old trusty Eclipse. Slow and hefty, but it's the Swiss army knife of development for me.

As before, open up the file you wish to edit. This time, click on Window > "New Editor".

Sources

Eclipse: Ignore certain files in project such as .git and .svn

For some time, the only way to ignore certain file types in Eclipse was to create a plugin.

Resource filters were added recently (apparently in 3.6 Helios) and I had only discovered them recently.

They solve one of the biggest gripes I've had with Eclipse so far. The ability to ignore any file matching a pattern (such as compile .pyc python files, MacOSX .DS_Store or thumbs.db).

It can also extend to folder paths so we can ignore those pesky .git or .svn folders and all of the unnecessary files within them.

image

Enough complaining, more removing!

For this example, I'll be showing how to hide all .git folders and their contents. This can be substituted for .svn.

  1. First step, open your project.
  2. Right click, Properties
  3. Expand Resources and click onto Resource Filters
  4. Click "Add"
  5. Use these settings

Filter type: Exclude all.

Applies to: Folders

Click "All children (recursive)" as any subfolders containing your pattern will still show up (common case for .git and .svn)

File and folder attributes: Name matches .git

OK to save!

Click Apply when ready.

image

Eclipse will now refresh and rebuild the project.

If you're ignoring file names, use the following settings instead.

Applies to: Files

Matches: *.pyc (or .DS_Store, thumbs.db, etc)

No need for all children.

Great feature, very flexible but pain in the ass if you've got 15 projects...

Very much worth setting up if you're working over a remote connection, it saves a LOT of time refreshing your project even if it's a LAN connection.

ZaZEf
Happy times!

Sources

Android & Eclipse: Fixing "Derived File Encountered - This file is derived. Do you really want to edit it?"

image

This annoying little quirk also caused my file to stop showing up in the "open resource" dialog.

It happened when I accidentally dragged the java file into the "gen" folder. I guess the SDK automatically marks anything in there as derived.

Derived just tells the Eclipse IDE that files were generated by the system, and will be overwritten if something else changed.

To remove it, simply right click on the file and select "Properties".

From there, untick "Derived" and then save it.

Now, back to business!

bSGfJ

Eclipse: Install HTML editor plugin

This is a lightweight editor plug-in with syntax highlighting and folding.

My Eclipse didn't have it, probably because I downloaded the classic release without all the extra Java trinkets.

Firstly, find out which release you're on. It usually displays a name under the word "Eclipse" on the splash screen when loading.

Then go to:

  • Open the "Help" menu
  • Click "Install new software"
  • Select "<your release name> - http://download.eclipse.org/releases/<release name>" from the dropdown
  • The URL could be http://download.eclipse.org/releases/galileo or http://download.eclipse.org/releases/indigo, depending on what you've got installed.
  • Wait for it to load...
  • Go to the bottom of the list and expand "Web, XML, and Java EE Development"
  • Select ONLY "Web Page Editor"
  • Click "Next"
  • Next again.
  • Accept agreements and finish
  • It may ask for you to accept the certificates when it's finished downloading. Tick the checkbox next to the item in the list and then click Next to install.
  • When it's done, it'll ask you to restart Eclipse. Do it.

Once your back in Eclipse, try editing a HTML file.

If it's not highlighted, you'll have to:

  • Open the Window menu
  • Click "Preferences"
  • General > Editors > File Associations
  • Select *.html
  • Select "HTML Editor" (not web page editor)
  • Click "Default"
  • Click "OK" to save

0df061d558a1bc8921bc7d11e829db19df94e6b3
You should now have a great HTML editor!

Source

Eclipse: Android development "Eclipse is loading framework information and the Layout library from the SDK folder"

When trying to view a layout in the drag and drop interface for the Android IDE, you may see this error:

Eclipse is loading framework information and the Layout library from the SDK folder. main.xml will refresh automatically once the process is finished

image
FFFFFFFFUUUUUUUUUUUUUUUUUU!

If that happens, then simply close Eclipse and open up the Eclipse plugins folder and search for "com.android.*".

The biggest version number is the one you should keep. Anything else should be removed.

image

In my case, I had 4 files to delete from v0.8:

  • com.android.ide.eclipse.editors_0.8.0.v200809220836-110569.jar
  • com.android.ide.eclipse.adt_0.8.0.v200809220836-110569.jar
  • com.android.ide.eclipse.common_0.8.0.v200809220836-110569.jar
  • com.android.ide.eclipse.ddms_0.8.0.v200809220836-110569.jar

Remove the old plugins and all should be well.

kitchen dance
Time for a victory dance.

[ Source ]

Eclipse: Save space and reduce history clutter

Eclipse is a pretty feature packed (and perhaps bloated) IDE, but its still pretty useful. However, it does do some stupid things like storing 900mb worth of crap from yesteryear.

image

In your Eclipse workspace folder, there is a ".metatags" directory that stores all project related information.

Every time you modify a file in Eclipse, a copy of the old contents is kept in the local history.

By default, it keeps up to 50 copies of each file (that is under 1mb) for 7 days. For some reason, my Eclipse wasn't always clearing out the files upon exit either.

If you have a large file intensive project, that's a helluva lot of files! This isn't exactly a bad feature, especially if you don't use version control of some sort, but if you do, its useless.

Under ".metadata\.plugins\org.eclipse.core.resources\.history", you'll be able to find the local history of all edited files. Delete all them. Don't worry, its ok!

Open up your Eclipse preferences dialog and change the following:

image 

I changed mine to 1 day, 1 entry per file and 1mb limit (since I couldn't set anything lower). You may want to change it to something more suitable for your usage.

Remember to restart Eclipse to apply the settings. Your Eclipse should now purge files whenever it is closed, but it still seems to need cleaning once in a while as files are deleted but cache directories aren't.

There are more uncommon space saving tips here.

[ Source, StackOverflow ]

Windows: Regain disk space on C drive with some uncommon methods

I admit I've been lazy and slacking on the computer maintenance side of things lately (which translates to a few years). As a result, things have cluttered up and I'm starting to constantly run low on C:.

I do however perform the usual trimming of the temp folders and restore points, which usually do the trick. I find programs that clear the browser cache to be stupid because the files are eventually redownloaded again when you browse.

So I resorted to TuneUp Utilities' Disk Space Explorer which is a bloody brilliant computer maintenance suite. The Disk Space Explorer is a nice tool that lets you see what folders/files are hogging up space on your computer.

Adobe Acrobat 9

First on the list, and somehow unsurprisingly, Adobe Acrobat. Delete the stupid installer cache files, with half the files in languages I cant even read!

Shaved: 1.22gb.

Windows Installer Cache

Much like the the previous program, incomplete or unsuccessful installations may leave horrendous cache files on your computer.

Use the Windows Installer Cleanup Utility (which is basically MSI Zap with a nice frontend) to remove the files in a safer manner. Just be careful with it. Its sort of like a big hammer so if you go apeshit with it, something will break.

Some programs will have broken shortcuts after this is run. Just edit the shortcut and set a target, or recreate a shortcut that runs the appropriate executable.

It also removes the install logs, which makes it impossible to uninstall the software. Just be sure you want to keep it ;)

Shaved: 2.16gb to 793mb (and thats just by removing Visual Studio 2005!)

ACDSee Catalogue Database

You may have noticed that I use alot of "strange images" in my posts. I'm a massive image hoarder, and that causes my image manager to suffer.

Remember to clean your ACDSee catalogue database!

Shaved: 1.6gb to 860mb.

NOD32 Antivirus Quarantine

The quarantine will store a copy of all infected files, including the gigantic (and infected) setup files that you might of grabbed off torrents.

Go to "Tools" > "Quarantine" and remove any files you know you wont need. Its a shame you cant sort by file size.

Shaved: 530mb to 5.38mb.

Compact Thunderbird POP3 Accounts

IMAP accounts will just download content from the servers when needed, but POP3 will store a copy of the email even after you've deleted it.

To delete the unecessary emails, clear your folders (inbox, sent, etc) and then delete them again from the trash folder. Now select your account, go to "File" > "Compact Folders".

Depending on how much crap you deleted, this may take some time. The first time I discovered this functionality, I saved over 1.2gb of space! Now I do this quite often, so I didn't save as much space.

Shaved: 1.66gb to 1.63gb.

Compact VMWare Virtual Hard Drives

All your VM machines need some loving too. See here to find out how to compact the virtual disks.

This will take quite some time, and the space saved will really depend on how much you use the virtual machines. While you're waiting, you can do the next part.

Vista was disgustingly slow and took the longest to shrink by far. Its ridiculous, because there wasn't even anything installed on the damn image and it took longer than overnight to complete! Vista went from being 6.59gb to 7.9gb. WTF?

Shaved: 60.3gb to 55.19gb

Clean Up Your Mess

You always have the feeling that one day, some point in your life you're gonna have to clean your room. Same deal with your downloads folder, one day you're gonna have to clean it out and remove those duplicate downloads.

Eclipse Workspace History

See here to reduce the size of your Eclipse workspace folder by deleting the local history. The local history is a backup copy of anything you save.

Clearing this also seems to speed up your Eclipse loading times.

Shaved: 943mb

Eclipse: Hide *.svn-base in Open Resource dialog

If you're using SVN to version control the source you're working with, you may notice in Eclipse v3.5 that the Open Resource dialog now shows you LOTS of *.svn-base files.

This is due to the filtering configuration in the plugins system has changed and plugins need to be updated.

The easiest way to hide those SVN files is to install Subclipse 1.6.x, which has been updated to work with the right filter configuration.

Installing Eclipse with PyDev

Getting started with a new language can be a bit difficult, but it can be alot less frustrating with the right development environment helping you along the way with little trips here and there.

At time of writing, I have set this up with

  1. Eclipse v3.5 (162mb)
  2. Python v2.6.2 (13.8mb)
  3. PyDev

To install, download the required files listed above. Then

  • Install Python (anywhere)
  • Download and unzip Eclipse into a folder of your liking
  • Create a "workspace" directory for your python projects
  • Run Eclipse and select your workspace folder.
  • Click on "Help" > "Install New Software..."
  • Click "Add" and type "PyDev" for the name, using http://pydev.sourceforge.net/updates as the location.
  • Expand and select "Pydev".
  • Click through to finish.
  • Restart when prompted.

Configuring PyDev

  • Select "Window" > "Preferences"
  • Expand "Pydev" and select "Interpreter - Python"
  • Click "New" and give it a name.
  • Select "python.exe" from your Python install path.
  • Click OK and accept the defaults.
  • Save the preferences and now you're ready to go!

Setting up Eclipse for Android development

Curious to see what the Android platform has to offer, I decided to try out some basic app development with it.

What you need:
  • Android SDK
  • Java SDK (JDK)
  • Eclipse

What I got: (for this tutorial)

File Setup:
I put all my files in a common folder, just to make things easier to find.
You can put them anywhere else, just remember to adjust the pathnames in this tutorial accordingly.

Create a folder "D:\Android" and extract the contents of both "android-sdk-windows-1.1_r1.zip" and "eclipse-SDK-3.4.2-win32.zip" into it.

Then create a folder "D:\Android\workspace" to save your Eclipse projects.

The folder should now contain 3 folders:
  • D:\Android\android-sdk-windows-1.1_r1\
  • D:\Android\eclipse\
  • D:\Android\workspace\

Installing ADT Plugin for Eclipse:

Starting up "D:\Android\eclipse\eclipse.exe" will load the Eclipse IDE.
When Eclipse asks you what workspace to load up, select "D:\Android\workspace".

(optional)
Click "Use this as the default and do not ask again" if you don't plan on changing your workspace.

Once its done loading, close the welcome screen.

Go to "Help -> Software Updates -> Available Software -> Add Site".
Paste in https://dl-ssl.google.com/android/eclipse (or http://dl-ssl.google.com/android/eclipse if the other site isn't working).
Expand the new Android node and wait for it to fetch some information.
Once it loads, select "Developer Tools" and click the "Install" button.
This will take a while to finish.
Restart Eclipse when prompted.

Configuring ADT Plugin:
Once its done reloading, there is one last step in configuring Eclipse before its ready for use.
Go to "Windows -> Preferences -> Android -> Browse".
Select "D:\Android\android-sdk-windows-1.1_r1" and click OK.

You are now ready to develop with the Android platform.



Testing:
To test out your setup, right click on the package explorer and select "New -> Project"
Select "Android -> Android Project" and click "Next".

Since its easier to test with some existing code, we're going to use the sample project "LunarLander".
Click on "Create project from existing source" and then click "Browse".
Select "D:\Android\android-sdk-windows-1.1_r1\samples\LunarLander" and click "Finish".

Go to "Run -> Debug -> Android Application".

The emulator should start up and display "A N D R O I D _" on a black screen for a few moments. It'll take a little bit longer to load up the Android OS, but eventually the LunarLander application should start up.

Enjoy!

Eclipse - Windows/Unix new line formatting

Sometimes you have to do work with Unix/Linux machines and the differences in new line encodings can be annoying, especially when doing diffs or merges.

Luckily, Eclipse has options for this which covers a global and per-project scope.

To change the option globally:
1. Open the preferences dialog.
2. Select "General" > "Workspace".
3. Change the "New text file line delimiter" to "Other" and select your preference.

To change the option on a per-project basis:
1. Open the project.
2. View the project properties.
3. Select "Resource"
4. Change it from "Inherited from container" to "Other" and select your preference.

If your project is using UTF8, you might want to take the time to change it to UTF8 while you're at it.

Eclipse PDT and Quick Outline

A great feature which eclipse PDT has is the "Quick Outline".

Much like the one in the Java perspective, the Quick Outline displays a list of functions/variables/defines/classes/etc in the current file in a filterable dialog.

It can be accessed via the shortcut key Ctrl+O. I'm not sure if this is the default key binding or not, but it is definitely useful to have.

If it weren't for this feature I definitely would of stuck with PHPeclipse, which has many other great features including variable highlighting, marking of unused/undefined variables and better integration with Eclipse.

Eclipse PDT and brace matching

Using the latest (at time of download) version of eclipsePDT R20080603 (Win32 All-in-one), I thought it'd be fine and dandy and ready to use straight out of the box.

After setting up a directory and importing some Drupal files into my project, I began to work on some modules.

However, the default PHP brace matching key binding sucked. Who the hell uses Ctrl+Shift+P for brace matching?

Changing it to Ctrl+], I noticed that it didnt work. Checking a few sites on Google, it seemed that a few other people had the same problem.

I updated Eclipse PDT through the "PDT Update" site via Eclipse "Find and install" wizard, but that didn't fix it either.

Eventually I got frustrated and removed the key bindings for Ctrl+] for both "Editing Java Source" and "Editing PHP Source" and configured one key binding for Ctrl+] for "Editing text".

Now my brace matching works on PHP quite nicely, the way its meant to work.
 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog