I am making an Android app, and have created a custom view to do some animation.
I have created a custom view, extending ImageView and implementing ValueAnimator.AnimatorUpdateListener.
When I try to compile this with maven it fails with “package android.animation does not exist”
However, when building within Intellij Idea it builds fine. After building in Idea it is even possible to run mvn install successfully.
The successful build running fine in the emulator, but not on my physical device.
When trying to start it up on the device I get:
Failed resolving Lno/derp/myapp/view/MyAnimatedView; interface 7 'Landroid/animation/ValueAnimator$AnimatorUpdateListener;'
Link of class 'Lno/derp/myapp//view/MyAnimatedView;' failed
Could not find class 'no/derp/myapp/view/MyAnimatedView', referenced from method no/derp/myapp.MainActivity.onCreate
and then
java.lang.ClassNotFoundException: no/derp/myapp.MyAnimatedView in loader dalvik.system.PathClassLoader[/data/app/no/derp/myapp-2.apk]
pom.xml:
<packaging>apk</packaging>
<name>My App</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/resources</resourceDirectory>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<target>1.6</target>
<source>1.6</source>
</configuration>
</plugin>
</plugins>
I am using the latest version of the SDK. A class importing the mentioned package does not compile, it is not just the view. The same happens with version 2.8.3 of android-maven-plugin (or maven-android-plugin as it was called)
Any ideas?
android.animation is available since API Level 11, you need set your dependency in your pom.xml to use 3.0+ to compile your code in command-line.
The reason why it works in Intellij is IDE usually use default.properties to resolve the SDK used to compile source code, I suppose you use the correct API level in your default.properties.
Hope this help.