Ionic Android build throws warnings

2019-07-25 10:25发布

Whenever I build my project using Ionic it gives me 1000 of warnings. I have tried many things, changes in the proguard-rules.pro, but none of them seems to be working. I am not sure how to remove those warnings. Some of them are below.

Maybe this is program method 'org.xwalk.core.internal.InMemorySharedPreferences$InMemoryEditor { void apply(); }'
Note: android.support.v4.app.NotificationCompatJellybean accesses a declared field 'icon' dynamically
      Maybe this is program field 'android.support.v4.app.NotificationCompat$Action { int icon; }'
      Maybe this is program field 'android.support.v7.appcompat.R$attr { int icon; }'
      Maybe this is program field 'android.support.v7.appcompat.R$id { int icon; }'
      Maybe this is program field 'com.digits.sdk.android.R$attr { int icon; }'
      Maybe this is program field 'com.digits.sdk.android.R$id { int icon; }'
      Maybe this is program field 'com.facebook.android.R$attr { int icon; }'
      Maybe this is program field 'com.facebook.android.R$id { int icon; }'
      Maybe this is program field 'com.twitter.sdk.android.R$attr { int icon; }'
      Maybe this is program field 'com.twitter.sdk.android.R$id { int icon; }'
      Maybe this is program field 'dk.nodes.ncore.R$attr { int icon; }'
      Maybe this is program field 'dk.nodes.ncore.R$id { int icon; }'
      Maybe this is program field 'io.fabric.sdk.android.services.settings.AppRequestData { io.fabric.sdk.android.services.settings.IconRequest icon; }'
      Maybe this is program field 'io.fabric.sdk.android.services.settings.AppSettingsData { io.fabric.sdk.android.services.settings.AppIconSettingsData icon; }'
Note: android.support.v4.app.NotificationCompatJellybean accesses a declared field 'title' dynamically
      Maybe this is program field 'android.support.v4.app.NotificationCompat$Action { java.lang.CharSequence title; }'
      Maybe this is program field 'android.support.v7.appcompat.R$attr { int title; }'
      Maybe this is program field 'android.support.v7.appcompat.R$id { int title; }'
      Maybe this is program field 'com.digits.sdk.android.R$attr { int title; }'
      Maybe this is program field 'com.digits.sdk.android.R$id { int title; }'
      Maybe this is program method 'com.google.android.gms.internal.zzso { com.google.android.gms.internal.zzsu clone(); }'
      Maybe this is program method 'com.google.android.gms.internal.zzso { java.lang.Object clone(); }'
      Maybe this is program method 'com.google.android.gms.internal.zzsq { java.lang.Object clone(); }'
      Maybe this is program method 'com.google.android.gms.internal.zzsr { java.lang.Object clone(); }'
      Maybe this is program method 'com.google.android.gms.internal.zzsu { com.google.android.gms.internal.zzsu clone(); }'
      Maybe this is program method 'com.google.android.gms.internal.zzsu { java.lang.Object clone(); }'
      Maybe this is program method 'com.google.gson.internal.Excluder { com.google.gson.internal.Excluder clone(); }'
      Maybe this is program method 'com.google.gson.internal.Excluder { java.lang.Object clone(); }'
      Maybe this is program method 'com.google.protobuf.AbstractMessage$Builder { com.google.protobuf.AbstractMessage$Builder clone(); }'
      Maybe this is program method 'com.google.protobuf.AbstractMessage$Builder { com.google.protobuf.AbstractMessageLite$Builder clone(); }'
      Maybe this is program method 'com.google.protobuf.AbstractMessage$Builder { com.google.protobuf.MessageLite$Builder clone(); }'
      Maybe this is program method 'com.google.protobuf.AbstractMessage$Builder { java.lang.Object clone(); }'
      Maybe this is program method 'com.google.protobuf.AbstractMessage$Builder { com.google.protobuf.Message$Builder clone(); }'

And my 'progaurd-rules.pro' as follows

-keepattributes InnerClasses
-keepattributes Signature
-keepattributes Exceptions
-verbose

-dontoptimize
-dontpreverify

-dontnote **

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepattributes EnclosingMethod
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
-keep public class com.google.** {*; }
-keep public class com.facebook.** {*; }

-ignorewarnings

-dontwarn android.support.v7.**
-keep class android.support.v7.internal.** { *; }
-keep interface android.support.v7.internal.** { *; }
-keep class android.support.v7.** { *; }

-dontwarn android.support.v7.appcompat.** {*;}
-dontwarn com.squareup.okhttp.**
-keep interface android.support.v7.appcompat.** { *; }
-keep class android.support.v7.appcompat.** { *; }

-keep class com.facebook.** {
   *;
}

-dontwarn org.apache.commons.lang3.time.**
-dontwarn dk.nodes.widgets.buttons.**
-dontwarn net.hockeyapp.android.tasks.**

-dontobfuscate
-dontpreverify

-dontnote android.support.v4.app.NotificationCompatJellybean
-dontwarn android.support.v4.app.NotificationCompatJellybean

-dontnote org.apache.commons.lang3.ObjectUtils
-dontwarn org.apache.commons.lang3.ObjectUtils

-dontnote com.google.protobuf.Descriptors$FileDescriptor
-dontwarn com.google.protobuf.Descriptors$FileDescriptor

-dontwarn class * extends com.google.protobuf.GeneratedMessageLite.** { *; }
-dontwarn interface * extends com.google.protobuf.GeneratedMessageLite.** { *; }
-dontnote com.google.protobuf.**
-dontnote com.google.android.**

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

 -keepclassmembers public class * extends android.view.View {
  void set*(***);
  *** get*();
 }

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
  public static <fields>;
  <fields>;
}

-libraryjars libs
#-injars libs/AudienceNetwork.jar
#-injars libs/google-api-client-1.18.0-rc.jar
#-injars libs/google-api-client-android-1.18.0-rc.jar
#-injars libs/google-http-client-android-1.18.0-rc.jar


 # The official support library.
-keep class android.support.v4.** { *; }
-keepclassmembers class android.support.v4.** {
    *;
 }
-keep interface android.support.v4.** { *; }
-keep class android.support.v7.** { *; }
-keepclassmembers class android.support.v7.** {
    *;
 }
-keep interface android.support.v7.** { *; }

# Library JARs.
-keep class com.facebook.** {
   *;
}
-keepclassmembers class com.facebook.** {
    *;
 }

When I build on Android Studio, I dont get warnings. But on terminal, 'ionic android build' I get warnings, that too only on first time after 'ionic state reset'. Those warnings are because of list of Notes displaying.

Reading library jar [/Users/neelavijayakumar/Library/Android/sdk/build-tools/23.0.2/lib/shrinkedAndroid.jar]
Note: android.support.v4.view.ViewPager calls 'Class.getAnnotation'
Note: com.facebook.model.GraphObject$Factory calls 'Method.getAnnotation'
Note: com.facebook.model.GraphObject$Factory$GraphObjectProxy calls 'Method.getAnnotation'
Note: com.google.ads.mediation.MediationServerParameters calls 'Field.getAnnotation'
Note: com.google.android.gms.internal.zzamp calls 'Field.getAnnotation'
Note: com.google.android.gms.internal.zzant calls 'Class.getAnnotation'
Note: com.google.android.gms.internal.zzant calls 'Field.getAnnotation'
Note: com.google.android.gms.internal.zzaoe calls 'Class.getAnnotation'
Note: com.google.android.gms.internal.zzaoj calls 'Field.getAnnotation'
Note: com.google.android.gms.internal.zzaon$zza calls 'Field.getAnnotation'
Note: com.google.gson.FieldAttributes calls 'Field.getAnnotation'
Note: com.google.gson.FieldAttributes calls 'Field.getAnnotations'
Note: com.google.gson.internal.Excluder calls 'Field.getAnnotation'
Note: com.google.gson.internal.Excluder calls 'Class.getAnnotation'
Note: com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory calls 'Class.getAnnotation'
Note: com.google.gson.internal.bind.ReflectiveTypeAdapterFactory calls 'Field.getAnnotation'
Note: com.google.gson.internal.bind.TypeAdapters$EnumTypeAdapter calls 'Field.getAnnotation'
Note: com.pushwoosh.internal.request.RequestManager$1 calls 'Class.getAnnotation'
Note: io.fabric.sdk.android.Fabric calls 'Class.getAnnotation'
Note: io.fabric.sdk.android.Kit calls 'Class.getAnnotation'
Note: org.xwalk.core.extension.JsStubGenerator calls 'Method.getParameterAnnotations'
Note: retrofit.RestMethodInfo calls 'Method.getAnnotations'
Note: retrofit.RestMethodInfo calls 'Class.getAnnotations'
Note: retrofit.RestMethodInfo calls 'Method.getParameterAnnotations'
Note: acidhax.cordova.chromecast.Chromecast calls 'Method.getGenericParameterTypes'
Note: android.support.v4.app.NotificationCompatJellybean calls 'Field.getType'
Note: com.digits.sdk.android.ActivityClassManagerFactory$ThemeAttributes calls 'Field.getType'
Note: com.digits.sdk.android.ThemeUtils calls 'Field.getType'
Note: com.facebook.model.GraphObject$Factory$GraphObjectProxy calls 'Method.getGenericReturnType'
Note: com.google.android.gms.internal.zzanr calls 'Class.getGenericInterfaces'
Note: com.google.android.gms.internal.zzanr calls 'Class.getGenericSuperclass'
Note: com.google.android.gms.internal.zzanr calls 'Class.getTypeParameters'
Note: com.google.android.gms.internal.zzant calls 'Field.getType'
Note: com.google.android.gms.internal.zzaoj calls 'Class.getGenericSuperclass'
Note: com.google.android.gms.internal.zzaoj calls 'Field.getGenericType'
Note: com.google.android.gms.internal.zzaoj calls 'Field.getType'
Note: com.google.android.gms.internal.zzaoo calls 'Class.getGenericSuperclass'
Note: com.google.android.gms.internal.zzapd calls 'Field.getType'
Note: com.google.gson.FieldAttributes calls 'Field.getGenericType'
Note: com.google.gson.FieldAttributes calls 'Field.getType'

For the first time, there are many getting updated, from second time, all are up-to-date so I dont get warnings. This is detailed analysis on the issue. Also I forgot to mention that these are from AAR libraries that I use in my ionic project. Please help me on this.

2条回答
贪生不怕死
2楼-- · 2019-07-25 10:39

To add up to the answer, proguard setting too is still required.

-dontnote option setting in proguard should help suppress the warnings. For more info on dontnote option, please check out official doc.

查看更多
你好瞎i
3楼-- · 2019-07-25 10:43

Fixed all warnings, I am sure I have tried this earlier, but now it works.

Changed Gradle version on the ionic as "2.0.0" And gradle wrapper distribution url as "http\://services.gradle.org/distributions/gradle-2.10-all.zip"

it just works..

查看更多
登录 后发表回答