PackageManager: Package signatures do not match the previously installed version; ignoring!

Issue Details:  signatures do not match the previously installed version; ignoring!
Mainly this issue happens when you try to install app with the same package name but not signed with the same Key-store file.

Steps how issue generated:
1) Installed App from the Google Play (with Current App version 1.2 and version code 3004).
2) Use Android Studio and make new release APK having version 1.3 and version code 3005
3) I start update from app version(1.2) to version(1.3) to test whether app will update to new version 1.3 properly.
4) I come across blow error:

Here is the screenshot while updating my app installed from the Google Play (with Current App version 1.2) to New release APK (version 1.3).
It shows message App Not Installed

Android Studio Warning Log in Details:
11-18 11:49:03.466 1487-1518/? W/PackageManager: Package com.geekscompete.gate_isro_cs.ugc_net_preparation signatures do not match the previously installed version; ignoring!

Understanding Original APK, Derived APK, App Signing Certificate and Upload Certificate
Then, I followed common stuffs like invalidate and restart studio, clean project, and Make new release APK but No Luck!
I open Google Play Console and check if the SHA-1 generated from release keystore is same as the Upload Certificate SHA-1:
You can derive the SHA-1 for release apk after using below command:
keytool -list -v -keystore {keystore_name} -alias {alias_name}
SHA-1 from my release keystore and Upload Certificate SHA-1 is matching!

There is one other Certificate "App Signing Certificate" which Google Play uses to sign your app before distributing it to Android devices.

App Signing Certificate:
certificate for the app signing key that Google Play uses to sign your app before distributing it to Android devices. The app signing key itself is inaccessible and kept on a secure Google server. Use the certificate below to register your app signing key with your API providers.

Upload Certificate ():
certificate for the upload key that you hold privately. Use your upload key to sign each release so that Google Play knows the release comes from you. Use the certificate below to register your app signing key with your API providers for app testing purposes.

and After visiting my Google Play Console: Release Management -> App Signing
I have "OPT IN" for Google App Signing. : "App Signing by Google is enabled for this app".
If You have OPT-OUT of Google signing then your APK will not signed by the Google and Available apk to all users will be same as your uploaded APK to Google Play Console.

If you visit Google Developer account as mentioned below:
Release Management -> App Releases -> Production Track (Click manage)
And Click Latest APK download option -> You can see two option to Download APK files Original APK and Derived APK(If you have opt-in for Google Signing).

Original APK: APK file which you have uploaded after signing with the release Key-store (using .jks file) and upload it to the Google Play Console for making it live.
(Uses Upload Certificate to Verify new app version upload to Google Play Console)

Derived APK: This is the APK which is available to the users to download from Google Play Store after your app goes live.

Reasons for this issue is signatures mismatch:
APK download from Google Play Store is signed using App Signing Certificate.
Whereas release APK generated from Android Studio is using Upload Keystore file with .jks extension.

So, Signature of Upload Certificate and App Signing Certificate will not match.
Then I come across this amazing post:
Which gave Me Idea about APK Derived APK and Original APK, Signature mismatch:
https://readyandroid.wordpress.com/app-not-installedthe-package-conflicts-with-an-existing-package-by-the-same-name-android/

Derived APK -> https://stackoverflow.com/questions/44599767/google-maps-not-working-in-derived-apk-published-app#answer-49692374
For derive apk google introduce App singing feature. Google sign you apk agian, so you have to get App Sigining certificate's SHA1 and set it into Google Cloud Platform (wher you set your package name and SHA1)



Fatal Exception: java.lang.NoClassDefFoundError: android.app.ANRManagerProxy

Crashlytics Issue Details:

I come across this rarely found only 1 crash in last 90 days on device alps -> A3-7 PLUS DUO and on Android 4.2.2 (Android 4.2 Jelly Bean (API 17)) Operating Systems. I found detail of Crash Insights in Firebase Crashlytics and posting here.

Crash Log in Details :   java.lang.NoClassDefFoundError: android.app.ANRManagerProxy

Fatal Exception: java.lang.NoClassDefFoundError: android.app.ANRManagerProxy
android.app.ANRManagerNative.asInterface + 30 (ANRManagerNative.java:30)
android.app.ANRManagerNative$1.create + 94 (ANRManagerNative.java:94)
android.app.ANRManagerNative$1.create + 88 (ANRManagerNative.java:88)
android.util.Singleton.get + 34 (Singleton.java:34)
android.app.ANRManagerNative.getDefault + 37 (ANRManagerNative.java:37)
android.os.MessageLogger.dump + 253 (MessageLogger.java:253)
android.app.ANRAppManager.dumpMessageHistory + 38 (ANRAppManager.java:38)
android.app.ActivityThread$ApplicationThread.dumpMessageHistory + 1176 (ActivityThread.java:1176)
android.app.ApplicationThreadNative.onTransact + 609 (ApplicationThreadNative.java:609)
android.os.Binder.execTransact + 351 (Binder.java:351)
dalvik.system.NativeStart.run (NativeStart.java)

Reason For Such Crash report:

This issue is triggered when your app experiences an ANR on devices running custom firmware that is missing the ANRManagerProxy class. To mitigate this issue, look for areas in your code that may block the main thread for extended periods of time. Check out the first resource for more details.

I have set below code in MainActivity.java class:
So, that I can allow network calls, database read and write and other heavy work in Main (GUI) thread. See more on StrictMode.ThreadPolicy.Builder().permitAll().build()
public void onCreate() {
StrictMode.ThreadPolicy policy;
policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
}

Solution:

So. According to below reference its suggested to use the StrictMode.ThreadPolicy.Builder for Development and testing. Only thing you can do about this is to make your app responsive. Best way to do so is to use during development and testing Strict Mode, i.e., to do something like this:
public void onCreate() {
    if (DEVELOPER_MODE) {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
             .detectDiskReads()
             .detectDiskWrites()
             .detectNetwork()   // or .detectAll() for all detectable problems
             .penaltyLog()
             .build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
             .detectLeakedSqlLiteObjects()
             .detectLeakedClosableObjects()
             .penaltyLog()
             .penaltyDeath()
             .build());
    }
    super.onCreate();
}

Best reference:

https://stackoverflow.com/questions/29289641/noclassdeffounderror-android-app-anrmanagerproxy

More on StrictMode.ThreadPolicy.Builder:
Creates ThreadPolicy instances. Methods whose names start with detect specify what problems we should look for. Methods whose names start with penalty specify what we should do when we detect a problem.

You can call as many detect and penalty methods as you like. Currently order is insignificant: all penalties apply to all detected problems.

For example, detect everything and log anything that's found:
 StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
     .detectAll()
     .penaltyLog()
     .build();
 StrictMode.setThreadPolicy(policy);

[databinding] {"msg":"Missing import expression although it is registered

[kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding error(s):

[databinding] {"msg":"Missing import expression although it is registered","file":"/home/espl/Documents/Desktop/d2/ocd/ocdlive_3.0.7_live_i_android_x_call (2)/app/src/main/res/layout/item_notif.xml","pos":[]}

at android.databinding.tool.processing.Scope.assertNoError(Scope.java:111)
at android.databinding.annotationprocessor.ProcessDataBinding.doProcess(ProcessDataBinding.java:124)
at android.databinding.annotationprocessor.ProcessDataBinding.process(ProcessDataBinding.java:88)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:132)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$200(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.runContributingProcs(JavacProcessingEnvironment.java:627)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1033)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1198)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1068)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:80)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:36)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:223)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:187)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:98)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:96)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:106)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:82)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:384)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:70)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:375)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:123)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:131)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:54)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:103)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:442)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:102)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:1023)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:102)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:1065)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:1022)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:441)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Popular Posts