Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法在设备上运行应用程序 我在虚拟仿真器上运行了我的应用程序,它运行得很好。然而,当我尝试在设备上运行它时,该应用程序停止工作。 清单文件如下所示:_Android_Error Handling - Fatal编程技术网

Android 无法在设备上运行应用程序 我在虚拟仿真器上运行了我的应用程序,它运行得很好。然而,当我尝试在设备上运行它时,该应用程序停止工作。 清单文件如下所示:

Android 无法在设备上运行应用程序 我在虚拟仿真器上运行了我的应用程序,它运行得很好。然而,当我尝试在设备上运行它时,该应用程序停止工作。 清单文件如下所示:,android,error-handling,Android,Error Handling,我在清单文件中添加了意图过滤器,但是应用程序仍然没有运行。在设备上启动应用程序时,应用程序即时关闭,显示消息应用程序已停止工作 I ran my app on virtual emulator and it ran fine. However when I tried to run it on a device, the app stops working. The manifest file is as follows: <application android:

我在清单文件中添加了意图过滤器,但是应用程序仍然没有运行。在设备上启动应用程序时,应用程序即时关闭,显示消息应用程序已停止工作

I ran my app on virtual emulator and it ran fine. However when I tried to run it on a device, the app stops working. 

The manifest file is as follows:

 <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="false"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Activity2">
            <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name=".Activity_3">
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name=".Taskplanner" />
        <activity android:name=".Activity_4" >
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
Main_Activity.java-单击按钮时,此活动包含基本信息,并链接到其他两个活动Activity2.java和Task.java。
公共类MainActivity扩展了AppCompatActivity{
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
公共void onclick(视图)
{
意向i=新意向(此,Activity2.class);
星触觉(i);
}
公共void gotoplanner(视图)
{
意图i=新意图(此,Taskplanner.class);
星触觉(i);
}
}
Activity2.java-此活动通过按钮链接到mainactivity和Activity3.java。它通过意图将消息传递给Activity3.java。
公共类Activity2扩展AppCompativeActivity实现AdapterView.OnItemSelectedListener{
字符串[]城市名称={“艾哈迈达巴德”、“阿格拉”、“阿姆利则”、“班加罗尔”、“博帕尔”、“布巴内斯瓦尔”、“昌迪加尔”、“钦奈”、“德拉敦”、“德里”、“甘托克”、“果阿”、“海得拉巴”、“斋浦尔”、“高知”、“加尔各答”、“勒克瑙”、“孟买”、“帕特纳”、“普纳”、“希隆”、“西姆拉”、“斯利那加”、“特里凡得鲁姆”、“乌代布尔”};
纺纱机;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_2);
//获取Spinner实例并在其上应用OnItemSelectedListener
喷丝器喷丝器2=(喷丝器)findViewById(R.id.spinnerto);
喷丝头2.SetonimSelectedListener(此);
//创建具有citynames列表的ArrayAdapter实例
ArrayAdapter aa=新的ArrayAdapter(这是android.R.layout.simple\u spinner\u项,citynames);
aa.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
ArrayAdapter aa2=新的ArrayAdapter(这是android.R.layout.simple\u spinner\u项,citynames);
aa2.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
//在微调器上设置ArrayAdapter数据
喷丝头2.固定接头(aa2);
}
@凌驾
已选择公共位置(AdapterView arg0、视图arg1、整型位置、长id){
Toast.makeText(getApplicationContext(),citynames[position],Toast.LENGTH\u LONG.show();
}
@凌驾
未选择公共无效(AdapterView arg0){
//TODO自动生成的方法存根
}
公共void gotohome(视图)
{
意图i=新意图(此,MainActivity.class);
星触觉(i);
}
公共void gotoinfo(视图)
{
微调器=(微调器)findViewById(R.id.spinnerto);
字符串spin=spinner.getSelectedItem().toString();
意向i=新意向(本活动为3类);
i、 putExtra(“消息”,spin);
星触觉(i);
}
}
Activity3.java—他的活动通过按钮链接到Activity2.java和Activity4.java。它通过意图将消息传递给Activity4.java。
公共课堂活动_3扩展了AppCompative活动{
私有ListView listplace;
专用数据库助手数据库助手;
专用阵列适配器;
字符串消息;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_3);
databaseHelper=新的databaseHelper(此);
Bundle data=getIntent().getExtras();
如果(数据==null)
{
返回;
}
Message=data.getString(“Message”);
Bundle data2=getIntent().getExtras();
如果(数据2==null)
{
返回;
}
Message=data.getString(“Message”);
日志d(“插入”、“插入位置数据”);
//databaseHelper.save(新地方(“阿格拉”,“北方邦”,“印地语,乌尔都语,旁遮普语,英语”,“炎热干燥的夏天,温和的季风和温和的冬天”,“这座城市以莫卧儿美食而闻名。阿格拉的Pethas在全国也非常有名。”,“泰姬陵马霍察夫,拉姆·巴拉特,泰姬陵文学节,凯拉什集市,恒高集市”,“公共汽车、人力车和自动人力车。一个人必须乘汤加车离开泰姬陵几公里。”);
//databaseHelper.save(新建议(“阿格拉”、“泰姬陵”、“阿格拉堡”、“法特赫布尔锡克里”、“锡坎达尔(阿克巴陵墓)”、“贾马·马斯吉德”、“马里亚姆陵墓”、“基瑟姆湖”、“莫卧儿遗产步行道”、“拉姆·巴格”、“梅赫塔布·巴格”);
Log.d(“读取”、“读取所有数据”);
List listplace=databaseHelper.findAllp();
用于(位置b:列表位置){
Log.d(“数据”,“ID:+b.getId()+”;城市:+b.getCity()+“;州:+b.getState()+”语言:+b.getLanguage()+”\n |气候:+b.getWeather()+”\n |烹饪:+b.GetCouncy()+“\n |节日和博览会:+b.getFandf());
}
Log.d(“读取”、“读取所有数据”);
List listsuggestion=databaseHelper.findAll();
对于(建议b:列表建议){
Log.d(“数据”,“ID:+b.getId()+”| Cit
Main_Activity.java- This activity contains a basic info and is linked to 2 other activites Activity2.java and Task.java when the buttons are clicked.

    public class MainActivity extends AppCompatActivity {

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

        }

        public void onclick(View view)
        {
            Intent i=new Intent(this,Activity2.class);
            startActivity(i);
        }
        public void gotoplanner(View view)
        {
            Intent i=new Intent(this,Taskplanner.class);
            startActivity(i);
        }

    }

 Activity2.java- This activity is linked to the mainactivity and Activity3.java through buttons. It passes a message through an intent to Activity3.java.

       public class Activity2 extends AppCompatActivity implements AdapterView.OnItemSelectedListener {

        String[] citynames={"Ahmedabad","Agra","Amritsar","Bangalore","Bhopal","Bhubaneshwar","Chandigarh","Chennai","Dehradun","Delhi","Gangtok","Goa","Hyderabad","Jaipur","Kochi","Kolkata","Lucknow","Mumbai","Patna","Pune","Shillong","Simla","Srinagar","Trivandrum","Udaipur"};
        Spinner spinner;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_2);


    //Getting the instance of Spinner and applying OnItemSelectedListener on it

            Spinner spinner2 = (Spinner) findViewById(R.id.spinnerto);
            spinner2.setOnItemSelectedListener(this);

    //Creating the ArrayAdapter instance having the citynames list
            ArrayAdapter aa = new ArrayAdapter(this,android.R.layout.simple_spinner_item,citynames);
            aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

            ArrayAdapter aa2 = new ArrayAdapter(this,android.R.layout.simple_spinner_item,citynames);
            aa2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

            //Setting the ArrayAdapter data on the Spinner
            spinner2.setAdapter(aa2);
        }

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int position,long id) {
            Toast.makeText(getApplicationContext(), citynames[position], Toast.LENGTH_LONG).show();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
    // TODO Auto-generated method stub

        }
        public void gotohome(View view)
        {
            Intent i=new Intent(this,MainActivity.class);
            startActivity(i);
        }
        public void gotoinfo(View view)
        {
            spinner=(Spinner) findViewById(R.id.spinnerto);
            String spin=spinner.getSelectedItem().toString();
            Intent i=new Intent(this,Activity_3.class);
            i.putExtra("Message",spin);
            startActivity(i);

        }
    }

Activity3.java-his activity is linked to the Activity2.java and Activity4.java through buttons. It passes a message through an intent to Activity4.java.

    public class Activity_3 extends AppCompatActivity {

        private ListView listplace;
        private DatabaseHelper databaseHelper;
        private ArrayAdapter adapter;
        String Message;


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

            databaseHelper= new DatabaseHelper(this);

            Bundle data=getIntent().getExtras();
            if(data==null)
            {
                return;
            }
            Message=data.getString("Message");

            Bundle data2=getIntent().getExtras();
            if(data2==null)
            {
                return;
            }
            Message=data.getString("Message");

            Log.d("insert", "inserting data for Place");
    //databaseHelper.save(new Place("Agra","Uttar Pradesh","Hindi,Urdu,Punjabi,English","Hot and dry summers along with mild monsoon and mild winters ","The city is famous for the Mughal cuisine. Pethas from Agra are also very  famous around the country.","Taj Mahotsav, Ram Barat,Taj Literature Festival,Kailash Fair,Gangaur Fair","Buses, Rickshaws and auto rickshaws. One has to take a Tonga a few kilometres away from Taj Mahal."));
            //databaseHelper.save(new Suggestion("Agra","Taj Mahal","Agra Fort","Fatehpur Sikri","Sikandar(Akbar’s Tomb)","Jama Masjid","Mariam’s Tomb","Keetham Lake","Mughal Heritage Walk","Ram Bagh","Mehtab Bagh"));

     Log.d("reading", "reading all data");
            List<Place> listplace = databaseHelper.findAllp();
            for (Place b : listplace) {
                Log.d("data", "ID :" + b.getId() + " | City :" + b.getCity() + " | State :" + b.getState() + "Language :" + b.getLanguage() + " \n| Climate :" + b.getWeather() + " \n| Cuisine :" + b.getCuisine() + " \n| Festival and Fair :" + b.getFandf());
            }

            Log.d("reading", "reading all data");
            List<Suggestion> listsuggestion = databaseHelper.findAll();
            for (Suggestion b : listsuggestion) {
                Log.d("data", "ID :" + b.getId() + " | City :" + b.getCity() + " | Place 1 :" + b.getPlace1());

            }


        }
        public void gotoselect(View view)
        {
            Intent i=new Intent(this,Activity2.class);
            startActivity(i);
        }

        public void gotoplannerinformation(View view)
        {
            Intent i=new Intent(this,Activity_4.class);
            i.putExtra("City_Name",Message);
            startActivity(i);
        }

        public void onaddinformation(View view)
        {

                listplace = (ListView) findViewById(R.id.listplace);
                Place p = databaseHelper.findOnep(Message);
                Suggestion s = databaseHelper.findOne(Message);
                String[] ans = {"CITY:\n" + p.getCity(), "STATE:\n" + p.getState(), "LANGUAGE:\n" + p.getLanguage(), "CLIMATE:\n" + p.getWeather(), "CUISINE:\n" + p.getCuisine(), "FESTIVALS AND FAIRS:\n" + p.getFandf(), "TRANSPORT:\n" + p.getTransport(), "PLACES:", s.getPlace1(), s.getPlace2(), s.getPlace3(), s.getPlace4(), s.getPlace5(), s.getPlace6(), s.getPlace7(), s.getPlace8(), s.getPlace9(), s.getPlace10()};
                adapter = new ArrayAdapter(getApplicationContext(), R.layout.custom_view, ans);
                listplace.setAdapter(adapter);



        }
    }

Activity4.java:

    public class Activity_4 extends AppCompatActivity implements AdapterView.OnItemSelectedListener {

        String[] no_of_days= {"2 days","3 days"};
        Spinner spinner;
        String city_name;
        String noofdays;

        private DatabaseHelperPlanner databasehelper;
        TextView text2;
        TextView text3;
        TextView text4;
        TextView text5;
        TextView text6;
        TextView text7;
        TextView text8;
        TextView text9;
        TextView text10;
        TextView text11;
        TextView text12;
        TextView text13;
        TextView text14;
        TextView text15;
        TextView text16;


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

            //Spinner
            spinner = (Spinner) findViewById(R.id.days);
            spinner.setOnItemSelectedListener(this);
            ArrayAdapter aa = new ArrayAdapter(this,android.R.layout.simple_spinner_item,no_of_days);
            aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(aa);

            Bundle data=getIntent().getExtras();
            if(data==null)
            {
                return;
            }
            city_name=data.getString("City_Name");

            databasehelper=new DatabaseHelperPlanner(this);

            Log.d("insert", "inserting data for Place");
     databasehelper.save(new Planner("Ahmedabad","3 days","Day 1:","10 :00 am-Sabarmati Ashram (8:30 am- 6:30 pm)- People usually take 2 hours visiting the Ashram.",
                    "12:30 pm-Sabarmati River Front (6:00 am-10:00 pm)-People usually spend around half an hour here.","3:00 pm-Adalaj Stepwell (8:00 am– 7:00 pm)- People usually take 30 minutes to 1 hour to visit the Stepwell.","","","Day 2:","9:00 am-Kankaria Lake (9:00 am -10:00 pm)- People usually take an hour to visit the Lake.","11:30 am-Hutheesing Jain Temple (8:00 am -8:00 pm)- People usually take around an hour to visit the temple","2:30 pm-Bhadra Fort(9:00 am-5:00pm)-People usually take an hour to visit the Fort."
                    ,"5:00 pm-Sarkhej Roja(9:00 am-6:00 pm)-People usually take an hour to visit the lake.","7:00 pm-Auto World Vintage Car Museum (8:00 am-9:00pm)- People spend around one to two hours here.","DAY 3:","10:00 am-Calico Museum of Textiles (10:15 am-12:30 pm (Wednesday Closed))-People usually spend two hours here.","5:30 pm- Akshardham Temple (9:30 am – 7:30 pm)-People usually take 2-3 hours to visit the Temple."));

    Log.d("reading", "reading all data");
            List<Planner> listplann = databasehelper.findAll();
            for (Planner b : listplann) {
                Log.d("data", "ID :" + b.getId() + " | City :" + b.getCity() + " | Days :" + b.getDay());
            }





        }

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) {
            Toast.makeText(getApplicationContext(), no_of_days[position], Toast.LENGTH_LONG).show();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
    // TODO Auto-generated method stub

        }

        public void gototravelinfo(View view)
        {
            Intent i=new Intent(this,Activity_3.class);
            i.putExtra("Message",city_name);
            startActivity(i);
        }

        public void gotonextpage(View view)
        {

            noofdays=spinner.getSelectedItem().toString();

            Planner planner = databasehelper.findOne(city_name,noofdays);

            text2=(TextView)findViewById(R.id.text2);
            text3=(TextView)findViewById(R.id.text3);
            text4=(TextView)findViewById(R.id.text4);
            text5=(TextView)findViewById(R.id.text5);
            text6=(TextView)findViewById(R.id.text6);
            text7=(TextView)findViewById(R.id.text7);
            text8=(TextView)findViewById(R.id.text8);
            text9=(TextView)findViewById(R.id.text9);
            text10=(TextView)findViewById(R.id.text10);
            text11=(TextView)findViewById(R.id.text11);
            text12=(TextView)findViewById(R.id.text12);
            text13=(TextView)findViewById(R.id.text13);
            text14=(TextView)findViewById(R.id.text14);
            text15=(TextView)findViewById(R.id.text15);
            text16=(TextView)findViewById(R.id.text16);
            text2.setText(planner.getOne_view());
            text3.setText(planner.getTwo_view());
            text4.setText(planner.getThree_view());
            text5.setText(planner.getFour_view());
            text6.setText(planner.getFive_view());
            text7.setText(planner.getSix_view());
            text8.setText(planner.getSeven_view());
            text9.setText(planner.getEight_view());
            text10.setText(planner.getNine_view());
            text11.setText(planner.getTen_view());
            text12.setText(planner.getEleven_view());
            text13.setText(planner.getTwelve_view());
            text14.setText(planner.getThirteen_view());
            text15.setText(planner.getFourteen_view());
            text16.setText(planner.getFifteen_view());
        }
    }



The logcat shows the following error on running the app on device.



     E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
 E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
    <service
        android:name=".MyFirebaseInstanceIDService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
        </intent-filter>
    </service>