生成的apk在安装后突然崩溃 [英] generated apk suddenly crashes after installation

查看:103
本文介绍了生成的apk在安装后突然崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我是Java的初学者。我在使用java程序构建apk时有很多疑点。我已经引用了许多网站,包括codeproject,堆栈溢出,并且在开发android应用程序时得到的一些想法。



我做的是:

1.下载Android工作室并构建一个签名的apk(成功构建)。

2.复制apk_release.apk到我的手机并安装它(成功安装)。

3.当我打开已安装的.apk时,它显示不幸的是KLUVIS(我的文件名)已停止。

4.在我的Android手机中使用开发人员设置我启用了USB调试并使用adb.exe安装了应用程序。但是我遇到了同样的问题。

5.在互联网上提到了各种程序但是没有用。

6.在codeproject中引用文章。



这是我的.java代码:

Sir, I am a beginner in Java.I have many doubts in building an apk using java program.I have referred many websites including codeproject, stack overflow and got few ideas in developing an android application.

What I did is:
1. Downloaded Android studio and built a signed apk(Successful build).
2. Copied the apk_release.apk to my phone and installed it(Successful installation).
3. when I opened the installed .apk it shows me "unfortunately KLUVIS(my file name) has stopped.
4. Using developers settings in my android phone I have enabled USB debugging and installed the app using adb.exe.But the same problem which I have encountered.
5. Referred various procedures in internet but didn't work.
6. Referring articles in codeproject.

Here is my .java code:

package com.vis.vis;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;


public class VIS extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_vis);
        final Button btn = (Button)findViewById(R.id.button1);
        final EditText et1 = (EditText)findViewById(R.id.editText1);
        final EditText et2 = (EditText)findViewById(R.id.editText2);
        final EditText et3 = (EditText)findViewById(R.id.editText3);
        final EditText et4 = (EditText)findViewById(R.id.editText4);
        final TextView result = (TextView)findViewById(R.id.textView1);
        btn.setOnClickListener(new OnClickListener()
        {

            @Override
            public void onClick(View v)
            {
                int s1 = new Integer(et1.getText().toString());
                int s2 = new Integer(et2.getText().toString());
                int s3 = new Integer(et3.getText().toString());
                float a = new Integer(et4.getText().toString());
                float end;
                end = (float) (((s1  + s2  + s3 ) / 7.5) + (a / 10));
                if(end<=40)
                {
                    end = (40 - end)*2;
                    result.setText("The marks needed to pass in your end semester:  " +end);
                }
                else
                {
                    end = (end - 40)/2;
                   result.setText("Additional marks that you have :"+end);
                }

            }
        });

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "visweswaran.nagasivam98@gmail.com", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_vi, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }


    }





这里是我的.xml代码:





and here is my .xml code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"

    android:layout_height="wrap_content" android:paddingLeft="@dimen/activity_horizontal_margin"

    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin"

    android:paddingBottom="@dimen/activity_vertical_margin"

    app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/activity_vis"

    tools:context=".VIS">

    <TextView android:text="Kalasalingam University Mark Calculator" android:layout_width="wrap_content"

        android:layout_height="wrap_content" />
    <TextView android:text="\n\nProgrammed by Er.N.Visweswaran.,B.Tech.,DMO.,DCP.," android:layout_width="wrap_content"

        android:layout_height="wrap_content" />
    <TextView android:text="\n\nEnter your sessional one marks:  " android:layout_width="wrap_content"

        android:layout_height="wrap_content" />
    <EditText

        android:id="@+id/editText1"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:inputType="textPersonName" >

        <requestFocus />
    </EditText>
    <TextView android:text="\n\nEnter your sessional two marks:  " android:layout_width="wrap_content"

        android:layout_height="wrap_content" />
    <EditText

        android:id="@+id/editText2"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:inputType="textPersonName" />
    <TextView android:text="\n\nEnter your sessional three marks:  " android:layout_width="wrap_content"

        android:layout_height="wrap_content" />
    <EditText

        android:id="@+id/editText3"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:inputType="textPersonName" />
    <TextView android:text="\n\nEnter your assignment marks:  " android:layout_width="wrap_content"

        android:layout_height="wrap_content" />
    <EditText

        android:id="@+id/editText4"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:inputType="textPersonName" />
    <Button

        android:id="@+id/button1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="CALCULATE" />
    <TextView

        android:id="@+id/textView1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Large Text"

        android:textAppearance="?android:attr/textAppearanceLarge" />



</RelativeLayout>


$ b $b

Have I missed anything?Kindly help me with this.



Have I missed anything?Kindly help me with this.

推荐答案

Fir st of all my sincere Thank you to



1. Sir Richard MacCutchan,

2. Sir Mohibur Rashid,

3. Sir Afzaal Ahmad Zeeshan.



for their patient, kind and sincere help.The question is finally solved by removing some complexity, connecting my device to PC and running the application directly on virtual device.



Modified code:(Simplified by eliminating toolbars,name etc.,)

First of all my sincere Thank you to

1. Sir Richard MacCutchan,
2. Sir Mohibur Rashid,
3. Sir Afzaal Ahmad Zeeshan.

for their patient, kind and sincere help.The question is finally solved by removing some complexity, connecting my device to PC and running the application directly on virtual device.

Modified code:(Simplified by eliminating toolbars,name etc.,)
package com.vis.vis;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class VIS extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_vis);
        final Button btn = (Button)findViewById(R.id.button);
        final EditText et1 = (EditText) findViewById(R.id.editText);
        final EditText et2 = (EditText)findViewById(R.id.editText2);
        final EditText et3 = (EditText) findViewById(R.id.editText3);
        final EditText et4 = (EditText) findViewById(R.id.editText4);
        final TextView result = (TextView) findViewById(R.id.textView);
        btn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                int s1 = new Integer(et1.getText().toString());
                int s2 = new Integer(et2.getText().toString());
                int s3 = new Integer(et3.getText().toString());
                float a = new Integer(et4.getText().toString());
                float end;
                end = (float) (((s1 + s2 + s3) / 7.5) + (a / 10));
                if (end <= 40) {
                    end = (40 - end) * 2;
                    result.setText("The marks needed to pass in your end semester:  " + end);
                } else {
                    end = (end - 40) / 2;
                    result.setText("Additional marks that you have :" + end);
                }

            }
        });



    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_vi, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}


这篇关于生成的apk在安装后突然崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆