Installation failed with message Error: android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
Asked Answered
B

12

149

I was getting the message

> Installation failed with message Failed to establish session.

so following some responses to the problem I disabled Instant Run and I started getting

> Installation failed with message Error: android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space.

I´ve tried rebuilding, cleaning the project, to disable and enable Instant Run and to build APK but nothing solves the problem.

This is my build.gradle (Module:app).

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.gabriel.justmeet"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 9
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    useLibrary 'org.apache.http.legacy'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.volley:volley:1.1.0'
}

and this is the build.gradle(Project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'http://repo1.maven.org/maven2' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

This started when I modified my RegisterActivity, so it might help

package com.example.gabriel.paska;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import java.util.HashMap;
import java.util.Map;

public class RegisterActivity extends AppCompatActivity {
    public static final String REGISTER_URL ="http://justmeet.000webhostapp.com/php/register.php";
    public static final String KEY_USERNAME ="username";
    public static final String KEY_PASSWORD="password";
    public static final String KEY_NAME ="name";
    public static final String KEY_AGE="age";
    public static final String REGISTER_SUCCESS ="RegisterSuccess";
    public static final String SHARED_PREF_NAME="tech";
    public static final String USERNAME_SHARED_PREF="username";
    public static final String LOGGEDIN_SHARED_PREF="loggedin";
    private boolean loggedIn=false;
    EditText etAge;
    EditText etName;
    EditText etPassword;
    EditText etUsername;
    Button bRegister;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        etAge = findViewById(R.id.etAgeR);
        etName = findViewById(R.id.etNameR);
        etPassword = findViewById(R.id.etPwordR);
        etUsername = findViewById(R.id.etUsernameR);
        bRegister = findViewById(R.id.btRegister);

        bRegister.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                register();
            }
        });
    }
        private void register() {
            final String name = etName.getText().toString().trim();
            final String password = etPassword.getText().toString().trim();
            final String username = etUsername.getText().toString().trim();
            final String age = etAge.getText().toString().trim();

            StringRequest stringRequest = new StringRequest(Request.Method.POST, REGISTER_URL,
                    new Response.Listener<String>() {
                        @Override
                        public void onResponse(String response) {
                            if(response.trim().equalsIgnoreCase(REGISTER_SUCCESS)){

                                SharedPreferences sharedPreferences = RegisterActivity.this.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);

                                SharedPreferences.Editor editor = sharedPreferences.edit();

                                editor.putBoolean(LOGGEDIN_SHARED_PREF, true);
                                editor.putString(USERNAME_SHARED_PREF, name);

                                editor.apply();

                                Intent intent = new Intent(RegisterActivity.this, UserActivity.class);
                                startActivity(intent);
                            }else{
                                Toast.makeText(RegisterActivity.this, "Register Failed" + response.trim(), Toast.LENGTH_LONG).show();
                            }
                        }
                    },
                    new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                        }
                    }){
                @Override
                protected Map<String, String> getParams() throws AuthFailureError {
                    Map<String,String> prams = new HashMap<>();
                    prams.put(KEY_USERNAME, username);
                    prams.put(KEY_PASSWORD, password);
                    prams.put(KEY_NAME, name);
                    prams.put(KEY_AGE, age);

                    return prams;
                }
            };
            RequestQueue requestQueue = Volley.newRequestQueue(this);
            requestQueue.add(stringRequest);
        }
        @Override
        protected void onResume() {
            super.onResume();
            SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREF_NAME,Context.MODE_PRIVATE);
            loggedIn = sharedPreferences.getBoolean(LOGGEDIN_SHARED_PREF, false);
            if(loggedIn){
                Intent intent = new Intent(RegisterActivity.this, UserActivity.class);
                startActivity(intent);
            }
        }
    }
Bul answered 31/1, 2019 at 13:4 Comment(1)
Is there enough space left on your device ? (ram or storage). Otherwise if you're testing on an emulator, try to recreate one...Omnipotent
E
261

This issue is about your storage in the emulator. Default AndroidStudio value of 2Gb is not enough for modern Android versions.

enter image description here


Solution

Step 1: close the emulator.

Step 2: Wipe the emulator.

enter image description here

Step 3: change the internal storage and SD Card to 4098MB.

enter image description here

Step 4: Run the Emulator.

Extent answered 1/3, 2022 at 14:25 Comment(2)
Step 3 alone working for me!Commander
I had to wipe the simulator once again after changing its storage sizeAbacus
R
46

This is simply the virtual device running out of space. Each install on a virtual device uses up a bit of space each time you run your app. Over time the space fills up until it's all used up. You can increase the space as suggested by some answers - which will work initially but eventually that space will get used up too.

From the virtual device's Settings app you can view how much space you have left. Here you can see that almost a whole GB is used up, but the apps themselves only use 132MB, clearly something is off.

enter image description here

Go to the AVD Manager and in the Actions for your device there is the option to 'Wipe Data' - do that.

enter image description here

Heading back to the Settings app you can now see that the space is freed up and your app has room to be installed - till the next time it runs out at which point you just repeat this process.

enter image description here

Rinna answered 30/3, 2021 at 9:45 Comment(1)
This should be marked as the Correct answer. It not only tells the root cause, but also how to fix the problem.Guttle
S
22

that file-system has no space:

java.io.IOException: Requested internal only, but not enough space.

the issue is:

android:installLocation="internalOnly"

either remove it, or replace it with:

android:installLocation="preferExternal"

or make some space on the device / emulator by uninstalled or deleting something -

or simply assign some more megabytes to the virtual SD card.

Sisco answered 31/1, 2019 at 13:18 Comment(5)
Before trying any modifications mentioned do check the space left on device.Support
I change the SD-card of AVD Manager into 1000MB,it worksFusain
This is where you set the installLocation: developer.android.com/guide/topics/manifest/…Factual
I deleted 100MB of APKs and apps I'd downloaded/installed on my AVD during testing, and this error went away.Gutta
Looks like installLocation is ignored on newer apis or devices or certain situation as large assets who knows but in my case it's just ignored.Turnabout
P
8

If you are using phone this error comes due to less storage. Make some space and try again it should work.

Psychotomimetic answered 31/1, 2020 at 6:28 Comment(0)
P
7

In Android Studio, open the AVD Manager and edit the problematic emulator. Inside the edit screen, you might need to click on 'Show Advanced Settings'. Scroll down and increase internal memory and SD card memory. After I did this I could install my app again.

Parochialism answered 17/12, 2019 at 9:15 Comment(0)
N
2

The problem is with your storage space on your device which it is running. Try Installing Clearing the space or install it on an emulator.

Naoma answered 15/5, 2020 at 9:46 Comment(0)
A
2

Your app is trying to install on internal space of your virtual device, and it doesn't have enough space. If you run the emulator, go to config/storage and you'll see you have no space.

Sometimes, the emulator is created with 800Mb of internal space, and Android Oreo (for example) occupies all that space, and it is not possible to install anything.

Furthermore, even when you config your app to "prefer external", the app keep trying to install on internal storeage, so you can not solve the problem with that.

The only solution that worked for me was increasing the internal space of the emulator, you can do that by following one of these options:

A) Go to Android SDK -> ADV Manager, locate your emulator, edit preferences and increase the space, duplicate it, or what you want.

B) Go to the folder with the config of your emulator (In Windows C:/Users/your_user/.android/avd/your_emulator) and edit the *.ini files, you can see values related to space, memory, and so on, just increase that values and save.

Visual Studio 2017 has an aweful integration with Android SDK/ADV Manager, so you need to do this 100% manually, furthermore you don't receive any info or instructions when the error happens, so it's really annoying to fix it :( And it is always the same with the 99% of Xamarin problems!

Admiralty answered 4/8, 2020 at 15:35 Comment(0)
L
1

Create space on your phone or emulator and it should work.

Lewanna answered 5/9, 2021 at 14:27 Comment(1)
Please add further details to expand on your answer, such as working code or documentation citations.Liquidation
B
1

it simply means the device that you wanna test the app or do debugging on does not have enough space. So clear off some memory, and then try again.

Blaine answered 31/10, 2021 at 9:7 Comment(0)
T
1

When running on emulator I found that even when I increased Internal disk space it didn't worked and stayed same size, I had to re-create emulator.

Turnabout answered 7/3, 2022 at 22:17 Comment(0)
S
0

I uninstalled all the apps I ran and got installed on the virtual device and the error went away.

Spiceberry answered 9/6, 2020 at 11:38 Comment(0)
C
0

On Mac I followed the same above procedure, but the settings were different. I didn't have to wipe the device to fix it.

Stop the emulator then choose Edit:

enter image description here

Then increase the disk.dataPartition.size property. It was 800M for me, I increased it to 4G for 4 gigabytes.

enter image description here

Then save and start up the emulator.

Caber answered 14/7, 2023 at 22:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.