Update xamarin app via app center distribute : Problem while parsing package - android

We have made an android app using Xamarin and make use of microsoft appcenter build and distribute, we migrated this app from using HockeyApp.
Appcenter allows us to make a QR code which people can then scan and they can install the application this way, this works fine. Another way users can install the application is by using the app center app, this also works.
However when we push out an update we start to get issues. We have allowed using in app updates so when we push a new version a pop up will show in the app requiring that you update it. There is a download button available. Clicking this will start the download. After the download is finished a screen is showed with the text 'Staging app' and the following error message : "There was a problem while parsing the package." This happens both using the app center app or the QR code to install the app. We can also install a new version using the microsoft app center app, in this case it does work but we would like the in app updates to work properly too.
How can we get this to work so that users can also do in app updates where the new version can actually be installed? The code to activate distribute is as follows :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Forms.Init(this, bundle);
ContextMenuViewRenderer.Preserve();
appVersion = "" + this.PackageManager.GetPackageInfo(ApplicationContext.PackageName, 0).VersionName;
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
}
AppCenter.Start(_appCenterId,
typeof(Analytics), typeof(Crashes), typeof(Distribute));
CheckForUpdates();
}
private void CheckForUpdates()
{
Distribute.SetEnabledAsync(true);
}
private void UnregisterManagers()
{
Distribute.SetEnabledAsync(false);
}
Thanks for the help.

Problem while parsing package
About this problem,
You need to check whether the apk file has been downloaded fully first. Check the size of downloaded apk file is the same with the server.
Second, you need to check whether the name of apk file is legal, such as can not contain space char.
Third, check the android:minSdkVersion of AndroidManifest is higher than your current environment.

Related

Keep an internal app updated

I'm going to develop an android app for a museum, which will handle a tablet with the app installed on it to the visitors.
The app will be on foreground full time and visitor will only be able to use this app.
Since there will be many tablets, and they are all under our control, I would like a way to update all the tablets remotly with the last version of the app.
Is there a way to achive this?
Is there a way to achive this?
Answer is : Yes but with one exception lets have a look.
Step 1 : Create a local server for your museum. I guess it is already in the museum.
Step 2 : Now In your android application whenever you start your app check that whether new version of APK is available. For checking APK new version you can use this code.
PackageInfo packageInfo = getPackageManager().getPackageInfo(context.getPackageName(), 0);
int apkVersion = packageInfo.versionCode;
You should set your APK name like "yourAppname_version" so whenever you upload the new app to your local server just change the name so you can easily identify that new version of APK is available or not.
Step 3 : If new version is available then start downloading APK from the local server and save it to your storage directory.
Step 4 : When downloading completed you can call this set of code to install the new APK.
Intent intentApkInstall = new Intent(Intent.ACTION_VIEW);
intentApkInstall.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory()+"/"+"yourAppname_version.apk")), "application/vnd.android.package-archive");
intentApkInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentApkInstall);
Now the Exception part is here the above code will prompt user to install APK. So in this case you have to install it manually.

Integrating Air Watch Android Studio

I am very much new to AirWatch Concept but had gone thoroughly about AirWatch. I have gone through the following links,
http://developer.air-watch.com/android/application-configuration-with-the-android-sdk/
http://developer.air-watch.com/android/android-sdk-setup/
but in vain.
Could anyone please help me regarding the integration of Air Watch in Android ?
Things i have done so far,
I have created app in the https://apidev.awmdm.com, and i have added assignemnts. The question here is, How can i get the assignment details in my android application that were added in the Air Watch Console.
Help is really appreciated.
Update:
I am able to create and push the application from AIR WATCH CONSOLE to my Device. Now, the issue i am facing is, If i am adding some application configuration in the AIR WATCH CONSOLE, i am not able to get those details in my application.
I have gone through the below Url for the above scenario,
https://appconfig.org/android/ which is very much similar to https://appconfig.org/ios/
I have implemented those things that were mentioned in the above url but still then i am not able to get those details.Please let me know if i am wrong anywhere.
I got to know that the key value pairs that were being passed in Air watch console will be coming into com.apple.configuration.managed key in iOS. Does any one have an idea that how these key value pairs will come. As far as i know, they will be handled via Restriction Manager. But no idea/clue how to handle in Android.
Updated:
xml/app_restrictions.xml:
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<restriction
android:key="ManagedServer"
android:restrictionType="string"
android:title="Managed Server"
tools:ignore="ValidRestrictions" />
<restriction
android:key="#string/mdm_key_managed_server_name"
android:restrictionType="string"
android:title="#string/mdm_key_managed_server_url"
tools:ignore="ValidRestrictions" />
<restriction
android:key="#string/mdm_key_managed_server_url"
android:restrictionType="string"
android:title="#string/mdm_key_managed_server_url"
tools:ignore="ValidRestrictions" />
</restrictions>
oncreate Method :
IntentFilter restrictionsFilter =
new IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
BroadcastReceiver restrictionsReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
// Get the current configuration bundle
Bundle appRestrictions = myRestrictionsMgr.getApplicationRestrictions();
// Check current configuration settings, change your app's UI and
// functionality as necessary.
Toast.makeText(LoginActivity.this, "Reciever Called", Toast.LENGTH_LONG).show();
RestrictionsManager myRestrictionsMgr =
(RestrictionsManager)
getSystemService(Context.RESTRICTIONS_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
if (myRestrictionsMgr != null) {
Bundle appRestrictions = myRestrictionsMgr.getApplicationRestrictions();
if (appRestrictions != null) {
if (appRestrictions.containsKey("ManagedServer")) {
String mConfigDetails = appRestrictions.getString("Managed Server");
Toast.makeText(LoginActivity.this, "" + mConfigDetails, Toast.LENGTH_LONG).show();
}
}
}
}
}
};
registerReceiver(restrictionsReceiver, restrictionsFilter);
List of Users:
When i am actually trying the other command:
Update:
Created a sample app and published to Play Store. App link as follows,
https://play.google.com/store/apps/details?id=com.manu.samplemdm
Now, its a play store app. When I am sending Application Configuration but unable to receive it in the Application. Its giving me still empty bundle from the application.
Help would be really appreciated.
Help is really appreciated
Beside AirWatch Resources, which tells you how you can create an app and set the app configurations,key-value pairs, to push to your devices, You need to check out Android Restriction Manager API. Follow the steps described in the link.
How the whole process works is, AirWatch controls AndroidForWork environment after you set your MDM as AirWatch. And then, AirWatch manages the device from AirWatch console and it pushes the App Configuration to AndroidForWork in your device. You need to implement Android Restriction Manager to access to these data passed you by your MDM. It goes same for all of the MDMs in the Market.
Update:
In order to install your app into Work Container in the development phase, you can use adb to copy it from Personal Container to Work Container.
First, list all of the active users in the device:
./adb shell pm list users
And later, find the Work User's ID from the List of Users and set it in the command below along with your app's package name and App's Main Activity.
./adb shell am start —user 13 -n “your.apps.package.name/your.main.activity.package.name”
13 up there in the command is the Work User's ID. In my case, it's 13.
For more information about ./adb commands in Managed Profiles, see this link and check the most bottom of the page.
There are a couple of different approaches to integrating with AirWatch. It depends on the technology set you're trying to use. I think these are the 2 that are most relevant to you based on what I see in your post:
AirWatch SDK
AppConfig Standard
Both these approaches can accomplish similar functionality but each have different deployment requirements. It sounds like you have gone with the second approach which is using the AppConfig standard and the native APIs provided by Google to have an app read configuration values delivered through AirWatch.
One important thing to note is the AppConfig standard approach on Android requires the device to support "Android for Work" enrollment which is a relatively newer management protocol released by Google. It's worth noting that AirWatch does support Android for Work enrollment so it may just be a matter of getting your AirWatch test instance configured for "Android for Work enrollment" instead of the traditional older Android enrollment protocol. More information about Android for Work can be found here:
https://enterprise.google.com/android/solutions/personal/
If you're already a customer of AirWatch, it may be helpful to create an account here on their resource portal if you haven't done so already to get access to documentation about how you can setup Android for Work within AirWatch. https://resources.air-watch.com
I hope this helps.

Force update for the latest version of android app

I am trying to figure out how to forcefully update the latest version from play store.
As the older version of my android app is already in play store where i haven't implement the check to get the current version of the app and compare with the play store app version like specified in the link update android app forcefully
I want that when I upload my new version on play store then user should not be able to use the app till he update the new version.
Could you please help me out.
I have to do the same thing but what i did i gonna share you i hope this will help you.
1> I get the previous code version of my application and store it the string.xml. like my live app version code is 1. And my new app version code is 1.1.
This code is tell us our app version code.
PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
int versionNumber = pinfo.versionCode;
String versionName = pinfo.versionName;
2> Than check
if (newcodeversion > previouscodeversion) {
// open any activity or pop up
}
3> And in the new activity place Text view with text "you have update version" and a button.And on the click of that button navigate to google play store.
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("Your application URL"));
startActivity(i);
It is not possible if the logic of comparing the versionCode and blocking the user isn't already placed inside the current app on PlayStore.
This is not difficult to do. Simply bar the user from having the core functionality of what ever your app is responsible for.
Example, if it is a calling app, do a version check, and if the user has not updated as yet, restrict the use of call making entirely.
According to #pieter-b, taken from Forcing Updates:
For this to work, some kind of logic the app uses needs to be under your control. And then without that part of logic the app won't work
and you can show a message: "your app is out of date, please download
the new version to continue use."
Consider a messenger app where traffic goes through your servers. Just
refuse to deliver messages of clients using an outdated version.
Also refer to Force update android app when new version available.

How to autoupdate android app without playstore? Like Facebook app or any Contest app

How do apps update internally automatically without updating from playstore?
I mean the internal data of app is changed (via internet) without updating from playstore. For eg any Contest app, or Facebook app. Here the newsfeed is updated automatically.
What is the technical term for that?
Any tutorial on it?
If you would like to check if you app has updates (without interacting with Google Play), you'd have to poll a server (providing your current version) and let the server check if there is a newer version available. If that is the case, let the server respond with a changelog and an url to the newer version.
Luckily, there are libraries to do this:
AppUpdater. Android Library that checks for updates on your own server (or Google Play, Github, etc). Great documentation. This library notifies your apps' updates by showing a Material dialog, Snackbar or notification.
Android Auto Update. Chinese library, but should do the trick, one of the most popular libraries to do this, but this can be just because Google Play is not available in China.
AppUpdateChecker A simple non-Market way to keep your app updated.
All it requires to set up is a URL pointing to a JSON document describing your app's changes.
Auto Updater This project allows to automatically update a running APK application using a private update server (see apk-updater) instead of Google Play updater. Also comes with a server script.
SmartUpdates. Older library, but instructions in English and also provides a server script.
WVersionManager. Checks for updates, but actual update has to be downloaded from the Play Store.
Answer from Mdlc is about updating the app itself but not the content.
What initially asked is how to create an App with dynamic content such Facebook or any other newsfeed app.
Any kind of such apps has 2 parts:
Server
Client
Server stores the whole information you need and client make requests to that server and displays information.
Let's say server stores in DB one entry called News#1. Client requests list of news and get back array[News#1] as response and show one tile on screen. Then somebody creates new entry News#2. On next request to the server client will get array of 2 elements: array[News#1, News#2] and displays this dynamic content.
REST Api Client is what to start with.
https://github.com/bitstadium/HockeySDK-Android/blob/develop/hockeysdk/src/main/java/net/hockeyapp/android/tasks/DownloadFileTask.java#L194 has the perfect and still working implementation on opening a downloaded APK file...
private fun install(downloadedAPK: File, context: Context) {
val intent = Intent(Intent.ACTION_INSTALL_PACKAGE)
intent.setDataAndType(Uri.fromFile(downloadedAPK),
"application/vnd.android.package-archive")
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
var oldVmPolicy: StrictMode.VmPolicy? = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
oldVmPolicy = StrictMode.getVmPolicy()
val policy = StrictMode.VmPolicy.Builder()
.penaltyLog()
.build()
StrictMode.setVmPolicy(policy)
}
context.startActivity(intent)
if (oldVmPolicy != null) {
StrictMode.setVmPolicy(oldVmPolicy)
}
}
Also have a look on AppCenter (Former HockeyApp) in-app updates https://learn.microsoft.com/en-us/appcenter/distribution/inappupdates
Here is the alternate
https://developer.android.com/guide/app-bundle/in-app-updates#update_readiness
try this google library to update from the application
dependencies {
implementation 'com.google.android.play:core:1.5.0'
...}
You can try this library: implementation 'com.github.vermat516:HelperLibrary:1.0.1'
This is best from my view we only have to write is:
new UniversalHelper(this).updateApp();
Rest of the work will automatically done by the library
This is response how your app will look like[This]

How make android application auto updateable without using google play service

how can i make my application auto updatable ? pls help.
process that should not want user confirmation.it should be run after login automatically
`
new Thread()
{
#SuppressWarnings({ "null", "deprecation" })
#Override
public void run() {
Looper.prepare();
Handler refresh1 = new Handler(Looper.getMainLooper());
refresh1.post(new Runnable() {
public void run()
{
//i want do here background process that search applications new version and install it automatically.
}
}
}
}//ends thread
This is not possible, except perhaps on rooted devices. Apps cannot install other apps, including updates to their own app, without user involvement.
You can't do that... all you can do is use the Android Market API (not official) to alert the users with a new update: https://code.google.com/p/android-market-api/
Also, if you're using some webservice, you can make a validator with it... but not a single chance to auto update an app without user confirmation.
You could force users to upgrade by other means. Have your app check a URL on startup, perhaps an XML file on your website. The XML file contains the android:versionCode of the latest app release. The app then compares the retrieved version code value with its own version code, and if an upgrade is required, you can then have the app display a message "Upgrade required" or something similar, and you can either have it be a reminder message that pops up on startup (using a Toast, maybe) every time the app is run, or you can have the app refuse to function until it is upgraded.
Please note, implementing this type of behavior in your apps may violate app store policies, especially for paid apps.

Categories

Resources