butterknife icon indicating copy to clipboard operation
butterknife copied to clipboard

Fix usage snippet in ButterKnife Reflect README

Open sewar opened this issue 6 years ago • 4 comments

Using Android Studio 3.2 and Gradle 4.10.3, properties.containsKey('android.injected.invoked.from.ide') is always false.

sewar avatar Feb 01 '19 16:02 sewar

Hmm I'll have to test. I'm pretty sure I was using 3.3 alphas when I wrote this.

JakeWharton avatar Feb 01 '19 16:02 JakeWharton

I just spend 15 mins trying to figure out what's wrong as well. Because you're in a dependencies block Groovy is being clever. We need to prefix properties with project. to make sure we're accessing what we're interested in, or do as @sewar suggested.

If you paste the code from README to AS, sync, and navigate to the declaration of properties you'll see:

package org.codehaus.groovy.runtime;
public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
    public static Map getProperties(Object self);
    public static MetaProperty hasProperty(Object self, String name);

i.e. the val Object.properties: Map<*, *> get() for Kotliners.

Note that even @sewar's suggestion wouldn't work without the project. prefix, because it would be trying to call the above hasProperty method which is a Groovy reflection method.

TWiStErRob avatar Feb 04 '19 00:02 TWiStErRob

Any ideas on how to fix that?

dawidhyzy avatar Apr 30 '19 12:04 dawidhyzy

@dawidhyzy it works if you use project.properties.... or project.hasProperty

TWiStErRob avatar Apr 30 '19 14:04 TWiStErRob

这是来自QQ邮箱的自动回复邮件。   您好,现在无法回复您的邮件。我将尽快给您回复。

EesiLife avatar Aug 27 '23 17:08 EesiLife