Cannot set the value of read-only property 'jniFolders' on task ':android:packageDebug'

Viewed 20058

I wanted to open up and project in Android studio that I haven't worked on in a while, but when Android Studio tries to load the project it fails with this error message:

Error:(21, 0) Cannot set the value of read-only property 'jniFolders' on task ':android:packageDebug'.

I click on the link to the build.gradle and I guess these lines are the problem ...

// needed to add JNI shared libraries to APK when compiling on CLI
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
    pkgTask.jniFolders = new HashSet<File>()
    pkgTask.jniFolders.add(new File(projectDir, 'libs'))
}

I see an answer here: Google AppInvites break build that says to ...

Fixed by adding this instead:

android {
  sourcesets {
    main {
      jniLibs.srcDir new File(buildDir, 'lib')
    {
  }
}

But the above answer is not very clear. I am not sure what line to change and the braces in the answer do not seem to match up.

I am at a total loss at what to do? Any help is appreciated.

Thanks

2 Answers
Related