Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

when I post code in gradle.properties I got errors and I don't know why

the code in my bild.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "alghafli.facts"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

and the code in gradle.properties

-assumenosideeffects class android.util.Log {
    public static boolean isLoggable(java.lang.String, int);
    public static int v(...);
    public static int i(...);
    public static int w(...);
    public static int d(...);
    public static int e(...);
}

please help me with this ^_*

3 Answers

Hi Ahmed,

I think I saw another post about this - does this replace that one?

What are you trying to do here? For the Log.e() code to work, your code file needs an import statement. Android Studio should manage this for you, but it is import android.util.Log;

If you're trying to do something other than using Logs please let me know.

Thanks,

Steve.

well I am not trying any thing else but if make changing in the first class to True and change the file to optimize it said worrying then can't resolve build Type and in the second class there are errors in all public statics methods

thanks a lot

OK - can you let me know what you are trying to acheive - I'm not sure I understand.

Your various posts seem to relate to the Log but I'm not sure why we're looking at Gradle files and properties.

Take me right back to the beginning - what are you trying to do that isn't working the way you expect?

Steve.

Sorry - I don't know what you're trying to do so can't help out with a solution. Can you let me know the requirements and what's failing we might get to the bottom of it.

I can't answer how you're getting errors in an Android class without seeing how you've implemented the class and used its public methods.

I want to remove the Log to publish my app in google play I changed in build.gradle

buildTypes { release { minifyEnabled true // I changed here from fails to true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' // and I add to ('proguard-android-optimize.txt') the optimize } } in this class when sync projects I don't get any errors, so every thing is fine here, i thing so

but in gradle.properties if I add the Log

-assumenosideeffects class android.util.Log { public static boolean isLoggable(jave.lang.String, int); // here I got errors below the public public static int v(...);// here too public static int i(...);;// here too public static int w(...);;// here too public static int d(...);;// here too public static int e(...);;// here too }

I hope you understand What I am trying to do

Yes I do - thank you for clarifying and apologies that I didn't get there sooner!!

Unfortunately, that's not something I know about. I'm betting Ken Alger will have an idea, though!

Steve.

thanks Steve

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Ahmed;

Are you putting the -assumenosideeffects code in gradle.properties or in the proguard-rules.pro file?

If you are working through the Removing Log Calls video, at about 3:30 Mr. Jakuben shows the code you posted regarding the log calls, but they are in the proguard-rules.pro file, which is what is referenced in the build.gradle file at the end of the line of code regarding proguardFiles.

Try making that change and post back if you are still having issues, er I mean opportunities for learning.

Happy coding,

Ken