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

error: element value must be a constant expression @BindView(R.id.toolbar) #1698

Closed
hh-ahmad opened this issue Mar 4, 2024 · 2 comments
Closed

Comments

@hh-ahmad
Copy link

hh-ahmad commented Mar 4, 2024

Build info

  • ButterKnife version: [e.g. 10.2.3]

Code

Code of build.gradle(:app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.jakewharton.butterknife'

android {
    compileSdk 34

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    defaultConfig {
        applicationId "com.literacy.hrdi"
        minSdkVersion 24
        targetSdkVersion 34
        versionCode 2
        versionName "1.1"
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/rxjava.properties'
    }
    namespace 'com.literacy.hrdi'
}

tasks.withType(JavaCompile).configureEach {
    options.fork = true
    options.forkOptions.jvmArgs += [
            '--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
            '--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
            '--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
            '--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
            '--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
            '--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
            '--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
            '--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
            '--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
            '--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED',
    ]
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.google.android.material:material:1.11.0'
    implementation 'androidx.recyclerview:recyclerview:1.3.2'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.gms:play-services-location:21.1.0'
    implementation 'com.google.firebase:firebase-core:21.1.1'
    implementation 'com.google.firebase:firebase-messaging:23.4.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test:rules:1.5.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation 'com.android.volley:volley:1.2.1'    
    implementation 'com.google.code.gson:gson:2.10.1'
    implementation 'cn.pedant.sweetalert:library:1.3'
    implementation 'com.rilixtech:materialfancybuttons:1.8.7'
    implementation 'com.rilixtech:fontawesome-typeface:4.7.0.4'
    // implementation of butterknife //
    implementation 'com.jakewharton:butterknife:10.2.3'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
}
apply plugin: 'io.objectbox'
Code of build.gradle(:Project)
buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url "https://objectbox.net/beta-repo/"
            setAllowInsecureProtocol(true);
        }
        google()
    }
    ext {
        agp_version = '7.4.2'
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.2.2'
        classpath 'io.objectbox:objectbox-gradle-plugin:3.8.0'
        classpath 'com.google.gms:google-services:4.4.1'
        classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3'
    }
}
allprojects {
    repositories {
        jcenter()
        maven { url "https://objectbox.net/beta-repo/" }
        google()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
ext {
}
Code of gradle.properties
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m

Logs, stack traces

Logs
error: element value must be a constant expression
    @BindView(R.id.toolbar_activity_home)
@JakeWharton
Copy link
Owner

#1694 (comment)

@hh-ahmad
Copy link
Author

hh-ahmad commented Mar 4, 2024

You may want to add android.nonFinalResIds=false to your gradle.properties. by the following solution.

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

3 participants
@JakeWharton @hh-ahmad and others