JakeWharton / butterknife

Bind Android views and callbacks to fields and methods.
http://jakewharton.github.io/butterknife/
Apache License 2.0
25.56k stars 4.6k forks source link

Migrating to AndroidX resulting into NullPointerException #1563

Closed Harsha-Mahadev closed 4 years ago

Harsha-Mahadev commented 4 years ago

This is app level Gradle

buildscript { // this should always be on top
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://clojars.org/repo/" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        google()
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.0'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'
apply plugin: 'com.jakewharton.butterknife'

//kotlin
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    maven { url "https://maven.google.com" }
    maven { url "https://clojars.org/repo/" }
}

android {

    testOptions {
        unitTests.returnDefaultValues = true
    }
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    defaultConfig {
        applicationId "com.awign.intern"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        testInstrumentationRunnerArguments clearPackageData: 'true'
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true

    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            crunchPngs false
            ext.enableCrashlytics = true
//            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {

            applicationIdSuffix '.debug'
            minifyEnabled false
            shrinkResources false

            crunchPngs false
            ext.enableCrashlytics = false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
            ext.alwaysUpdateBuildId = false
            ext.betaDistributionReleaseNotes = "Release Notes for this build."
            ext.betaDistributionGroupAliases = "my-best-testers"
            ext.betaDistributionNotifications = true

        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dataBinding {
        enabled = true
    }

    androidExtensions {
        experimental = true
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':core')
    implementation project(':aw_utils')
    implementation project(':aw_questions')

    //work manager
    implementation 'androidx.work:work-runtime:2.2.0'

    //firebase job schedoler
    implementation 'com.firebase:firebase-jobdispatcher:0.8.5'

    // ViewModel and LiveData
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"

    kapt "com.google.dagger:dagger-android-processor:$dagger2_version"
    kapt "com.google.dagger:dagger-compiler:$dagger2_version"

    implementation 'com.google.firebase:firebase-config:16.0.1'

    //room orm
    implementation "androidx.room:room-runtime:2.2.1"
    kapt "androidx.room:room-compiler:2.2.1"
    // RxJava support for Room
    implementation "androidx.room:room-rxjava2:2.2.1"

    implementation 'com.github.freshdesk:freshchat-android:2.6.0'

    testImplementation 'org.json:json:20140107'

    implementation 'com.jakewharton:butterknife:10.2.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'
}
apply plugin: 'project-report'
apply plugin: 'com.google.gms.google-services'

Project Level Gradle

buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
        maven { url "http://mobile.maven.couchbase.com/maven2/dev/" }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.3.2'
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
        classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.0'
        classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "androidx.databinding:databinding-runtime:3.5.1"
//        classpath "io.realm:realm-gradle-plugin:3.7.2"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
        maven { url "http://mobile.maven.couchbase.com/maven2/dev/" }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex')) {
                details.useVersion "28.0.0"
            }
        }
    }
}

Have no issue in compiling the project, but views are not binded resulting in NullPointerException at run time.

kelegele commented 4 years ago

how to fix it