1. Are you ready for the Galaxy S20? Here is everything we know so far!

Android Emulator App Not Launcing

Discussion in 'Android Development' started by United Nations, Jan 14, 2016.

  1. United Nations

    Thread Starter

    I have created a project in Android Studio: package com.example.apps.newapplication; Java code:

    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.RelativeLayout;
    import android.widget.Button;


    publicclassMainActivityextendsAppCompatActivity{

    @override
    protectedvoid onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    RelativeLayoutDakotasLayout=newRelativeLayout(this);
    Button redButton =newButton(this);

    DakotasLayout.addView(redButton);
    setContentView(DakotasLayout);

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

    FloatingActionButton fab =(FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(newView.OnClickListener(){
    @override
    publicvoid onClick(View view){
    Snackbar.make(view,"Replace with your own action",Snackbar.LENGTH_LONG)
    .setAction("Action",null).show();
    }
    });
    }

    @override
    publicboolean onCreateOptionsMenu(Menu menu){
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    returntrue;
    }

    @override
    publicboolean 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){
    returntrue;
    }

    returnsuper.onOptionsItemSelected(item);
    }
    }
    Manifest.xml code:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app.newapplication">

    <application>
    android:allowBackup="true"
    android:icon="@Mipmap/ic_launcher"
    android:label="@String/app_name"
    android:supportsRtl="true"
    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>
    </application>

    </manifest>
    The problem is my app shuts down every time I launch it in the emulator. I'm not sure what's wrong in my java file. It might be my manifest file that's wrong, but I'm not sure.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Deleted User

    Deleted User Guest

Loading...
Similar Threads - Android Emulator App
  1. Attila Gubanyi
    Replies:
    0
    Views:
    262
  2. h110m
    Replies:
    0
    Views:
    767
  3. Hedwig7s
    Replies:
    0
    Views:
    729
  4. Richard Morey
    Replies:
    5
    Views:
    2,154
  5. workbench
    Replies:
    2
    Views:
    1,589
  6. brentc
    Replies:
    1
    Views:
    1,281
  7. Ulrich Hansa
    Replies:
    1
    Views:
    1,065
  8. cjnewman28
    Replies:
    2
    Views:
    2,684
  9. Mark WoodPatrick
    Replies:
    4
    Views:
    3,705
  10. Atsix26
    Replies:
    0
    Views:
    2,747

Share This Page

Loading...