Error Message:
2018-12-16 11:08:28.339 7163-7163/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: <package_name>, PID: 7163
java.lang.NumberFormatException: null
at java.lang.Long.parseLong(Long.java:406)
at java.lang.Long.parseLong(Long.java:485)
at <package_name>.view.user.main.a.b.b.a(Unknown Source)
at androidx.recyclerview.widget.RecyclerView$a.a(Unknown Source)
at androidx.recyclerview.widget.RecyclerView$o.a(Unknown Source)
at androidx.recyclerview.widget.RecyclerView$o.a(Unknown Source)
at androidx.recyclerview.widget.RecyclerView$o.b(Unknown Source)
at androidx.recyclerview.widget.LinearLayoutManager$c.a(Unknown Source)
at androidx.recyclerview.widget.LinearLayoutManager.a(Unknown Source)
at androidx.recyclerview.widget.LinearLayoutManager.a(Unknown Source)
at androidx.recyclerview.widget.LinearLayoutManager.c(Unknown Source)
at androidx.recyclerview.widget.RecyclerView.D(Unknown Source)
at androidx.recyclerview.widget.RecyclerView.y(Unknown Source)
at androidx.recyclerview.widget.RecyclerView.onLayout(Unknown Source)
at android.view.View.layout(View.java:17666)
at android.view.ViewGroup.layout(ViewGroup.java:5577)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17666)
at android.view.ViewGroup.layout(ViewGroup.java:5577)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17666)
at android.view.ViewGroup.layout(ViewGroup.java:5577)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:17666) at android.view.ViewGroup.layout(ViewGroup.java:5577) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17666) at android.view.ViewGroup.layout(ViewGroup.java:5577) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17666) at android.view.ViewGroup.layout(ViewGroup.java:5577) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17666) at android.view.ViewGroup.layout(ViewGroup.java:5577) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17666) at android.view.ViewGroup.layout(ViewGroup.java:5577) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17666) at android.view.ViewGroup.layout(ViewGroup.java:5577) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:730) at android.view.View.layout(View.java:17666) at android.view.ViewGroup.layout(ViewGroup.java:5577) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2390) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2112) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1298) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6437) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:876) at android.view.Choreographer.doCallbacks(Choreographer.java:688) at android.view.Choreographer.doFrame(Choreographer.java:623) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:862) at android.os.Handler.handleCallback(Handler.java:754)
I am getting the above error when I use minifyEnabled=true
in release build.
Building same project in release build with minifyEnabled=false
doesn't create the error.
The error doesn't appear on app launch,it appears on showing a fragment.
proguard-rules.pro:
-assumenosideeffects class android.util.Log {
public static *** d(...);
}
build.gradle(app) (used libraries):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "my.package.id"
minSdkVersion 19
targetSdkVersion 28
versionCode 3
versionName "0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
debug {
minifyEnabled true
debuggable true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Testing
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
// Support library
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// Architecture components
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
// Ads
implementation 'com.google.android.gms:play-services-ads:17.1.2'
// Firebase
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-firestore:17.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-invites:16.0.6'
implementation 'com.google.firebase:firebase-dynamic-links:16.1.5'
// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
// Circular imageView
implementation 'com.mikhaellopez:circularimageview:3.2.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
// About libraries
implementation 'com.mikepenz:aboutlibraries:6.2.0'
}
Edit 1: In the fragment which crashes,I have a RecyclerView which uses a custom adapter in which the following line of code is used:
viewHolder.userOrderRecyclerViewItemDateTv.setText(MyDateUtils.getDateStringFromLong(Long.parseLong(order.getOrderDate())));
MyDateUtils.java:
public class MyDateUtils {
private static String calenderToDateString(Calendar calendar) {
// Convert calender object to date string
return String.format(Locale.ENGLISH, "%02d - %02d - %04d",
(calendar.get(Calendar.DAY_OF_MONTH)), (calendar.get(Calendar.MONTH) + 1),
calendar.get(Calendar.YEAR));
}
public static String getDateStringFromLong(long dateLong) {
// Create a new calender instance
Calendar calendar = Calendar.getInstance();
// Set calender time to given value
calendar.setTimeInMillis(dateLong);
// Return calender as date in string format
return calenderToDateString(calendar);
}
}
Long.parseLong((String) null);
... with that amount of libraries, there might be a quite a bunch of proguard rules required, nevertheless. – Martin Zeitler