Entries tagged tools

Using a Perl script because refactoring of a project with Android tools didn’t work

Posted on 20. Dezember 2014 Comments

I wanted to rename my project but I guess since it has a lot of dependencies that caused an error somewhere and I got the error message:

Refactoring
A fatal error occurred while performing the refactoring.
An unexpected exception occurred while creating a change object. See the error log for more details.

So I just the normal refactoring feature of Eclipse which not surprisingly also caused an error. After editing the AndroidManifest package entry, the import of the resources in the sources files didn’t work. It still said

import com.example.oldpackage.R

Only a couple of resource files needed manual editing but the Java files were a problem. What did the trick for me was this one-liner

perl -pi -w -e 's/import com.example.oldpackage.R/import com.example.newpackage.R/g;' `grep -r -l "import com.example.oldpackage.R"`

I realise this is rather quick&dirty (do a backup 😉 ) but it did work for this project. A short explanation:

perl

  • -pi puts the code in a loop (like -n, but sed-style)
  • -w gives you warnings
  • -e is one line of programm and since -pi
  • /g global, for all lines in the file

grep

  • -r recursive
  • -l give out files that matches the following search string

Bei Perl unter Windows 7 fehlt Tk und lässt sich nicht über cpan installieren

Posted on 7. Februar 2013 Comments

Die neue Perl Version enthält aus irgendeinem Grund Tk nicht (mehr?) standardmässig. Perl schlägt dann vor Tk mit dem folgendem Befehl nachzuinstallieren:

cpan -i Tk

Das funktioniert aber nicht, weil u.a. keine Compiler und Linuxtools wie make installiert sind. Also werden diese automatisch heruntergeladen. Allerdings schlägt die Installation trotzdem mit dem folgenden Ausgaben fehl:

rc -fo tk.res -r -i . -i mTk\win\rc mTk\win\rc\tk.rc
'rc' is not recognized as an internal or external command,
operable prgram or batch file.
dmake.exe: Error code 129, while making 'tk.res'
dmake.exe: Error code 255, while making 'pTk\libpTk.a'.

Was jedoch wunderbar und schnell funktioniert hat ist der folgende Befehl:

ppm install Tk