Broken Android Launcher Shortcut due to Extending Application class - android

So in an effort to refactor my code I introduced a custom application class to my app by extending Application class and including 'android:name=".MyApp"' in the manifest:
<application
android:name=".MyApp"
android:hardwareAccelerated="true"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#style/AppBaseTheme" >
The problem I face is that this broke the launcher shortcut for a number of my users after they downloaded the update. Its an issue as some uninstall the app in confusion, this impacts my metrics.
Rolling back now isnt an option as it will break the shortcut again.
The reason why I believe its the addition of the name attribute in the application tag is because I am actually able to reproduce this consistently on a number of test devices. On some this creates a duplicate shortcut on the home screen and in the app drawer. And on others breaks the home screen shortcut and users see "App isnt installed" message.
Any advice or recommendations on how to deal with this? Thanks.

Related

Cordova app listed as 'webIntentFilter' under Android settings for Location permissions

I don't know when this occurred, but my app was always listed by MyAppName under the Android Phone Settings for Location Permissions - the settings section that specifies what apps are allowed to use location services (ie: always, only when in use, never, etc).
I discovered yesterday that in this section my app is no longer listed as MyAppName and is now listed as webIntentFilter - I was able to validate this on several Android phones, including my own. My app icon is correct, just the name is wrong.
In my config.xml:
<widget id="com.myAppName" ... >
<name>myAppName</name>
So, obviously some android:label: 'webIntentFilter' is overriding my config.xml app name.
I haven't a clue as to where this is originating from. I searched my entire project folder for files with the string webIntentFilter in them and got 17 hits across 12 files. But I don't know which one is causing the problem. I looked at all of them and none of them seem to be related to Location Services so I can't determine which is the culprit.
How can I fix this?
I found it....but I still have no idea how it happened, or how many revs of my app its been like this.
In projectFolder\platforms\android\app\src\main\AndroidManifest.xml was the main <application> section xml tag had the following:
<application
android:allowBackup="false"
android:fullBackupContent="false"
android:fullBackupOnly="false"
android:hardwareAccelerated="true"
android:icon="#mipmap/ic_launcher"
android:label="webIntentFilter" <----------------------------- here
android: name="androidx.multidex.MultiDexApplication"
.....
>
Changing it to: android:label="myAppName" fixed it.

An Android app remembers its data after uninstall and reinstall

While developing an Android app targeting all versions above 4.1, I observed that uninstalling my app and installing it again does not clear its data.
The app is designed to store the details that it asks in its first screen.
After uninstalling and installing again in OS version 4.4.4, the app prompts the user to fill in the data, which is normal. However in version 6.0 the same install/uninstall sequence bring backs the data originally input.
I tried to ensure by visiting /data/data/my package folder to see the database is gone after uninstalling and indeed that folder gets deleted during uninstall.
I tried to delete the app by visiting the settings page, through Titanium Backup and the results are same. The device is rooted Nexus 5 running v6.0.
What could be the reason for this strange behavior?
It's because Android 6 has automatic backup. You need to tune android:allowBackup and android:fullBackupContent in your manifest <application> tag if you don't want your data backed up or if you want to include or exclude some resources. It's not a bug.
More about AutoBackup on Android here.
greywolf82's answer is correct but I want to add some info to this.
When developing my Android app (using Xamarin), I noticed that whenever I'd re-launch the app from Visual Studio, my data would revert back to data from a few months ago. It didn't matter if I simply stopped and re-ran it from VS, or if I completely uninstalled the app and reinstalled it.
It's also worth noting that we never explicitly told the app to store a backup.
The backup also seemed to overwrite newer data when launching from Visual Studio, and we have reports of users using the release build of our app and also getting newer data overwritten by the backups.
Since I don't know exactly when backups and restores occur this feature seems to cause only problems.
We've modified our AndroidManifest by adding the following two lines:
android:allowBackup="false"
android:fullBackupOnly="false"
After adding them, our AndroidManifest contained the following xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.XXXXXXX" android:versionName="8.0.0" android:installLocation="auto" android:versionCode="439">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="24" />
<application
android:label="#string/appName"
android:icon="#drawable/icon_small"
android:installLocation="internalOnly"
android:largeHeap="true"
android:allowBackup="false"
android:fullBackupOnly="false"
/>
...
</manifest>
Once we explicitly set the value to false, all seems to work. I'd expect this to be an opt-in feature but...seems like it might be on by default for apps which don't specify the value either way.
You should check your device's Backup and Reset settings, and turn off Automatic restore (when reinstalling an application, backed up settings and data will be restored.)
Turning off auto-backup is different from the auto-restore. If you think it will be helpful to turn on auto-backup for your application do so. But if you think this will make end users who are not aware that the auto-restore feature of their device is turned on, feel free to turn it off.
In my case, I turned off the allowBackup feature, but since I already had a backup of the previous version on the Cloud, it still kept on restoring.
See image as reference for a Samsung device on Android 6.0. Other devices and versions may have a different screen. See image below.
Automatic Restore Setting under Backup and Reset
Just adding to this, we found that in Android 9 (on a HMD Nokia device) that the assets were held, even after deleting the app through the interface and through adb.
The answer of adding:
android:allowBackup="false"
android:fullBackupOnly="false"
Obviously, this is not a new answer - but an observation for people who were in the same position as us.
I recently needed to take advantage of these features, I was able to uncover documentation and upon extensive testing this is what I have been able to deduce:
Android:allowbackup - will backup local app data on the device it is located on.
Android:fullBackupContent - is used in conjunction with Google's backup restore api and CAN be controlled via an xml file to specify what exactly to backup, as well as a BackupManager class you may implement for further control over the process.
However the documentation states, and I have confirmed with testing, that a restore will only occur either when the device is restored and the restore app data process is triggered. OR it will also restore when the app is sideloaded through adb, which is what we do when we run the app for testing or debug on our devices through Android Studio. Note that if you set android:allowbackup but do not configure android:fullBackupContent with a Google api code then the apps data only gets stored locally, whereas if you configured it properly then if your app was backed up and you get a new device the apps data was stored on the cloud so it can be restored on a new device.
If you are targeting android 10 then you have to put android:hasFragileUserData="true" in application tag of AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name=".MyApplication"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:allowBackup="true"
android:hasFragileUserData="true">
.....
</application>
</manifest>
android:hasFragileUserData is a new manifest setting (I’m guessing on ). “If true the user is prompted to keep the app’s data on uninstall”. This seems ripe for abuse, but I can see where it might be useful for some apps.
See https://commonsware.com/blog/2019/06/06/random-musings-q-beta-4.html
Adding android:allowBackup="false" under application tag in Manifest file solved my issue.
Here goes the android documentation for Back up user data with Auto Backup
I also added:
tools:replace="android:allowBackup"
to override same option in a used component
This answer summarizes multiple other existing answers, and includes recent details as of Android 12 being introduced, and includes instructions for clearing existing app backup data generated from a device.
For more information, see
https://developer.android.com/guide/topics/data/autobackup#EnablingAutoBackup
https://developer.android.com/about/versions/12/behavior-changes-12#backup-restore
https://developer.android.com/guide/topics/manifest/application-element
http://android-doc.github.io/preview/backup/index.html (for clearing existing app backup data stored in Google Drive from a device: Settings > Backup > toggle Google One backup off then back on again, then try uninstall/reinstall again)
As a side note, some of the other answers suggest android:fullBackupContent="false" but that doesn't seem correct anymore since that is currently meant to specify an xml file of a specific format, not a true/false.
These attributes to <application> allow for disabling or configuring specifics for Android auto-backup functionality.
<application
tools:replace="android:label, android:icon, android:allowBackup, '...any other attribute you want to override with a value you set in this file for in case dependencies set them to other values...'"
'...your other attributes set here like android:label and android:icon...'
android:allowBackup="false" '...default is true, and setting this false prevents data backups of any kind (except device to device transfers if your app targets Android 11 (API 30) or higher)...'
android:fullBackupContent="#xml/backup_rules_android_11_and_below" '...optional, for Android 11 and below, referring to a file res/xml/backup_rules_android_11_and_below.xml you need to create...'
android:dataExtractionRules="#xml/backup_rules_android_12_and_above" '...optional, for Android 12 and above (fullBackupContent still needed along with this, assuming you support Android 11 and below), referring to a file res/xml/backup_rules_android_12_and_above.xml you need to create, with a slightly different required xml format...'
android:fullBackupOnly="false" '...optional, and default is false, but if set to true this field description says it enables auto backup on Android 6 (API 23) devices or higher (I am not sure how this matters compared to the more broadly reaching allowBackup)...'
android:hasFragileUserData="false" '...optional, and default is false, but if set to true this field description says it gives the user an option when they uninstall the app whether or not to backup their app data...'
>
'...contents of application element...'
</application>
The <application> changes only affect creation (or lack of creation) of future app backups; any existing app backup data will still exist and be used until overwritten or cleared (see above for instructions to clear that data for a device).
Just change android:allowBackup="true" to android:allowBackup="false" in manifiest.xml. It will be worked.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<application
android:allowBackup="false"
android:icon="#mipmap/app_icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
</manifest>

ClassNotFoundException when app launch

I created an Andriod app for a Chinese Newspaper Company.
From the Exception/ANR report of Google Play Store, it was found that some users encountered the problem of ClassNotFoundException when they launch the app.
The app cannot found the activity marked as
<category android:name="android.intent.category.LAUNCHER" />
The frequency is about every 3 sessions out of 500000.
What are the possibilities leading to ClassNotFoundException?
Remakrs:
I doubt if this related to the package name.
In the first few lines of AndroidManifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.news"
the source code are stored in different folder name (Real file storage place)
com.anotherCompany.abc
so.. in the activity tag (AndroidManifest)
<activity
android:name="com.anotherCompany.abc.MainActivity"
android:label="#string/app_name"
Thank you for your time
If this happens rarely, I think you shouldn't worry too much about it.
It can be due to a bad installation, a bad phone backup, or some android mods. But probably not something related to your code.

Android app fails to load on some phones in PathClassLoader

I have an app, let us call it 'com.company.foo', with a main Activity 'FooBar'. In my AndroidManifest.xml, I have
<application android:label="#string/app_name"
android:icon="#drawable/icon"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
<activity android:name="FooBar"
android:label="#string/app_name"
android:configChanges="keyboardHidden|orientation" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</application>
(where the dots contain other activities inside my app). In this form, it works fine on my HTC desire and on the emulator. However, a (very) small number of people who downloaded the app from the market report a crash with
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.company.foo/com.company.foo.FooBar}: java.lang.ClassNotFoundException: com.company.foo.FooBar in loader dalvik.system.PathClassLoader[/mnt/asec/com.company.foo-1/pkg.apk]
Someone suggested to replace the android:name="FooBar" with android:name=".FooBar", which again works fine on my phone and the emulator, but fails on some other devices. If I leave this attribute out altogether it will not let me install at all.
Any ideas?
I have an app published on Android Market. And sometimes I receive similar crash reports. Seems that's not your fault. This can be reproduced if your app is installed on SD card. Eject this card without unmounting it and run your app.
Additional information can be found here.
The code that you have shown is fine, can't see anything wrong with it - so what else have you looked at?
Have you checked the SDK level against the android release on teh phones that have failed? Any chance of some incompatability there?
Instantiating the activity I have found to my cost is a non-trivial matter and there are so many things to go wrong - you will have to go back over all your support files and make sure that they are clean but think about incompatabilities.
You have not said what imports are involved - have you tried cutting down your app to the bare minimum and see does it still cause problems with those small number of rogue phone - maybe you dont have access to the phones?
Try posting the phone makes/models that are causing problems, also where to access your app and there might be someone out here with the same make/model who would be willing to do some testing for you
Sorry I can't be more help,
Good Luck!!
Oliver

Android error: Application is not installed on your phone?

I am learning this via Sams Teach Yourself Android in 24 hours.
This is really strange, I run the app in the emulator and I get my splash screen (just some crappy text really) then I press the home button, and click on my app's icon and it gives me "Application is not installed on your phone"
I went into the emulators settings->applications and it's there!
I cleaned the project, uninstalled it from the emulator and re-ran it. Same damn problem.
(project is simple:
6activities, each has a unique text, as it starts it shows the splash activity
I have not even connected the other activities... just this)
You can download the entire source if you want at http://elxotica.com/TriviaQuiz.rar
Ok, got it working after going to the authors website, downloading the support code and going over it and comparing it line by line.
Basically in my manifest file I had
<activity android:name=".QuizSplashActivity"
android:label="#string/app_name">
and again below I had
<activity android:name="QuizSplashActivity"></activity>
which I thought was needed, but it looks like that should not be declared twice.
I fixed the problem but am not 100% sure of the cause :((
My problem was solved with this error when I moved the INTERNET permission statement in the manifest file out of the activity definition and into the application definition - that is, up in the hierarchy, right under the SDK version declaration:
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET"/>
<application android:icon="#drawable/icon" blah blah
I also had the permission defined twice. Compiling did not find the bug, however, running the app on the Android emulator did. "Application not installed" is not very helpful, tho. Rather like, "You fowled up [and if you don't know why, I'm not telling you].
I have no problem to run it on Android 2.2 Virtual Device. Maybe you can try create new AVD and run it there. I´ve had similar problem with new update and creating new AVD solved it...
Yeah, I had the same problem.
Just don't declare QuizSplashActivity twice.
Helped in my project, grettz
Yet another failure mode with the same symptom. I had same permission twice, first like this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
then like this:
<application android:icon="#drawable/icon" android:label="#string/app_name" android:permission="android.permission.WRITE_EXTERNAL_STORAGE">
The second one turns out not only not needed, but also cause the "Application not installed.." error.
So my application declaration looks like this now:
<application android:icon="#drawable/icon" android:label="#string/app_name">
And all is well in the world.
Same symptom, different cause. I'm not entirely certain what happened, but I will hazard a guess in case it helps anyone. What I know for sure: I deleted the icon, dragged it anew from Applications, problem solved.
At some point I changed which Activity was the entry-point (had android.intent.category.LAUNCHER & android.intent.action.MAIN)
I was trying to open the app using an icon on one of my "desktops", an icon which I had added before making the change in the manifest which changed which Activity was MAIN. So I'm guessing that the shortcut refers to the launcher activity and not the app (makes sense)...
My problem was missing assemblies in the package. But only on some phones.
I enabled "link all assemblies" option in the Xamarin studio and problem solved.
Android project options->Android build->Linker behavior->Link all assemblies.
[I'm using Xamarin studio with mono on Android.]

Categories

Resources