Android proguard问题:路径可能不是null或空字符串.路径=“空”

前端之家收集整理的这篇文章主要介绍了Android proguard问题:路径可能不是null或空字符串.路径=“空”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在设置之前,每件事情都很好

minifyEnabled true

shrinkResources true

设置这些值后,每当我运行项目时,我都会收到此错误

  1. Information:Gradle tasks [:app:assembleProdRelease]
  2. Error:path may not be null or empty string. path='null'
  3. Information:BUILD Failed
  4. Information:Total time: 23.606 secs
  5. Information:1 error
  6. Information:0 warnings
  7. Information:See complete output in console

这个错误意味着什么错误:路径可能不是null或空字符串.路径=“空”
这是build.gradle:

  1. signingConfigs {
  2. release {
  3. storeFile file('/home/rishabh/Documents/dekhoJks/release.jks')
  4. storePassword "XXXXXXX"
  5. keyAlias "XXXXXXXX"
  6. keyPassword "XXXXXXXXX"
  7. }
  8. }
  9. buildTypes {
  10. release {
  11. minifyEnabled true
  12. //proguardFiles fileTree(dir: "proguard",include: ["*.pro"]).asList().toArray()
  13. proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
  14. shrinkResources true
  15. signingConfig signingConfigs.release
  16. }
  17. }

我试着把每一个该死的东西都放在proguard.pro中:

  1. -optimizationpasses 5
  2. -dontusemixedcaseclassnames
  3. -dontskipnonpubliclibraryclasses
  4. -dontskipnonpubliclibraryclassmembers
  5. -dontpreverify
  6. -verbose
  7. -dump class_files.txt
  8. -printseeds seeds.txt
  9. -printusage unused.txt
  10. -printmapping mapping.txt
  11. -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
  12.  
  13. -allowaccessmodification
  14. -keepattributes *Annotation*
  15. -renamesourcefileattribute SourceFile
  16. -keepattributes SourceFile,LineNumberTable
  17. -repackageclasses ''
  18.  
  19. -keep public class * extends android.app.Activity
  20. -keep public class * extends android.app.Application
  21. -keep public class * extends android.app.Service
  22. -keep public class * extends android.content.BroadcastReceiver
  23. -keep public class * extends android.content.ContentProvider
  24. -keep public class * extends android.app.backup.BackupAgentHelper
  25. -keep public class * extends android.preference.Preference
  26. -keep public class com.android.vending.licensing.ILicensingService
  27. -dontnote com.android.vending.licensing.ILicensingService
  28.  
  29. # Explicitly preserve all serialization members. The Serializable interface
  30. # is only a marker interface,so it wouldn't save them.
  31. -keepclassmembers class * implements java.io.Serializable {
  32. static final long serialVersionUID;
  33. private static final java.io.ObjectStreamField[] serialPersistentFields;
  34. private void writeObject(java.io.ObjectOutputStream);
  35. private void readObject(java.io.ObjectInputStream);
  36. java.lang.Object writeReplace();
  37. java.lang.Object readResolve();
  38. }
  39.  
  40. # Preserve all native method names and the names of their classes.
  41. -keepclasseswithmembernames class * {
  42. native <methods>;
  43. }
  44.  
  45. -keepclasseswithmembernames class * {
  46. public <init>(android.content.Context,android.util.AttributeSet);
  47. }
  48.  
  49. -keepclasseswithmembernames class * {
  50. public <init>(android.content.Context,android.util.AttributeSet,int);
  51. }
  52.  
  53. # Preserve static fields of inner classes of R classes that might be accessed
  54. # through introspection.
  55. -keepclassmembers class **.R$* {
  56. public static <fields>;
  57. }
  58.  
  59. # Preserve the special static methods that are required in all enumeration classes.
  60. -keepclassmembers enum * {
  61. public static **[] values();
  62. public static ** valueOf(java.lang.String);
  63. }
  64.  
  65. -keep public class * {
  66. public protected *;
  67. }
  68.  
  69. -keep class * implements android.os.Parcelable {
  70. public static final android.os.Parcelable$Creator *;
  71. }
  72. ##---------------End: proguard configuration common for all Android apps ----------
  73.  
  74. #---------------Begin: proguard configuration for support library ----------
  75. -keep class android.support.v4.app.** { *; }
  76. -keep interface android.support.v4.app.** { *; }
  77. -keep class com.actionbarsherlock.** { *; }
  78. -keep interface com.actionbarsherlock.** { *; }
  79.  
  80. # The support library contains references to newer platform versions.
  81. # Don't warn about those in case this app is linking against an older
  82. # platform version. We know about them,and they are safe.
  83. -dontwarn android.support.**
  84. -dontwarn com.google.ads.**
  85. ##---------------End: proguard configuration for Gson ----------
  86.  
  87. ##---------------Begin: proguard configuration for Gson ----------
  88. # Gson uses generic type information stored in a class file when working with fields. Proguard
  89. # removes such information by default,so configure it to keep all of it.
  90. -keepattributes Signature
  91.  
  92. # For using GSON @Expose annotation
  93. -keepattributes *Annotation*
  94.  
  95. # Gson specific classes
  96. -keep class sun.misc.Unsafe { *; }
  97. #-keep class com.google.gson.stream.** { *; }
  98.  
  99. # Application classes that will be serialized/deserialized over Gson
  100. -keep class com.example.model.** { *; }
  101.  
  102. ##---------------End: proguard configuration for Gson ----------
  103.  
  104. # If your project uses WebView with JS,uncomment the following
  105. # and specify the fully qualified class name to the JavaScript interface
  106. # class:
  107. #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  108. # public *;
  109. #}
  110.  
  111.  
  112.  
  113.  
  114. -keepclassmembers class android.support.design.internal.BottomNavigationMenuView {
  115. boolean mShiftingMode;
  116. }
  117.  
  118. -dontwarn com.fasterxml.**
  119. -dontwarn okio.**
  120. -dontwarn retrofit2.**
  121. -dontwarn com.fasterxml.jackson.databind.**
  122.  
  123. # Basic ProGuard rules for Firebase Android SDK 2.0.0+
  124. -keep class com.firebase.** { *; }
  125. -keep class org.apache.** { *; }
  126. -keepnames class com.fasterxml.jackson.** { *; }
  127. -keepnames class javax.servlet.** { *; }
  128. -keepnames class org.ietf.jgss.** { *; }
  129. -dontwarn org.apache.**
  130. -dontwarn org.w3c.dom.**
  131.  
  132. -dontwarn com.firebase.ui.**
  133.  
  134. -keepattributes Signature
  135.  
  136. -dontwarn com.googlecode.mp4parser.**
  137. -dontwarn org.mp4parser.aspectj.runtime.reflect.**
  138. -keep class * implements com.coremedia.iso.Boxes.Box { *; }
  139. -dontwarn com.coremedia.iso.Boxes.**
  140. -dontwarn com.googlecode.mp4parser.authoring.tracks.mjpeg.**
  141. -dontwarn com.googlecode.mp4parser.authoring.tracks.ttml.**
  142.  
  143. -keep class com.facebook.** {
  144. *;
  145. }

但仍然无法运行我的应用程序.我出错的任何帮助.

解决方法

两种解决方

>使用以下类路径. (当我使用2.3.2版时,我收到了这个错误.)

classpath’com.android.tools.build:grad:2.2.2′>如果无法更改类路径版本,请禁用拆分apk选项以进行临时修复.

猜你在找的Android相关文章