Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to detect the line number in logcat Android Studio

Android Studio 2.2.3

Android Studio is not able to detect the line number in logcat. Is there any way to solve this? It show Unknown Source in place of line no.

LOGCAT is added just the shake of pointing what is the issue. Not to point why NULL POINT EXCEPTION occuring...

Please ignore the error( I know why it is occurring ). I have added the logout to show what is problem.

Android studio is showing Unknown Source instead of error line number.

Logcat:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: user.com.hlthee, PID: 1107
                  java.lang.NullPointerException
                      at user.com.hlthee.Reminders$13.onClick(**Unknown Source**)
                      at android.support.v7.app.AlertController$ButtonHandler.handleMessage(Unknown Source)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5001)
                      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:785)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                      at dalvik.system.NativeStart.main(Native Method)
like image 933
Ankur Khandelwal Avatar asked Dec 26 '16 09:12

Ankur Khandelwal


1 Answers

If it is your class(Not a library) you are missing a view in your XML connected to the class. It says as NullPointerException - onClick(**Unknown Source)** meaning in your class you probably used onclick funtion for that view but the view is not in the XML. Find where you added onClicks in your class and see which one is not present in your connected XML

Edit :

This Unknown Source can occur if you do not have a proper naming conventions for your package name and package tag in your manifest like below

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="string"
          android:sharedUserId="string"
          android:sharedUserLabel="string resource" 
          android:versionCode="integer"
          android:versionName="string"
          android:installLocation=["auto" | "internalOnly" | "preferExternal"] >
    . . .
</manifest> 

So you can double check your activity tag as well and follow naming conventions. You might have a name something like this ..Reminders$13

enter image description here

A full Java-language-style package name for the Android application. The name should be unique. The name may contain uppercase or lowercase letters ('A' through 'Z'), numbers, and underscores ('_'). However, individual package name parts may only start with letters. To avoid conflicts with other developers, you should use Internet domain ownership as the basis for your package names (in reverse). For example, applications published by Google start with com.google. You should also never use the com.example namespace when publishing your applications.

From developer.android.com

like image 149
Charuක Avatar answered Oct 13 '22 02:10

Charuක