java.lang.NoSuchFieldError: com.banwxf.shoplibrary.R$id.pager_gv

报错详细日志:

03-28 18:14:41.525 3561-3561/com.banwxf.client E/AndroidRuntime: FATAL EXCEPTION: main
                                                                 Process: com.banwxf.client, PID: 3561
                                                                 java.lang.NoSuchFieldError: com.banwxf.shoplibrary.R$id.pager_gv
                                                                     at com.banwxf.shoplibrary.ui.ShopActivity.onCreate(ShopActivity.java:61)
                                                                     at android.app.Activity.performCreate(Activity.java:5231)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2157)
                                                                     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2035)
                                                                     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
                                                                     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
                                                                     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:749)
                                                                     at android.widget.TabHost.setCurrentTab(TabHost.java:413)
                                                                     at android.widget.TabHost.setCurrentTabByTag(TabHost.java:287)
                                                                     at com.banwxf.mainlibrary.ui.activity.MainActivity$2.onCheckedChanged(MainActivity.java:58)
                                                                     at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
                                                                     at android.widget.RadioGroup.access$600(RadioGroup.java:54)
                                                                     at android.widget.RadioGroup$CheckedStateTracker.onCheckedChanged(RadioGroup.java:358)
                                                                     at android.widget.CompoundButton.setChecked(CompoundButton.java:130)
                                                                     at android.widget.CompoundButton.toggle(CompoundButton.java:87)
                                                                     at android.widget.RadioButton.toggle(RadioButton.java:76)
                                                                     at android.widget.CompoundButton.performClick(CompoundButton.java:99)
                                                                     at android.view.View$PerformClick.run(View.java:18422)
                                                                     at android.os.Handler.handleCallback(Handler.java:733)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                     at android.os.Looper.loop(Looper.java:136)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5019)
                                                                     at java.lang.reflect.Method.invokeNative(Native Method)
                                                                     at java.lang.reflect.Method.invoke(Method.java:515)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                                                     at dalvik.system.NativeStart.main(Native Method)

java.lang.NoSuchFieldError: com.banwxf.shoplibrary.R$id.pager_gv_第1张图片

问题分析:

从报错栈信息来看         java.lang.NoSuchFieldError: com.banwxf.shoplibrary.R$id.pager_gv   是这个ID找不见

但我们在android studio中点击是可以连接过去的,这是为什么呢

 

其实很简单,就是我们这个id.pager_gv所在的布局文件和别的布局文件名称重复了。这种问题多发生与组件化开发的过程中

 

这个错误说的不是ID找不见,二是布局文件被前一个布局文件占用,在第一个布局文件中没有找到

 

解决办法:

重命名当前这个布局文件名称

你可能感兴趣的:(android,app,android,studio,java)