android-proguard-snippets icon indicating copy to clipboard operation
android-proguard-snippets copied to clipboard

error while adding multiple proguard directory in release type

Open TheReprator opened this issue 8 years ago • 11 comments

FileCollection proGuardFileCollection = files { file('./cproguardfiles').listFiles() } proguardFiles(proGuardFileCollection)

Folder name is: cproguardfiles(in project structure )

Error:(23, 0) Cannot convert the provided notation to a File or URI: file collection. The following types/formats are supported:

  • A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
  • A String or CharSequence URI, for example 'file:/usr/include'.
  • A File instance.
  • A URI or URL instance.

This is screen shot 2016-10-10 at 7 00 56 pm

TheReprator avatar Oct 10 '16 13:10 TheReprator

switch it to

proguardFiles fileTree(dir: "cproguardfiles", include: ["*.pro"]).asList().toArray()

jdulaney avatar Oct 10 '16 14:10 jdulaney

thanks it worked.

TheReprator avatar Oct 10 '16 14:10 TheReprator

although the error is removed but it didn't accept the proguard files added, here is the screenshot of the error

here is the error along with screenshot, Warning:com.fasterxml.jackson.databind.ext.PathDeserializer: can't find referenced class java.nio.file.Path Warning:com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry Warning:com.fasterxml.jackson.databind.ext.PathDeserializer: can't find referenced class java.nio.file.Paths Warning:com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector$Java7Support: can't find referenced class java.beans.Transient Warning:com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector$Java7Support: can't find referenced class java.beans.Transient Warning:com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector$Java7Support: can't find referenced class java.beans.ConstructorProperties Warning:com.fasterxml.jackson.databind.ext.PathDeserializer: can't find referenced class java.nio.file.Path Warning:com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector$Java7Support: can't find referenced class java.beans.ConstructorProperties Warning:com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector$Java7Support: can't find referenced class java.beans.Transient Warning:com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector$Java7Support: can't find referenced class java.beans.ConstructorProperties Warning:com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector$Java7Support: can't find referenced class java.beans.Transient Warning:com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector$Java7Support: can't find referenced class java.beans.ConstructorProperties Warning:okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning:okio.Okio: can't find referenced class java.nio.file.Files Warning:okio.Okio: can't find referenced class java.nio.file.Path Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption Warning:okio.Okio: can't find referenced class java.nio.file.Path Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning:okio.Okio: can't find referenced class java.nio.file.Path Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption Warning:okio.Okio: can't find referenced class java.nio.file.Path Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning:retrofit2.Platform$Java8: can't find referenced method 'boolean isDefault()' in library class java.lang.reflect.Method Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup Warning:retrofit2.Platform$Java8: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning:there were 41 unresolved references to classes or interfaces. Warning:there were 1 unresolved references to library class members. Warning:Exception while processing task java.io.IOException: Please correct the above warnings first. Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForClientDebug'.

java.io.IOException: Please correct the above warnings first.

screen shot 2016-10-13 at 10 52 44 am

TheReprator avatar Oct 13 '16 05:10 TheReprator

Include these in your proguard-rules.pro

-dontwarn com.fasterxml.** -dontwarn okio.** -dontwarn retrofit2.**

sauravexodus avatar Oct 31 '16 07:10 sauravexodus

if i add these lines in proguard-rules.pro, then "{ file('./cproguardfiles').listFiles() }" will be useless, your as well as mine efforts will go in vein.

TheReprator avatar Nov 01 '16 05:11 TheReprator

I don't understand. Can you provide any reference?

What I read about -dontwarn is they are only used to ignore warnings while building. So if you know that some unreferenced class won't create a mess in your project then its totally okay to use these.

http://proguard.sourceforge.net/manual/usage.html

sauravexodus avatar Nov 01 '16 07:11 sauravexodus

I had the same problem as well.

android {
    ....
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            FileCollection proguardFileCollection = files { file('./proguard').listFiles() }
            proguardFiles(proguardFileCollection)
        }
    }
}

It seem 2016-11-23 12 32 17

enginebai avatar Nov 23 '16 06:11 enginebai

please add this "proguardFiles fileTree(dir: "proguard", include: ["*.pro"]).asList().toArray()"

and remove these lines, FileCollection proguardFileCollection = files { file('./proguard').listFiles() } proguardFiles(proguardFileCollection)

TheReprator avatar Nov 23 '16 06:11 TheReprator

@sauravexodus , means i include these then, what will be the advantage of adding your file as i have to write the code in my own proguard files.

TheReprator avatar Nov 23 '16 06:11 TheReprator

https://code.google.com/p/android/issues/detail?id=212882

trevorwang avatar Dec 22 '16 03:12 trevorwang

@TheGreat0004 line of code solved it for me

chriscoderdr avatar Jul 16 '17 00:07 chriscoderdr