5

I'm trying to open a source code of Plumble , I changed gradle wrapper distributionUrl to 4.4 and then this gradle error appeared

tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }

I searched and figured out in gradle 4.4 "Compile" is undefined and I have to use JavaCompiler instead but then this error appeared

Could not find method jniDir() for arguments [C:\Users\NP\Desktop\Plumble-Legacy-master\build\native-libs] on task ':packageDebug' of type com.android.build.gradle.tasks.PackageApplication.

so I replaced

tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
    pkgTask.jniDir new File(buildDir, 'native-libs')
}

to

tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
    pkgTask.jniFolders = new HashSet<File>()
    pkgTask.jniFolders.add(new File(projectDir, 'native-libs'))
}

but now there is a new error in gradle building :

Cannot cast object '[]' with class 'java.util.HashSet' to class 'org.gradle.api.file.FileCollection' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: org.gradle.api.file.FileCollection()

does anybody know how can I fix this? any help will be much appreciated

shmakova
  • 6,076
  • 3
  • 28
  • 44
Shakib Karami
  • 678
  • 1
  • 4
  • 11
  • 1
    You probably inherited these scripts from a very old version of Android Studio. Today, Gradle will build and pack the native libraries for you. Or, if you have prebuilt libraries, [add their location to jniLibs](https://stackoverflow.com/a/22072984/192373). – Alex Cohn Aug 27 '18 at 11:16

1 Answers1

1

Even I faced the issue. The solution that worked for me is 1) Update the build script with the exact maven repo url. 2) add apply plugin : maven to the script.

Spear A1
  • 525
  • 1
  • 7
  • 20
  • Can you please update your answer with some more details? I'm facing a similar issue with the above error. – Mohammedsalim Shivani Feb 28 '19 at 16:02
  • @Shivani Add the exact url - "http://repo1.maven.org/maven2" and try a clean build. It should work. Worst case scenario, delete the project and restart in a new space in your IDE. Post an update if it worked. – Spear A1 Mar 04 '19 at 02:44