Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Lint error: onLayout #33

Open
dlazerka opened this issue May 6, 2015 · 5 comments
Open

Fatal Lint error: onLayout #33

dlazerka opened this issue May 6, 2015 · 5 comments

Comments

@dlazerka
Copy link

dlazerka commented May 6, 2015

Hi Jess,
I don't know how to use this library in my project, (copy-pasting the code doesn't feel right). So I tried to add a library module (using git submodule to keep it up-to-date).
However, when I selected "Import existing Eclipse ADT or Gradle project as a module", it asked me for Eclipse installation location (I don't have any).
So I decided to create a build.gradle file (anyway Android is going the Gradle way, whether we want it or not). I had hard time figuring out proper settings, but finally found that someone already did that: https://github.com/AppFellas/TwoWayGridViewGradle/blob/master/build.gradle
So I created a build.gradle file (below), but there's one problem, it throws a fatal Lint error, along with some non-fatal.
Here it is:

WrongCall: Using wrong draw/layout method
../../src/com/jess/ui/TwoWayAdapterView.java:758: Suspicious method call; should probably call "layout" rather than "onLayout"
 755            // Force one here to make sure that the state of the list matches
 756            // the state of the adapter.
 757            if (mDataChanged) {
 758                this.onLayout(false, getLeft(), getTop(), getRight(), getBottom());
 759            }
 760        } else {
Note: This issue has an associated quickfix operation in Android Studio/IntelliJ Fix 
Priority: 6 / 10
Category: Correctness
Severity: Fatal
Explanation: Using wrong draw/layout method.
Custom views typically need to call measure() on their children, not onMeasure. Ditto for onDraw, onLayout, etc.

To reproduce this, go to /lib, place the build.gradle there, and run gradle build. Gradle version is 2.3, though I doubt that matters.

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.2'
    }
}

apply plugin: 'com.android.library'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'
    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 22
        versionCode 1
        versionName '1.0'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
    // Worakaround for fatal Lint error
    // lintOptions {
    //  abortOnError false
    // }
}
@anthony-bernardo
Copy link

I got the same error,

I can't build apk...

Up !

@imikm
Copy link

imikm commented Jan 2, 2016

i couldn't generate apk , what shall i do ? i hadn't this error on my simulator.

@ArcherN9
Copy link

ArcherN9 commented Jan 4, 2016

Similar error, unable to generate a signed APK for deployment.
Error : Error:(758) Error: Suspicious method call in TwoWayAdapterView.java; should probably call "layout" rather than "onLayout" [WrongCall]

@imikm
Copy link

imikm commented Jan 19, 2016

in TwoWayAdapterView .... i changed onLayout to layout .... also the "false" variable is redundant and the layout method just need get left ,right,top and bottom
i generated apk with no error

@ArcherN9
Copy link

@imikm I tried that. Building a development build is easy. The hard part is if you attempt to build a signed APK for Play Store release. It just won't work, will continue giving the error I posted above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants