Sonntag, 6. Januar 2013

Android Development with Java 7 and Mac OS X.

First: yes it is possible to use Java 7 to develop Android. However there are two problems.

First Java 6 used a rather strange directory layout. Strange for the average UNIX™ user. Not so strange for unencumbered user as the names used are more readable and understandable.

Since a lot of tools got used to the Java 6 names we need two compatibility links:

pushd /Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/
sudo ln -s jre/lib Classes
cd jre/lib
sudo ln -s rt.jar classes.jar
popd

Java 7 also comes with an new jar signer which by default uses a new algorithm. Android devices can't use that algorithm so you have to force the signer to use the old algorithm:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
</goals>
<phase>package</phase>
<inherited>true</inherited>
<configuration>
<archive>target/${project.build.finalName}.apk</archive>
<arguments>
<argument>-sigalg</argument>
<argument>MD5withRSA</argument>
<argument>-digestalg</argument>
<argument>SHA1</argument>
</arguments>
<sigfile>CERT</sigfile>
<keystore>${env.HOME}/.keystore</keystore>
<storepass>${env.KEY_STOREPASS}</storepass>
<keypass>${env.KEY_KEYPASS}</keypass>
<alias>${env.KEY_ALIAS}</alias>
</configuration>
</execution>
</executions>
</plugin>

You don't use Maven? Your loose, it is the best way to develop Android. And it is just not my opinion: ViewpageIndicator, AndroidAnnotations, Robotium — All the top Android developers use Maven.

Keine Kommentare:

Kommentar veröffentlichen