Android app crashes: why exists (Unknown source) instead of line number

My application that I built and signed up to periodically post crashes on my machine, in logcat, I open stacktrace to exclude a null pointer. But I can not find the exact line numbers? because it says (Unknown source) for example, some lines look like this:

Caused by: java.lang.NullPointerException at me.com.myapplication.aid(Unknown Source) at me.com.myapplication.MainActivity.onResume(Unknown Source) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1210) 

As you can see, somewhere there is my application package, I do not see line numbers, instead it says Unknown source.

Here is my gradle config for this project.

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "me.com.myappliaction" minSdkVersion 8 targetSdkVersion 21 versionCode 6 versionName "2.0" } signingConfigs { signed { storeFile file('../keystore/my.keystore') storePassword 'xxxxxx' keyAlias 'xxxxx' keyPassword 'xxxxxx' } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } signed { debuggable false minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.signed } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile project(':mycomponent') } 

The application used a version of the signed assembly. I used the proguard command to read the trace correctly using the following syntax

 retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>] 

after these class names are shown better, but still the line numbers? I am wondering what exactly is wrong here, which leads to the lack of line numbers? How can I get a trace that shows the line numbers in my code and is still ready to make it ready for publication?

+5
source share
3 answers

To save debugging information after building ProGuard, you need to add the following configuration (to the proguard-rules.pro file):

 -keepattributes SourceFile,LineNumberTable # rename the source files to something meaningless, but it must be retained -renamesourcefileattribute '' 
+6
source

You can also download the mapping.txt file to the Google Play Developer Console. On the console, just click on the application you want to de-bass. Then go to Android vitals> ANRs and Crashes:

https://play.google.com/apps/publish/?dev_acc=[YOUR-DEV_ID†#DeobfuscationMappingFilesPlace:p=[your.app.package]

and download the mapping.txt file corresponding to the current version of your application.

Location map.txt:

Android Studio:

\ [YOUR-PROJECT-DIR] \ application \ build \ outputs \ display \ release \ mapping.txt

Eclipse:

\ [ECLIPSE-WORKSPACE] \ [YOUR-PROJECT-DIR] \ ProGuard \ mapping.txt

Beware: Errors are only dereferenced AFTER map.txt is loaded. There is no deobfusion of already registered crashes in the Google Play Developer Console.

+1
source

This error occurs if you enable the minify parameter in build.gradle .

 minifyEnabled true 

To get the line number when using proguard, you should write the following line inside proguard-rules.pro

 -keepattributes *Annotation*,SourceFile,LineNumberTable 

and you're done.

0
source

All Articles