私は自分のアプリケーションを行っていますが、私はretrofit、rxJava、retrofit:converter-gsonを使用しています.ProGuardを使用してアプリケーションを保護することに決めました。proguard-android.txtをproguard-アプリケーションがエラーを受信:ProGuardの後、アプリケーションがクラッシュし、何が原因なのか理解するのに役立ちますか?
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.OpenOption
Warning:okio.Okio: can't find referenced class java.nio.file.Path
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.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
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.OpenOption
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Warning:there were 67 unresolved references to classes or interfaces.
Warning:rx.internal.util.unsafe.UnsafeAccess: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpscUnboundedArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpscArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpmcArrayQueueProducerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpmcArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.MpscLinkedQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.MpmcArrayQueueProducerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.ConcurrentSequencedCircularArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef: can't find referenced class sun.misc.Unsafe
Warning:retrofit.Platform$Java8: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:retrofit.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle
Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:retrofit.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup
Warning:retrofit.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle
Warning:retrofit.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles
Warning:retrofit.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles
Warning:retrofit.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup
Warning:rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.ConcurrentCircularArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.MpmcArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details
私はちょうど-dontwarnを使用する場合は、アプリケーションがエラーでクラッシュします:
02-22 19:38:16.998 31147-31147/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 31147
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.example.myapplication.b.c.c()' on a null object reference
at com.example.myapplication.c.b$b.a(Unknown Source)
at com.example.myapplication.c.b.a(Unknown Source)
at android.support.v7.widget.RecyclerView$a.a(Unknown Source)
at android.support.v7.widget.RecyclerView$a.b(Unknown Source)
at android.support.v7.widget.RecyclerView$n.a(Unknown Source)
at android.support.v7.widget.RecyclerView$n.c(Unknown Source)
at android.support.v7.widget.LinearLayoutManager$c.a(Unknown Source)
at android.support.v7.widget.GridLayoutManager.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.c(Unknown Source)
at android.support.v7.widget.GridLayoutManager.c(Unknown Source)
at android.support.v7.widget.RecyclerView.J(Unknown Source)
at android.support.v7.widget.RecyclerView.k(Unknown Source)
at android.support.v7.widget.RecyclerView.onLayout(Unknown Source)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.support.v4.widget.SwipeRefreshLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.support.v4.view.ViewPager.onLayout(Unknown Source)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2198)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1958)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1134)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6045)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860)
at android.view.Choreographer.doCallbacks(Choreographer.java:672)
at android.view.Choreographer.doFrame(Choreographer.java:608)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityTh
ProGuardの:
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
# 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.**
# Understand the @Keep support annotation.
-keep class android.support.annotation.Keep
-keep @android.support.annotation.Keep class * {*;}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <init>(...);
}
私のGradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:recyclerview-v7:24.1.0'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.pacioianu.david:ink-page-indicator:1.2.0'
compile 'io.reactivex:rxjava:1.1.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
}
私を助けてください!改造、rxjava、okio、ピカソ、サポート-V7-APPCOMPAT、butterknife-7:
は、私はすべてが働いてい を解決し、私はスニペット(https://github.com/krschultz/android-proguard-snippets)を追加しました。
## --------------- Start Project specifics --------------- ##
-keep class com.example.yourapp.model.Yourmodel{ *; }
-keep class com.example.yourapp.model.Yourmodel{ *; }
-keep class com.example.yourapp.model.Yourmodel{ *; }
# Keep the BuildConfig
-keep class com.example.BuildConfig { *; }
# Keep the support library
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.** { *; }
# Application classes that will be serialized/deserialized over Gson
# or have been blown up by ProGuard in the past
## ---------------- End Project specifics ---------------- ##
そして、私のGradleは、次のようになります:私はproguard-rules.pro追加あなたのProGuardの規則にこれを追加すること
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.application"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFile 'proguard-rx-java.pro'
proguardFile 'proguard-square-retrofit.pro'
proguardFile 'proguard-square-picasso.pro'
proguardFile 'proguard-square-okio.pro'
proguardFile 'proguard-butterknife-7.pro'
proguardFile 'proguard-support-v7-appcompat.pro'
proguardFile 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:recyclerview-v7:24.1.0'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.pacioianu.david:ink-page-indicator:1.2.0'
compile 'io.reactivex:rxjava:1.1.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
}
私はコード –
...あなたの完全なコードを追加します。ヌルオブジェクトを指すStringメソッドがある場合は、lang.String com.example.myapplication.bcc() 'をnullオブジェクト参照で使用します。 – 2Ra66it
あなたの問題はここに 'java.lang.NullPointerExceptionがある置くことができない、これは非常に大きなプロジェクトです –