1

I am learning Android with tutorial from his page, and I have problem in part: Running Your App chapter. When I see activity_my.xml preview I see "Hello world" text, but when I run application and see emulated device, emulator shows device with only black page and "android" text. I think I can't start it properly, but in Android Studio console I see:

C:\Users\Abc\AppData\Local\Android\sdk\tools\emulator.exe 
-avd Nexus_4_cale -netspeed full -netdelay none

creating window 208 44 800 480
emulator: emulator window was out of view and was recentered

So it seems to be ok. But if I choose to edit "app" configuration, in Target Device / Emulator I see that Prefer Adroid Virtual Device, in my calse, called "Nexus_4_cale", is red. But if I edit this device there is no errors etc.. I don't know what's happening, and I will be happy if anybody would like to help me with this problem - thank you in advance.

That is how it looks in emulator: Emulator

And that is how it looks in Android Studio preview: Preview_in_IDE

And that is configuration, with red device but with no explanation: configuration

Code for activity_my.xml:

<RelativeLayout 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"     android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MyActivity">

<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

And code for MyActivity.java class:

package com.example.abc.android3;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;


public class MyActivity extends ActionBarActivity {

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


@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_my, 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);
}
}

All code is generated by Android Studio

Radek Anuszewski
  • 1,812
  • 8
  • 34
  • 62

3 Answers3

2

Its in Loading.. You have to wait for loading to complete. If still your emulator is not starting than edit your emulator configuration by uncheck Use Host Gpu For more check Can't start emulator for Android Studio

Community
  • 1
  • 1
Subhalaxmi
  • 5,687
  • 3
  • 26
  • 42
0

Sorry for wasting your time - it is loading view, but it was so slow... Over 20 minutes until I saw something and it was reason that I thought something is wrong - simply I wait a little more time and saw what I want.

Radek Anuszewski
  • 1,812
  • 8
  • 34
  • 62
0

If you are not seeing any errors and you are using Mac. Make sure you don't have Docker up and running. The moment I turned off Docker, it all worked. Can't believe the 2 hours I spent for the debugging.

Alison Z
  • 85
  • 1
  • 8