chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
712 stars 569 forks source link

show debug message only in debug apk #177

Closed didlich closed 9 years ago

didlich commented 9 years ago

Log.d is used to print debug messages, the message is printed not only in the debug version of the apk but also in the release, which is not desirable

to show the message only in the debug version I created this PR

JohnMcLear commented 9 years ago

Looks like a sensible PR to me. Tnx @didlich

don commented 9 years ago

This fails to build from the command line for me.

cd /tmp
cordova create nfc
cd nfc
cordova platform add android
cordova plugin add /path/to/your/patched/nfc
cordova run

Are you missing an import?

-compile: [javac] Compiling 6 source files to /private/tmp/nfc/platforms/android/ant-build/classes [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. [javac] /private/tmp/nfc/platforms/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java:78: error: cannot find symbol [javac] if (BuildConfig.DEBUG) { [javac] ^ [javac] symbol: variable BuildConfig [javac] location: class NfcPlugin [javac] /private/tmp/nfc/platforms/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java:78: error: illegal start of type

didlich commented 9 years ago

instead of: cordova run I used: cordova build it leads to the same error, but I tested it with Gradle:

cordova build android -- --gradle

this works fine

for ANT the BuildConfig is generated under: platforms/android/CordovaLib/ant-gen/org/apache/cordova/BuildConfig.java

wasn't able to find out why there is a problem with ANT, if it is to complicated I would skip the PR and use Proguard for this task

i.e.: http://stackoverflow.com/questions/12390466/android-proguard-not-removing-all-log-messages

didlich commented 9 years ago

seems there is a better way to kick Log.d in release version