krschultz / android-proguard-snippets

Proguard configurations for common Android libraries
http://www.kevinrschultz.com/blog/2014/02/15/proguard-with-gradle/
Apache License 2.0
4.59k stars 598 forks source link

error while adding multiple proguard directory in release type #138

Open TheReprator opened 7 years ago

TheReprator commented 7 years ago

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:

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

jdulaney commented 7 years ago

switch it to

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

TheReprator commented 7 years ago

thanks it worked.

TheReprator commented 7 years ago

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

sauravexodus commented 7 years ago

Include these in your proguard-rules.pro

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

TheReprator commented 7 years ago

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.

sauravexodus commented 7 years ago

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

enginebai commented 7 years ago

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
TheReprator commented 7 years ago

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

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

TheReprator commented 7 years ago

@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.

trevorwang commented 7 years ago

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

chriscoderdr commented 7 years ago

@TheGreat0004 line of code solved it for me