cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dropbox com.android.packageinstaller.InstallAppProgress has leaked IntentReceiver

Dropbox com.android.packageinstaller.InstallAppProgress has leaked IntentReceiver

Siddharth J.
New member | Level 1

Unable to upload a file.
I am trying to upload a file to dropbox. I have configured manifest file, and written the below code. Please help me understand what I am missing here.

Debug Statements prove that the file is correct.

02-11 12:24:37.835: D/AutoActivate(14797): Database path /data/data/<mypackage>/databases/activations
02-11 12:24:37.835: D/AutoActivate(14797): File path activations.db len 4358144

public class UploadDB2DropBox extends AsyncTask<Object, Void, String> {
    private Context context;
    private WakeLock wakeLock;

    final static private String APP_KEY = "something";
    final static private String APP_SECRET = "sometingmore";
    final static private AccessType ACCESS_TYPE = AccessType.APP_FOLDER;
    private DropboxAPI<AndroidAuthSession> mDBApi;

    public UploadDB2DropBox(Context context) {
        this.context = context;
        AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
        AndroidAuthSession session = new AndroidAuthSession(appKeys,
                ACCESS_TYPE);
        mDBApi = new DropboxAPI<AndroidAuthSession>(session);
        mDBApi.getSession().startOAuth2Authentication(context);
    }

    protected void onPreExecute() {
        super.onPreExecute();
        final PowerManager pm = (PowerManager) context
                .getSystemService(Context.POWER_SERVICE);
        wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "");
        wakeLock.acquire();
    }

    @Override
    protected String doInBackground(Object... params) {
        File file = new File(context.getDatabasePath(God.TABLE_ACTIVATIONS)
                + ".db");
        Log.d(God.TAG,
                "Database path "
                        + context.getDatabasePath(God.TABLE_ACTIVATIONS));
        FileInputStream inputStream;
        try {
            inputStream = new FileInputStream(file);

DropboxException_ONE_LINE_BELOW     
            Entry response = mDBApi.putFile(
                    "/" + God.TABLE_ACTIVATIONS + God.getTodayInLong(),
                    inputStream, file.length(), null, null);
            Log.d(God.TAG, "Uploaded file is " + response.rev);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            Log.e(God.TAG, "FileNotFoundException");
        } catch (DropboxException e) {
            e.printStackTrace();
            Log.e(God.TAG, "DropboxException");
        }
        return null;
    }

    protected void onPostExecute(String result) {
        super.onPostExecute(result);
        if (wakeLock.isHeld())
            wakeLock.release();
        God.notifyNewActivations(context);
        if (mDBApi.getSession().authenticationSuccessful()) {
            try {
                // Required to complete auth, sets the access token on the session
                mDBApi.getSession().finishAuthentication();

                String accessToken = mDBApi.getSession().getOAuth2AccessToken();
            } catch (IllegalStateException e) {
                Log.i(God.TAG, "Error authenticating", e);
            }
        }
    }
}

I am getting a exception at DropboxException_ONE_LINE_BELOW. Below is the exception.

com.android.packageinstaller.InstallAppProgress has leaked IntentReceiver com.android.packageinstaller.InstallAppProgress$4@4231a880 that was originally registered here. Are you missing a call to unregisterReceiver()?

02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:822)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1167)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1154)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1148)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:365)
02-10 15:04:06.592: E/ActivityThread(26210):    at com.android.packageinstaller.InstallAppProgress.initView(InstallAppProgress.java:267)
02-10 15:04:06.592: E/ActivityThread(26210):    at com.android.packageinstaller.InstallAppProgress.onCreate(InstallAppProgress.java:179)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.Activity.performCreate(Activity.java:5158)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.ActivityThread.access$600(ActivityThread.java:149)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.os.Looper.loop(Looper.java:153)
02-10 15:04:06.592: E/ActivityThread(26210):    at android.app.ActivityThread.main(ActivityThread.java:5086)
02-10 15:04:06.592: E/ActivityThread(26210):    at java.lang.reflect.Method.invokeNative(Native Method)
02-10 15:04:06.592: E/ActivityThread(26210):    at java.lang.reflect.Method.invoke(Method.java:511)
02-10 15:04:06.592: E/ActivityThread(26210):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
02-10 15:04:06.592: E/ActivityThread(26210):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
02-10 15:04:06.592: E/ActivityThread(26210):    at dalvik.system.NativeStart.main(Native Method)
6 Replies 6

Greg-DB
Dropbox Staff

[Cross-linking for reference: https://stackoverflow.com/questions/28428719/dropbox-com-android-packageinstaller-installappprogress... ]

I wasn't able to reproduce this when we discussed this on StackOverflow. Can you supply a small sample project that reproduces this issue so we can investigate? Thanks in advance!

Siddharth J.
New member | Level 1

It is strange that dropbox developers(http://blog.smarx.com/) downvote answers, cannot reproduce after the entire code is shared, and provides bad/cryptic answers to questions. Is this how you support your customers ?

Downvoted by smarx, a dropbox developer http://stackoverflow.com/questions/28428719/dropboxunlinkedexception-if-you-have-not-set-an-access-t...

His response is
As a warning to others: It's hard to tell without context (like when this function is run), but it looks like this code will ask the user to auth every single time. The expected use is to auth the user just once, the first time they run the app.

A shameless downvote and a more discouraging to fellow developers.

This question has been on for more than 5 days, the solution I posted "works for me" and I am OK with the reauth. Instead of answering the question, you downvote it. Shame on you dropbox.

Greg-DB
Dropbox Staff

My apologies for any offense or miscommunication here. Like you, we want to make sure the best content and answers are available to other developers. We agree that having the user re-authorize the app is a bad experience but it seems the confusion here is around the notion that re-authing the user (via startOAuth2Authentication) is necessary, when in fact it isn't. As Steve was trying to point out with his comment, you only need to have the user authorize the app once, after which you can store and re-use the resulting access token. This is covered in the tutorial here:

https://www.dropbox.com/developers/core/start/android#authenticating

Only if the user explicitly unlinks the app do you need to prompt them to re-authorize. If they do unlink the app, API calls with the old access token will fail with DropboxUnlinkedException, documented here:

https://www.dropbox.com/static/developers/dropbox-android-sdk-1.6.3-docs/com/dropbox/client2/excepti...

Likewise, this can occur if you restart a previously authorized app but don't load up the previously acquired access token. You can create a session using a previously stored access token without having the user re-authorize the app using this constructor:

https://www.dropbox.com/static/developers/dropbox-android-sdk-1.6.3-docs/com/dropbox/client2/android...

I hope this helps!

Siddharth J.
New member | Level 1

So if I understand correctly, I need to call startOAuth2Authentication only once. After that I need to set a flag somewhere in the app to not need to all this again. Correct ?

Also why are your developers downvoting answers, instead of rephrasing / editing or adding a answer on SO. SO is the official way of communication for dropbox, why aren't you educating your developers to behave and help on a public forum which you official support.

Greg-DB
Dropbox Staff

Yes, that's the right idea with only calling startOAuth2Authentication once.

And thanks for your feedback on the StackOverflow etiquette! I'll be sure to pass that along to the right people.

Nisha J.
New member | Level 1

I just noticed, user http://stackoverflow.com/users/94559/smarx is downvoting most questions on dropbox. There are so many questions, hinting at how badly your API's are, worse this developer has the audacity to downvote questions. Pathetic behavior I must say.

Do you guys have any integrity as a company. I will be escalating this behavior to your Founders. They must know how your behavior is impacting our decision to NOT use dropbox API's.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Nisha J. New member | Level 1
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Siddharth J. New member | Level 1
What do Dropbox user levels mean?