i get this message error when i build my app in release mode.
No pending exception expected: java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "amplitudes" in class "Llinc/com/amplituda/AmplitudaResultJNI;" or its superclasses.
But app correctly works on Dev build. What should i do?
gradle file
implementation 'com.github.lincollincol:amplituda:2.1.2'
proguard-rules.pro
-keep class linc.com.amplituda.** { *; }
Thanks
Related
When invoking FirebaseFunctions.getInstance(FirebaseApp.getInstance()) an NPE is thrown. FirebaseApp.initializeApp(this); is called inside extended App class onCreate before calling any other firebase functionality.
This is the stacktrace:
Fatal Exception: java.lang.NullPointerException
at com.google.firebase.functions.internal.Preconditions.checkNotNull(Unknown Source:876)
at com.google.firebase.functions.FirebaseFunctions.<init>(Unknown Source:77)
at com.google.firebase.functions.FirebaseFunctions.getInstance(Unknown Source:141)
at com.google.firebase.functions.FirebaseFunctions.getInstance(Unknown Source:159)
The exception is thrown only when building the application with release configuration, this means the code gets obfuscated with DexGuard but all firebase classes have been excluded from the obfuscation, below my dexguard config:
...
-keep class com.google.** { *; }
-keep class android.** { *; }
-keep class com.firebase.** { *; }
-keep class com.android.** { *; }
...
I'm using:
com.google.firebase:firebase-functions:12.0.1 (also all other firebase libraries use the same version)
DexGuard version 8.1.15
classpath 'com.google.gms:google-services:4.0.1'
When using debug configuration everything works like charm, any idea how to solve this?
Already checked this similar question but it's outdated: Error with Firebase callable functions
EDIT - New configuration
I tried updating both DexGuard dependency and Firebase one with the ones below:
com.google.firebase:firebase-functions:16.1.1 (all other firebase and gms dependencies are updated to the latest one, except for play-services-ads that is 16.0.0)
DexGuard version 8.2.20
classpath 'com.google.gms:google-services:4.0.1'
This is the new stacktrace:
Fatal Exception: java.lang.NullPointerException: null reference
at com.google.firebase.functions.a.a.a(Unknown Source:30)
at com.google.firebase.functions.FirebaseFunctions.(Unknown Source:77)
at com.google.firebase.functions.FirebaseFunctions.getInstance(Unknown Source:141)
at com.google.firebase.functions.FirebaseFunctions.getInstance(Unknown Source:154)
For the ones who may face the same problem, it was caused by the "projectId" field being null when the FirebaseOptions were initialised by the sdk using FirebaseOptions.fromResource(Context) and the app was protected with DexGuard
FirebaseOptions {
applicationId = ***********************,
apiKeyapiKey = ***********************,
databaseUrl = ***********************,
gcmSenderId = ***********************,
storageBucket = ***********************,
projectId = null
}
The problem has been solved by adding the following line to the DexGuard config file:
-keepresources string/project_id
My android app uses Pushy.me Push notification service, i have built the signed apk with minifyEnabled true and when i run the app i am getting below error
org.apache.commons.logging.LogConfigurationException: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'org.apache.commons.logging.b'.
i have added below lines in proguard-rules.pro file, but it shows same error
-dontwarn me.pushy.**
-keep class me.pushy.** { *; }
-dontwarn org.apache.commons.logging.**
This worked for me
-keep class org.apache.** { *; }
I'm Using FCM with Dexguard.
FCM cannot make token in release build.
but, it works well in debug build.
my gradle settings
classpath 'com.google.gms:google-services:3.2.1'
compile 'com.google.android.gms:play-services-base:15.0.2'
compile 'com.google.android.gms:play-services-analytics:15.0.2'
compile 'com.google.firebase:firebase-core:15.0.2'
compile 'com.google.firebase:firebase-messaging:15.0.2'
And, ShrinkResources = false And optimize 5time by Dexguard
gradle version : 4.1
android gradle plugin : 2.3.3
options in dexguardFile related with FCM
-keep public class com.google.firebase.** { *; }
-keep public class com.google.firebase.iid.FirebaseInstanceId { public *;}
Firebase 15+ requires some additional rules. The latest DexGuard version 8.2.09 for example includes all necessary configurations.
Add the following dexguard rules to fix the problem:
-keep class com.google.firebase** { *; }
-dontshrink
It seems that dexguard removes all classes that are not directly referenced in code. So the entry points like services classes to get firebase tokens (FirebaseInstanceIdService) will be removed during obfuscation process, if shrinking is allowed.
I had similar issues with Firebase analytics where it works for debug build but not the release build, thanks to T. Neidhart's answer above I found this block from the Dexguard 8.4.13 sample - samples/advanced/GooglePlayServices/AdMob/dexguard-project.txt and it solves the problem for me.
-keep public class !**.internal.**, com.google.** {
public protected *;
}
# We can repackage all obfuscated classes in a new internal package.
-repackageclasses com.google.internal
My app is completely ready to deploy and its using many libraries. I want to minify the code using Proguard and also want to remove unused classes and resources but while using proguard I am getting Runtime error
java.lang.RuntimeException: Unable to create application com.rig.onblick.App: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
I gone through many tutorial but its seems too complicated to write proguard configuration because I have to write many rules to make sure my app will run perfectly. I have never used proguard in this kind of big project. Can anyone tell me the minimal configuration which make sure at least my code will be minified and will not get any runtime error.
My present configuration is as below.
-dontwarn com.witt.mspapp.**
-keep class com.github.mikephil.** { *; }
-dontwarn com.github.mikephil.**
-keep class com.github.mikephil.** { *; }
-dontwarn org.apache.**
-keep class com.google.gms.** { *; }
-dontwarn com.google.gms.**
-keep class com.viewpagerindicator.** { *; }
-dontwarn com.viewpagerindicator.**
-keep class org.jivesoftware.smackx.** { *; }
-dontwarn org.jivesoftware.smackx.**
I am testing in debug env. and my gradle configuration is as below
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
There is nothing "minimal configuration" for proguard configuration. You will get the proguard configuration for each library on his official repo page. So whatever dependencies you have used go through these and add proguard configuration for each of that dependency.
Link to project - File manager
After i'm enabling obfuscation, application crash, when i try to show fragment from library project that use data binding.
Error:
java.lang.NoClassDefFoundError: Failed resolution of: Lcorp/wmsoft/android/lib/filemanager/databinding/WmFmFileManagerViewLayoutBinding;
at corp.wmsoft.android.lib.filemanager.ui.widgets.nav.a.onCreateView(Unknown Source)
But Android Studio->Build->Analyze APK, show that i have this class inside APK:
library project proguard-rules.pro:
-dontwarn android.databinding.**
-keep class android.databinding.** { *; }
-keep class corp.wmsoft.android.lib.filemanager.databinding.** { *; }
Please help to solve this problem.