android targetapi23,Android TargetApi annotation and the Just-In-Time compiler

I'm including Android Beam support for our app. But because we're still support 2.2 * cough cough die froyo, die gingerbread, cough * I've packed all the NFC code in the class NfcHandler with the TargetApi annotation to avoid lint warnings like this:

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)

public class NfcHandler implements NfcAdapter.CreateNdefMessageCallback

then from the MainActivity during onCreate I build the object if necessary like this:

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)

nfcHandler = new NfcHandler(this);

in the constructor it does all the necessary NFC stuff and later in the code if( nfcHandler != null ) I pass the intent to it, so it can check if it's receiving a beam.

All good and great and it works most of the time.

But in rarely occasions Gingerbread devices crash with:

10-22 16:08:01.022 1734-1734/com.baseapp.eyeem.p0 E/dalvikvm﹕ Could not find class 'com.baseapp.eyeem.os.NfcHandler', referenced from method com.foo.MainActivity.onCreate

I mean, the class does exist and it's just a null object of it there.

Because our app on XXHDPI devices is 23mb and on the ldpi Gingerbread 5mb, I can see that the Just in time compiler (JIT) or some other runtime optimization is deleting the unnecessary resources. I wonder if it could be the same case of my NfcHandler class, because it's annotate for ICE_CREAM_SANDWICH it deletes it.

So the question is:

what is happening actually happening and why am I getting this crash just once in a while and not every time?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值