java.lang.NullPointerException:当proguard启用时,name为null

时间:2018-05-08 13:10:20

标签: java android nullpointerexception android-proguard

当我在调试模式下启用proguard时,我得到java.lang.NullPointerException: name is null,当我在没有proguard的情况下使用时,我的应用程序在调试mmode中工作正常。这是我用来启用proguard的片段

debug{
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

这是我得到的错误日志

java.lang.NullPointerException: name is null
        at android.content.res.Resources.getIdentifier(Resources.java:3708)
        at com.byteapp.postearnmoney.b.a.a(Unknown Source)
        at com.byteapp.postearnmoney.b.a.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$p.a(Unknown Source)
        at android.support.v7.widget.RecyclerView$p.a(Unknown Source)
        at android.support.v7.widget.RecyclerView$p.a(Unknown Source)
        at android.support.v7.widget.RecyclerView$p.c(Unknown Source)
        at android.support.v7.widget.LinearLayoutManager$c.a(Unknown Source)
        at android.support.v7.widget.LinearLayoutManager.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.RecyclerView.N(Unknown Source)
        at android.support.v7.widget.RecyclerView.onMeasure(Unknown Source)
        at android.view.View.measure(View.java:20236)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
        at android.view.View.measure(View.java:20236)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.view.View.measure(View.java:20236)
        at android.support.v4.widget.DrawerLayout.onMeasure(Unknown Source)
        at android.view.View.measure(View.java:20236)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
        at android.view.View.measure(View.java:20236)
        at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:716)
        at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:462)
        at android.view.View.measure(View.java:20236)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.support.v7.widget.ContentFrameLayout.onMeasure(Unknown Source)
        at android.view.View.measure(View.java:20236)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
        at android.view.View.measure(View.java:20236)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.view.View.measure(View.java:20236)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
        at android.view.View.measure(View.java:20236)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:3140)
        at android.view.View.measure(View.java:20236)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2704)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1656)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1948)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1544)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7607)
        at android.view.Choreographer$CallbackRe
05-08 18:12:58.646 24073-24535/com.byteapp.postearnmoney E/File: fail readDirectory() errno=2
    fail readDirectory() errno=2
05-08 18:13:04.586 24073-24453/com.byteapp.postearnmoney E/Ads: Fail to get isAdIdFakeForDebugLogging
    java.io.IOException: java.util.concurrent.TimeoutException: Timed out waiting for the service connection
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):202)
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):20)
        at com.google.android.gms.ads.identifier.a.b(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):148)
        at com.google.android.gms.ads.internal.util.d.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):6)
        at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):4)
        at com.google.android.gms.ads.internal.util.m.call(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3)
        at com.google.android.gms.ads.internal.util.n.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.util.concurrent.TimeoutException: Timed out waiting for the service connection
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):189)
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):20) 
        at com.google.android.gms.ads.identifier.a.b(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):148) 
        at com.google.android.gms.ads.internal.util.d.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):6) 
        at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):4) 
        at com.google.android.gms.ads.internal.util.m.call(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3) 
        at com.google.android.gms.ads.internal.util.n.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3) 
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
        at java.lang.Thread.run(Thread.java:818) 
05-08 18:13:04.996 24073-24484/com.byteapp.postearnmoney E/Ads: Fail to get isAdIdFakeForDebugLogging
    java.io.IOException: java.util.concurrent.TimeoutException: Timed out waiting for the service connection
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):202)
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):20)
        at com.google.android.gms.ads.identifier.a.b(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):148)
        at com.google.android.gms.ads.internal.util.d.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):6)
        at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):4)
        at com.google.android.gms.ads.internal.util.m.call(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3)
        at com.google.android.gms.ads.internal.util.n.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.util.concurrent.TimeoutException: Timed out waiting for the service connection
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):189)
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):20) 
        at com.google.android.gms.ads.identifier.a.b(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):148) 
        at com.google.android.gms.ads.internal.util.d.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):6) 
        at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):4) 
        at com.google.android.gms.ads.internal.util.m.call(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3) 
        at com.google.android.gms.ads.internal.util.n.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3) 
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
        at java.lang.Thread.run(Thread.java:818) 
05-08 18:13:05.276 24073-24495/com.byteapp.postearnmoney E/Ads: Fail to get isAdIdFakeForDebugLogging
    java.io.IOException: java.util.concurrent.TimeoutException: Timed out waiting for the service connection
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):202)
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):20)
        at com.google.android.gms.ads.identifier.a.b(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):148)
        at com.google.android.gms.ads.internal.util.d.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):6)
        at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):4)
        at com.google.android.gms.ads.internal.util.m.call(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3)
        at com.google.android.gms.ads.internal.util.n.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.util.concurrent.TimeoutException: Timed out waiting for the service connection
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):189)
        at com.google.android.gms.ads.identifier.a.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):20) 
        at com.google.android.gms.ads.identifier.a.b(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):148) 
        at com.google.android.gms.ads.internal.util.d.a(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):6) 
        at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):4) 
        at com.google.android.gms.ads.internal.util.m.call(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3) 
        at com.google.android.gms.ads.internal.util.n.run(:com.google.android.gms.dynamite_dynamitemodulesa@12529019@12.5.29 (040306-192802242):3) 
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
        at java.lang.Thread.run(Thread.java:818) 

1 个答案:

答案 0 :(得分:-1)

您可能需要添加此shrinkResources true shink-code

  

资源缩减仅适用于代码收缩。在代码缩减器删除所有未使用的代码之后,资源缩减器可以识别应用程序仍在使用哪些资源。添加包含资源的代码库时尤其如此 - 必须删除未使用的库代码,以便库资源不会被引用,从而可以被资源缩减器移除。