Android:当我尝试安装签名的应用程序时,它显示“应用程序未安装”

2023-12-06

当我尝试安装签名的 apk 文件时,应用程序安装程序显示“应用程序未安装”。
我制作的每个应用程序都会发生这种情况。 即使我创建一个全新的密钥库,或者将构建模式设置为调试。
虽然如果我通过 Android Studio 安装它确实可以工作。但如果我需要与我的朋友分享,我就不能。
我试图在这个网站上寻找一个可以解决我的情况的问题,但我还没有找到。
我的申请正在运行并且(据说)已经签署。我找不到任何它不工作的理由。

例如,这是我通过 Udacity 的 Android 开发课程制作的 JustJava 应用程序的代码。

Activity_main.xml 是:

<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>

Java 是:

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);
}


}

显现:

<?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>

谢谢你!


检查来宾帐户中是否安装了该应用程序(如果您在 android 5.0+ 中模拟),如果是,则将其删除并从 IDE 重新安装。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android:当我尝试安装签名的应用程序时,它显示“应用程序未安装” 的相关文章

随机推荐