-1

I am getting java.lang.NullPointerException: name is null when i am enabling proguard in debug mode, my app is working fine in debug mmode when i am using without proguard . here is the snippet i am using to enable proguard

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

here is error log which i am getting

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) 
Rohit Maurya
  • 730
  • 1
  • 9
  • 22
  • feel free to click on first `Unknown Source` in `at com.byteapp.postearnmoney.b.a.a(Unknown Source)` to check where the exception appear and provide some code – Selvin May 08 '18 at 13:12
  • post your app module build.gradle please – Linh Nguyen May 08 '18 at 13:15
  • by the way if you look closely there is the reason for this exception. In your log it clearly says that this exception is caused due to service time out. and you got null as a result. – Umair May 08 '18 at 13:16
  • @Selvin `Unknown Source` is not Clickable – Rohit Maurya May 08 '18 at 13:30
  • 1
    you have code like `String name = null;` and then `Resources.getIdentifier(name, ....)` and that's why you are getting NPE ... – Selvin May 08 '18 at 13:58
  • Thank you @Selvin , i was doing that same mistake which you mentioned, I solved it by adding `@Keep` annotation on model class. – Rohit Maurya May 08 '18 at 14:47

1 Answers1

-1

you may need to add this shrinkResources true shink-code

Resource shrinking works only in conjunction with code shrinking. After the code shrinker removes all unused code, the resource shrinker can identify which resources the app still uses. This is especially true when you add code libraries that include resources—you must remove unused library code so the library resources become unreferenced and, thus, removable by the resource shrinker.

Linh Nguyen
  • 1,264
  • 1
  • 10
  • 22
  • how this would help? – Selvin May 08 '18 at 13:31
  • again *how this would help?* it will cut unused resources ... how this would fix his NPE ? – Selvin May 08 '18 at 13:48
  • try to read it carefully please @Selvin "the resource shrinker can identify which resources the app still uses", because Proguard may remove the resources what make NPE – Linh Nguyen May 08 '18 at 13:49
  • try to read it with understanding ... not using it (like he does) it will not remove unused resources ... using this option(shrinkResources true) will remove unused resources ... HOW THIS WOULD HELP ... **ProGuard shrinks CODE ONLY** – Selvin May 08 '18 at 13:52
  • he has some code like `String name = null;` and then `Resources.getIdentifier(name, ....)` and that's why he is getting NPE ... shrinking resource has nothing to do with that – Selvin May 08 '18 at 13:57