RVIDAN
RVIDAN

Reputation: 140

Android: When I try to install my signed app, it says "App not installed"

When I try to install a signed apk file, the application installer says "App not installed".
It happens to every app that I have made. Even if I create a brand new keystore, or if I set the build mode to debug.
Although it does work if I install it through the Android Studio. But if I need to share it with my friends I can't.
I tried to look for a question that can appeal my situation on this site, but I haven't found any.
My application is working and (supposedly) signed. I can't find any reason for it not to work.

For example, this is the code for the JustJava app I made with the android development course at Udacity.

The activity_main.xml is:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="16dp">

    <EditText
        android:id="@+id/name"
        android:hint="@string/name_field"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:layout_marginBottom="16dp"/>

    <TextView
        style="@style/HeaderTextStyle"
        android:text="@string/toppings" />


    <CheckBox
        android:id="@+id/topping_whipped_cream"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:paddingLeft="24dp"
        android:text="@string/topping_whipped_cream" />
    <CheckBox
        android:id="@+id/topping_chocolate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:layout_marginLeft="16dp"
        android:paddingLeft="24dp"
        android:text="@string/topping_chocolate" />

    <TextView
        style="@style/HeaderTextStyle"
        android:text="@string/quantity" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="16dp">

        <Button

            android:id="@+id/decrement"
            android:layout_width="48dp"
            android:layout_height="wrap_content"
            android:onClick="decrement"
            android:text="@string/minus" />

        <TextView
            android:id="@+id/quantity_text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="16dp"
            android:paddingLeft="16dp"
            android:paddingRight="16dp"
            android:paddingTop="16dp"
            android:text="@string/quantity_num"
            android:textColor="@android:color/black"
            android:textSize="18sp" />

        <Button
            android:id="@+id/increment"
            android:layout_width="48dp"
            android:layout_height="wrap_content"
            android:onClick="increment"
            android:text="@string/plus" />

    </LinearLayout>


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">


        <Button
            android:id="@+id/order"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="submitOrder"
            android:text="@string/order_btn" />
    </LinearLayout>

</LinearLayout>

And the Java is:

package com.example.android.justjava;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import java.text.NumberFormat;

/**
 * This app displays an order form to order coffee.
 */
public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
/**
 * Assigns the name text field
 */


/**
 * This method is called when the order button is clicked.
 */
int quantity = 1;

public void submitOrder(View view) {
    EditText name = (EditText) findViewById(R.id.name);
    String clientName = name.getText().toString();

    Intent submit = new Intent(Intent.ACTION_SEND);
    submit.setData(Uri.parse("mailto:"));
    submit.setType("*/*");
    submit.putExtra(Intent.EXTRA_CC, "[email protected]");
    submit.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.mail_subject_order) + clientName);
    submit.putExtra(Intent.EXTRA_TEXT, createOrderSummary());
    if (submit.resolveActivity(getPackageManager()) != null) {
        startActivity(submit);
    }
}

public void increment(View view) {
    if (quantity < 99) {
        quantity += 1;
        displayQuantity(quantity);
    } else {
        Toast toast = Toast.makeText(getApplicationContext(),
                getString(R.string.over_100_coffees_toast), Toast.LENGTH_LONG);
        toast.show();
    }
}

public void decrement(View view) {
    if (quantity == 1) {
        Toast toast = Toast.makeText(getApplicationContext(), R.string.no_coffees_toast, Toast.LENGTH_SHORT);
        toast.show();
    } else {
        quantity -= 1;
        displayQuantity(quantity);
    }

}

/**
 * This method displays the given quantity value on the screen.
 *
 * @param quant
 */
private void displayQuantity(int quant) {
    TextView quantityTextView = (TextView) findViewById(
            R.id.quantity_text_view);
    quantityTextView.setText("" + quant);
}


/**
 * Creates a visual summary of the order.
 * <p/>
 * quantity is the number of cups of coffee ordered
 */

private String createOrderSummary() {
    /**
     * Assigns the whipped cream checkbox
     */
    CheckBox toppingWhippedCream = (CheckBox) findViewById(R.id.topping_whipped_cream);
    boolean isCheckedWhippedCream = toppingWhippedCream.isChecked();
    /**
     * Assigns the chocolate checkbox
     */
    CheckBox toppingChocolate = (CheckBox) findViewById(R.id.topping_chocolate);
    boolean isCheckedChocolate = toppingChocolate.isChecked();
    //retrieve client's name
    EditText name = (EditText) findViewById(R.id.name);
    String clientName = name.getText().toString();
    /**
     * Inputs the total price
     */
    int pricePerCup = 5;
    if (isCheckedWhippedCream) {
        pricePerCup += 1;
    }

    if (isCheckedChocolate) {
        pricePerCup += 2;
    }
    int totalPrice = pricePerCup * quantity;
    return          //returns the name of the client
            getString(R.string.name_at_order_summary) + clientName + "\n"
                    //return quantity
                    + getString(R.string.quantity_at_order_summary) + quantity + "\n"
                    //return if whipped cream is checked
                    + getString(R.string.topping_whipped_cream_at_order_summary) + isCheckedWhippedCream + "\n"
                    //return if chocolate is checked
                    + getString(R.string.topping_chocolate_at_order_summary) + isCheckedChocolate + "\n"
                    //return total price
                    + getString(R.string.total_price_at_order_summary) + totalPrice + "\n" +
                    getString(R.string.thank_you_at_order_summary);
}


}

Mainfest:

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Thank you!

Upvotes: 3

Views: 1179

Answers (2)

penta
penta

Reputation: 2586

Check if in guests account(if you are emulating in android 5.0+) the app is installed or not, if yes then remove it and re-install from IDE.

Upvotes: 2

Akshat Agarwal
Akshat Agarwal

Reputation: 2847

Since you already have enabled installation from 'unknown sources'

Taking from 'App not Installed' Error on Android

This error also occurs when trying to install an apt on a phone with a previous version of the same apt and both asks aren't signed with the same certificate, so you might wanna check if you used it previously that you used the same certificate. One way to ensure this is to uninstall all previous versions and install the new signed apk

Upvotes: 0

Related Questions