web-dev-qa-db-ja.com

Androidプロガードの問題:パスがnullまたは空の文字列ではない可能性があります。path= 'null'

設定する前にすべてがうまくいく

minifyEnabled true

そして

shrinkResources true

これらの値を設定した後、プロジェクトを実行するたびにこのエラーが発生します。

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

このエラーの意味Error:path not null or empty string。path = 'null'これがbuild.gradleです:

signingConfigs {
            release {
                storeFile file('/home/rishabh/Documents/dekhoJks/release.jks')
                storePassword "XXXXXXX"
                keyAlias "XXXXXXXX"
                keyPassword "XXXXXXXXX"
            }
        }
        buildTypes {
            release {
                minifyEnabled true
                //proguardFiles fileTree(dir: "proguard", include: ["*.pro"]).asList().toArray()
                proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
                shrinkResources true
                signingConfig signingConfigs.release
            }
        }

そして、私はproguard.proに入れることができるすべてのいまいましいものを入れようとしました:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-dump class_files.txt
-printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-allowaccessmodification
-keepattributes *Annotation*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-repackageclasses ''

-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 * extends Android.app.backup.BackupAgentHelper
-keep public class * extends Android.preference.Preference
-keep public class com.Android.vending.licensing.ILicensingService
-dontnote com.Android.vending.licensing.ILicensingService

# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
-keepclassmembers class * implements Java.io.Serializable {
    static final long serialVersionUID;
    private static final Java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(Java.io.ObjectOutputStream);
    private void readObject(Java.io.ObjectInputStream);
    Java.lang.Object writeReplace();
    Java.lang.Object readResolve();
}

# Preserve all native method names and the names of their classes.
-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);
}

# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.
-keepclassmembers class **.R$* {
  public static <fields>;
}

# Preserve the special static methods that are required in all enumeration classes.
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(Java.lang.String);
}

-keep public class * {
    public protected *;
}

-keep class * implements Android.os.Parcelable {
  public static final Android.os.Parcelable$Creator *;
}
##---------------End: proguard configuration common for all Android apps ----------

#---------------Begin: proguard configuration for support library  ----------
-keep class Android.support.v4.app.** { *; }
-keep interface Android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn Android.support.**
-dontwarn com.google.ads.**
##---------------End: proguard configuration for Gson  ----------

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class Sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.example.model.** { *; }

##---------------End: proguard configuration for Gson  ----------

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}




-keepclassmembers class Android.support.design.internal.BottomNavigationMenuView {
    boolean mShiftingMode;
}

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

# Basic ProGuard rules for Firebase Android SDK 2.0.0+
-keep class com.firebase.** { *; }
-keep class org.Apache.** { *; }
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class javax.servlet.** { *; }
-keepnames class org.ietf.jgss.** { *; }
-dontwarn org.Apache.**
-dontwarn org.w3c.dom.**

-dontwarn com.firebase.ui.**

-keepattributes Signature

-dontwarn com.googlecode.mp4parser.**
-dontwarn org.mp4parser.aspectj.runtime.reflect.**
-keep class * implements com.coremedia.iso.boxes.Box { *; }
-dontwarn com.coremedia.iso.boxes.**
-dontwarn com.googlecode.mp4parser.authoring.tracks.mjpeg.**
-dontwarn com.googlecode.mp4parser.authoring.tracks.ttml.**

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

しかし、それでも私のアプリを実行できません。私が間違っているところならどんな助けでも。

11
Rishabh Chandel

さて、解決策を得ました。ハードコードされた署名設定を置き換えるだけです:

release {
                storeFile file('/home/rishabh/Documents/dekhoJks/release.jks')
                storePassword "XXXXXXX"
                keyAlias "XXXXXXXX"
                keyPassword "XXXXXXXXX"
            }

その代わりに、個別のsigning.propertiesファイルを作成します。

STORE_FILE=/home/XXX/XXX/XXX
STORE_PASSWORD=XXXXXX
KEY_ALIAS=XXXXXXXX
KEY_PASSWORD=XXXXXXXXX

enter image description here

そしてあなたのグラドルで使用してください。それが役に立てば幸い!!

1
Rishabh Chandel

2つのソリューション

  • 次のクラスパスを使用します。 (バージョン2.3.2を使用していたときに、このエラーが発生しました。)

    classpath 'com.Android.tools.build:gradle:2.2.2'

  • クラスパスのバージョンを変更できない場合は、一時的な修正のためにsplit apkオプションを無効にします。

1
Varun Bhatia