Tag Archives: Android Warning

[Solved] Android Warning: Avoid passing null as the view root

When making an application, the Android SDK is changed from 4.4 to 6.0. When using the inflate method of layoutinflater, the following situation appears

LayoutInflater.inflate(intresource,ViewGrouproot)

When the parameter root is null, a warning message appears

Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout’s root element)

You should add:

@SuppressLint("InflateParams")

If you use the inflate method of view and root is null, the warning prompt will not appear

View.inflate(Contextcontext,intresource,ViewGrouproot)

 

[Solved] Android Warning: Gradle DSL method not found: ‘android()’

This problem is caused by the Android attribute in the build.gradle file under project. Under normal circumstances, there are only three attributes in the build.gradle file under Project: buildscript, allprojects and dependencies (which are empty in many cases)

The contents are as follows:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

    repositories {
        jcenter()
    }

    //Configure gradle version
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
}
allprojects {
    repositories {
        jcenter()
    }
}

dependencies {
}