https://kotlinlang.org logo
#android
Title
# android
f

freddiewang

06/18/2018, 8:57 AM
Hi I found that kapt would generate some stub with
@android.annotation.TargetApi(value = null)
in my project and it would cause build fail. does anyone know how to avoid it?
r

rkeazor

06/18/2018, 3:24 PM
In your code are you calling @TargetApi , without putting the actual API level
f

freddiewang

06/19/2018, 6:03 AM
in my kotlin file, the function is
Copy code
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
    fun isAsynchronous(isAsynchronous: Boolean): MessageBuilder = apply {
        this.isAsynchronous = isAsynchronous
    }
But in the generated java it is
Copy code
@org.jetbrains.annotations.NotNull()
    @android.annotation.TargetApi(value = null)
    public final com.linecorp.lineat.android.util.MessageBuilder isAsynchronous(boolean isAsynchronous) {
        return null;
    }
r

rkeazor

06/19/2018, 1:46 PM
Are you sure that constant isnt null
Try this @TargetApi(21)
If that works than you know its your constant that is the issue
f

freddiewang

06/19/2018, 11:40 PM
yes, constant value works but
Copy code
Build.VERSION_CODES.LOLLIPOP_MR1
is in android sdk. that is the weird thing…
5 Views