3

.I followed this tutorial and getting errors "PARSING ERROR THERE IS A PROBLEM PARSING THE PACKAGE". I have check the result in Android Device Samsung Galaxy S3.

    package com.mrfs.android.surveyapp.activities;

        import java.io.File;
        import java.io.FileOutputStream;
        import java.io.InputStream;
        import java.net.HttpURLConnection;
        import java.net.URL;

        import android.app.Activity;
        import android.content.Context;
        import android.content.Intent;
        import android.net.Uri;
        import android.os.AsyncTask;
        import android.os.Bundle;
        import android.os.Environment;
        import android.util.Log;


        public class ApkFileAsync extends Activity
        {
            UpdateApp updateAppInstance;

        @Override
        public void onCreate(Bundle savedBundleInstance)
        {

        super.onCreate(savedBundleInstance);
        updateAppInstance = new UpdateApp();
        updateAppInstance.setContext(getApplicationContext());
        updateAppInstance.execute("http://demo.ingresssolutions.com/proposalmanagement/services/user/getApkFile");
        }

        private class UpdateApp extends AsyncTask<String,Void,Void>{
        private Context context;
        public void setContext(Context contextf){
            context = contextf;
        }
        @Override
        protected Void doInBackground(String... arg0) {
              try {
                    URL url = new URL(arg0[0]);
                    HttpURLConnection c = (HttpURLConnection) url.openConnection();
                    c.setRequestMethod("POST");
                    c.setDoOutput(true);
                    c.connect();

                    String PATH = "/mnt/sdcard/Download/";
                    File file = new File(PATH);
                    file.mkdirs();
                    File outputFile = new File(file,"surveyapp.apk");
                    if(outputFile.exists()){
                        outputFile.delete();
                    }
                    FileOutputStream fos = new FileOutputStream(outputFile);

                    InputStream is = c.getInputStream();

                    byte[] buffer = new byte[1024];
                    int len1 = 0;
                    while ((len1 = is.read(buffer)) != -1) {
                        fos.write(buffer, 0, len1);
                    }
                    fos.close();
                    is.close();

                  /*  Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(Uri.fromFile(new File("/mnt/sdcard/Download/update.apk")), "application/vnd.android.package-archive");
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);*/ // without this flag android returned a intent error!
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")), "application/vnd.android.package-archive");
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);  
                    context.startActivity(intent);


                } catch (Exception e) {
                    Log.e("UpdateAPP", "Update error! " + e.getMessage());
                }
            return null;
 }}  
  }

I am getting this error after Complete Action using dialog when trying to press either PACKAGE INSTALLER or VERIFY AND INSTALL in both cases same error. Manifest file

Erum
  • 790
  • 3
  • 14
  • 36

1 Answers1

0

Change your manifes to like

enter image description here

This should work fine i think.. If not worked please post your tutorial link i missed it.. i need to check it.. and i will update answer... and also mention how you are installing app wether by eclipse or by some other process like importing apk... IF importing apk to real device means please check ur device version, If its s3 mans it has ICS api level includes 14 or 15 so change that.. if its jellly bean means you can use up to 18

Community
  • 1
  • 1
Whats Going On
  • 1,379
  • 6
  • 20
  • 49
  • link i have followed 2nd Anser: For ICS I´ve implemented your code and made a class that extends AsyncTaskhttp://stackoverflow.com/questions/4967669/android-install-apk-programmatically?rq=1 – Erum Jan 16 '14 at 12:16
  • k so you want install .apk programmatically so use juro question and answer of that link its worked fine i tried it.. http://stackoverflow.com/questions/4604239/install-application-programmatically-on-android there is problep with your code that code works for only few devices.. which will include root permissions also.. so follow juros answer.. – Whats Going On Jan 16 '14 at 12:24
  • following JUROS answer lets see result – Erum Jan 16 '14 at 12:36
  • hey Erum Hannan Can you send me Code to this email justdoit1str@gmail.com.. so that i will check that.. before sending Remove all your personal belongings.. regarding that application.. and send me example code.. I think the problem is that your device require root permissions.. so once send me i will check it... – Whats Going On Jan 17 '14 at 04:41
  • can u please let me know your skype id so that i can let u know project flow becoz my project contains so many code – Erum Jan 17 '14 at 05:04
  • have u recieved any file in your email ? – Erum Jan 17 '14 at 05:55
  • Hey Erum Hannan i am in office Skype youtube temveawer not works so send your code to email.. my laptop is protected by server so i cant install any skype or temveawer so but softwares are preloaded so i can see problem... sorry for late responce i am in week off.. – Whats Going On Jan 20 '14 at 06:33