Reputation: 11
I am trying to work on this source code for android and it ran perfectly until I refactored the app to a different package name. No errors are showing in the package explorer and when I run it in debug mode this is what I get in logcat:
09-04 21:57:07.544: INFO/ActivityManager(58): Starting activity: Intent { cmp=com.dalimited.zs/.Snake } 09-04 21:57:07.683: DEBUG/AndroidRuntime(387): Shutting down VM 09-04 21:57:07.683: WARN/dalvikvm(387): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): FATAL EXCEPTION: main 09-04 21:57:07.734: ERROR/AndroidRuntime(387): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dalimited.zs/com.dalimited.zs.Snake}: android.view.InflateException: Binary XML file line #21: Error inflating class com.example.android.snake.SnakeView 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.os.Handler.dispatchMessage(Handler.java:99) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.os.Looper.loop(Looper.java:123) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.app.ActivityThread.main(ActivityThread.java:4627) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at java.lang.reflect.Method.invokeNative(Native Method) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at java.lang.reflect.Method.invoke(Method.java:521) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at dalvik.system.NativeStart.main(Native Method) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class com.example.android.snake.SnakeView 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.view.LayoutInflater.inflate(LayoutInflater.java:407) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.app.Activity.setContentView(Activity.java:1647) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at com.dalimited.zs.Snake.onCreate(Snake.java:50) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): ... 11 more 09-04 21:57:07.734: ERROR/AndroidRuntime(387): Caused by: java.lang.ClassNotFoundException: com.example.android.snake.SnakeView in loader dalvik.system.PathClassLoader[/data/app/com.dalimited.zs-1.apk] 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at java.lang.ClassLoader.loadClass(ClassLoader.java:573) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at java.lang.ClassLoader.loadClass(ClassLoader.java:532) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.view.LayoutInflater.createView(LayoutInflater.java:466) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565) 09-04 21:57:07.734: ERROR/AndroidRuntime(387): ... 20 more
My problem is: What is this logcat telling me? Where do I look in my code for my issue? And lastly is there information readily available to learn how to read the logcat?
Upvotes: 0
Views: 2661
Reputation: 3155
As you told in our question, it's not working after you refactored package name. If package name not refactored inside layout xml files, You manually need to update package names inside your layout xml file in which you are using SnakeView layout. After refactoring you must need to clean and re-build project.
Upvotes: 0
Reputation: 464
The trick to logcat is to look at the first major error (not indented doesn't start with "at" and is at the top of the list) then make sure u can read the entire line. 98% of the time it will tell you exactly what line to look at and will usually give some google searchable hint to the error. In your case the line read:
09-04 21:57:07.734: ERROR/AndroidRuntime(387): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dalimited.zs/com.dalimited.zs.Snake}: android.view.InflateException: Binary XML file line #21: Error inflating class com.example.android.snake.SnakeView
please make sure u scroll all the way over. You will see it tells you the error at the very end Binary XML file line #21: Error inflating class com.example.android.snake.SnakeView
Upvotes: 1
Reputation: 1
if your snake source code is from android developers page. Change snake_layout.xml file in line 21 with your new package name. Sorry for my english.
Upvotes: 0
Reputation: 1
ClassNotFoundError - project class path does not contain the new package name, refactoring did not work correctly in your IDE.
Upvotes: 0
Reputation: 6778
Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class com.example.android.snake.SnakeView
Check out your layout file. You are trying to create your CustomView. Does your SnakeView class extend View?
You can refer this link : http://www.anddev.org/creating_custom_views_-_the_togglebutton-t310.html
Upvotes: 1
Reputation: 681
Can you please tell what was your Package before you changed it to other name. Because I think this error is generating due to that, I think this because one of your error is class not found. You can also check your current package name which system (Eclipse) is considering for your application like this:
Content ctx = getApplicationContext();
Application app = ctx.getApplicationInfo();
Log.i("Tag", "Package Name :" + app);
I am telling you to do this because sometimes we change the package name of our application but eclipse is still considering the old one only. I may be wrong but try this I think this might going to work.
Upvotes: 0