【问题标题】:Application is working on Android studio emulator but when it is downloaded from google play it stop unfortunately应用程序正在 Android Studio 模拟器上运行,但是当它从 google play 下载时,不幸的是它停止了
【发布时间】:2017-06-22 12:55:21
【问题描述】:

我创建了简单的 android studio 应用程序并将签名的 apk 发布到 google play 商店。该应用程序在模拟器上运行良好,这是一个非常简单的应用程序。所以没有什么应该让它崩溃。无论如何,在 Google Play 商店发布该应用程序后,我将其下载到我的其他手机上。它打开并显示所有小部件。但是当我点击按钮时它会崩溃说“不幸的是体重指数计算器已经停止。 这是我的第三个 android 应用程序,它们都得到了相同的结果。我究竟做错了什么?。我正在遵循发布签名 apk 的所有说明,并且我正在直接遵循所有 google play store 步骤。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="20dp"
    android:layout_marginTop="20dp"
    android:gravity="top|center"
    tools:context="calculator.bodyweight.www.myapplication.MainActivity">


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingLeft="10dp"
            android:paddingRight="10dp">


            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:layout_marginTop="25dp"
                android:text="@string/textView2"
                android:textAlignment="center"
                android:textAppearance="@style/TextAppearance.AppCompat.Large" />

            <EditText
                android:id="@+id/editTextweight"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/textView2"
                android:layout_alignStart="@+id/textView2"
                android:layout_below="@+id/textView2"
                android:layout_marginTop="19dp"
                android:ems="10"
                android:inputType="numberDecimal"
                android:textAlignment="center"
                android:textAppearance="@style/TextAppearance.AppCompat.Large" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/editTextHeight"
                android:layout_alignStart="@+id/editTextHeight"
                android:layout_below="@+id/editTextweight"
                android:layout_marginTop="33dp"
                android:text="@string/textView3"
                android:textAppearance="@style/TextAppearance.AppCompat.Large" />

            <EditText
                android:id="@+id/editTextHeight"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/editTextweight"
                android:layout_alignStart="@+id/editTextweight"
                android:layout_alignTop="@+id/textView3"
                android:layout_marginTop="46dp"
                android:ems="10"
                android:inputType="numberDecimal"
                android:textAlignment="center"
                android:textAppearance="@style/TextAppearance.AppCompat.Large" />

            <Button
                android:id="@+id/button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/editTextHeight"
                android:layout_alignStart="@+id/editTextHeight"
                android:layout_below="@+id/editTextHeight"
                android:layout_marginTop="16dp"
                android:onClick="calculate"
                android:text="@string/button"
                android:textAppearance="@style/TextAppearance.AppCompat.Large" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/button"
                android:layout_alignStart="@+id/button"
                android:layout_below="@+id/button"
                android:layout_marginTop="23dp"
                android:text=""
                android:textAppearance="@style/TextAppearance.AppCompat.Large" />

            <ImageView
                android:id="@+id/imageView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:srcCompat="@drawable/weight" />

        </LinearLayout></ScrollView>
</RelativeLayout>

【问题讨论】:

  • 你能发布你的java文件吗
  • 有崩溃日志吗?
  • 您是否使用ProGuard 进行发布构建?如果是这样,可能是您缺少一些配置。
  • 不,我没有使用 proguard。
  • 崩溃日志:java.lang.IllegalStateException: at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:327) at )

标签: android apk publish android-install-apk


【解决方案1】:

我解决了这个错误。 我将按钮单击方法用作 public void(View view) { },这在模拟器和我的手机上的调试版本上运行良好,但在发布版本上不起作用。 在我更改 oncreate 标签内的方法后,使用 setOnclicklisner 在发布版本上一切正常,并将其上传到 playstore,它运行良好。 如果没有指导或清除日志,很难找到此解决方案!我将其粘贴在这里,以供可能遇到相同问题的其他人使用。

【讨论】:

    【解决方案2】:

    从应用程序创建新版本并删除设备上所有以前的数据,然后再次测试新的 apk

    【讨论】:

      猜你喜欢
      • 2015-08-10
      • 2018-09-16
      • 2014-09-22
      • 2014-08-04
      • 1970-01-01
      • 2012-07-12
      • 2012-01-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多