Ad

ERROR: Could Not Get Unknown Property 'appcompat' For Project ':app' Of Type Org.gradle.api.Project

Error rising while Building Gradle of a code I found online.

    implement "com.android.support:appcompat-v7:$project.appcompat"
    implement "com.android.support:cardview-v7:$project.appcompat"
    implement "com.android.support:recyclerview-v7:$project.appcompat"
    implement "android.arch.lifecycle:runtime:$project.arch"
    implement "android.arch.lifecycle:extensions:$project.arch"
    implement "com.squareup.retrofit2:retrofit:$project.retrofit"
    implement "com.squareup.retrofit2:converter-gson:$project.retrofit"
    annotationProcessor "android.arch.lifecycle:compiler:$project.arch"
    implement "com.android.support.constraint:constraint-layout:$project.constraintLayout"
    implement "com.android.support:support-v4:$project.appcompat"

P.S. Problem is solves as i understood how to use a variable in gradle file

Ad

Answer

ERROR: Could not get unknown property 'appcompat' for project ':app' of type org.gradle.api.Project

It happens because you are trying to use a property $project.appcompat not defined in your script.

Update your script with something like:

ext {
    supportLibraryVersion = '28.0.0' //or your version
}

and then (pay attention, implementation and not implement)

dependencies {
    // support libraries
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    //....
}
Ad
source: stackoverflow.com
Ad