I have a test activity which should do very simple task : inflate the view, and move it on the screen with ObjectAnimator.
This works perfectly with all devices (OS 2.2+ - OS4.2), if I use the NineOldAndroids library.
However, if I change the library to ActionBarSherlock (which supposes to have the same NineOldAndroid library inside), it works for OS 3.x and above, but it doesn't work for 2.2 and 2.3 devices. In this case it can not find the property and throws a Null Pointer exception (listed below).
Anybody has the same problem? Is there a work around, or I have actually consume both libraries (NineOldAndroids and ActionBarSherlock ) to resolve the issue?
Here is the TestsActivity
:
public class TestActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.main_layout);
View testView = getLayoutInflater().inflate(R.layout.object_holder, null);
mainLayout.addView(testView);
AnimatorSet set = new AnimatorSet();
set.playTogether(
ObjectAnimator.ofFloat(testView, "translationX", 100),
ObjectAnimator.ofFloat(testView, "translationY", 100)
);
set.setDuration(0).start();
}
}
(Same thing happen, if I change "translationX" with "x" . )
Here is the exception (it's happening only if I use the library ActionBarSherlock on 2.2 and 2.3 devices) :
05-16 13:24:53.662: E/PropertyValuesHolder(2007): Couldn't find setter property translationX for RelativeLayout with value type float
05-16 13:24:53.662: E/PropertyValuesHolder(2007): RelativeLayout - Couldn't find no-arg method for property translationX: java.lang.NoSuchMethodException: getTranslationX
05-16 13:24:53.662: D/AndroidRuntime(2007): Shutting down VM
05-16 13:24:53.662: W/dalvikvm(2007): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
05-16 13:24:53.672: E/AndroidRuntime(2007): FATAL EXCEPTION: main
05-16 13:24:53.672: E/AndroidRuntime(2007): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testanimator/com.example.testanimator.TestActivity}: java.lang.NullPointerException
05-16 13:24:53.672: E/AndroidRuntime(2007): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1821)
05-16 13:24:53.672: E/AndroidRuntime(2007): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1842)
05-16 13:24:53.672: E/AndroidRuntime(2007): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
05-16 13:24:53.672: E/AndroidRuntime(2007): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
05-16 13:24:53.672: E/AndroidRuntime(2007): at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 13:24:53.672: E/AndroidRuntime(2007): at android.os.Looper.loop(Looper.java:150)
05-16 13:24:53.672: E/AndroidRuntime(2007): at android.app.ActivityThread.main(ActivityThread.java:4263)
05-16 13:24:53.672: E/AndroidRuntime(2007): at java.lang.reflect.Method.invokeNative(Native Method)
05-16 13:24:53.672: E/AndroidRuntime(2007): at java.lang.reflect.Method.invoke(Method.java:507)
05-16 13:24:53.672: E/AndroidRuntime(2007): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-16 13:24:53.672: E/AndroidRuntime(2007): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-16 13:24:53.672: E/AndroidRuntime(2007): at dalvik.system.NativeStart.main(Native Method)
05-16 13:24:53.672: E/AndroidRuntime(2007): Caused by: java.lang.NullPointerException
05-16 13:24:53.672: E/AndroidRuntime(2007): at com.actionbarsherlock.internal.nineoldandroids.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:515)
05-16 13:24:53.672: E/AndroidRuntime(2007): at com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:386)
05-16 13:24:53.672: E/AndroidRuntime(2007): at com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:539)
05-16 13:24:53.672: E/AndroidRuntime(2007): at com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.start(ValueAnimator.java:929)
05-16 13:24:53.672: E/AndroidRuntime(2007): at com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.start(ValueAnimator.java:952)
05-16 13:24:53.672: E/AndroidRuntime(2007): at com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator.start(ObjectAnimator.java:364)
05-16 13:24:53.672: E/AndroidRuntime(2007): at com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet.start(AnimatorSet.java:501)
05-16 13:24:53.672: E/AndroidRuntime(2007): at com.example.testanimator.TestActivity.onCreate(TestActivity.java:30)
05-16 13:24:53.672: E/AndroidRuntime(2007): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
05-16 13:24:53.672: E/AndroidRuntime(2007): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
05-16 13:24:53.672: E/AndroidRuntime(2007): ... 11 more