• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Emulator Problem

For a month now I've not been able to get a proper function from my emulator. Here's a group of error messages I get today in the Event log:

I would have removed this thread since I moved it to App Development but I don't see a link to remove it from this area.


Code:
9/17/2019
6:03 AM    * daemon not running; starting now at tcp:5037

6:03 AM    * daemon started successfully

6:03 AM    Gradle sync started with single-variant sync

6:03 AM    Project setup started

6:03 AM    Gradle sync finished in 3 s 989 ms (from cached state)

6:04 AM    Executing tasks: [:app:generateDebugSources] in project C:\Users\Shelby\AndroidStudioProjects\JavaArrays

6:04 AM    NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN

6:04 AM    Gradle build finished in 30 s 252 ms

6:08 AM    Executing tasks: [:app:assembleDebug] in project C:\Users\Shelby\AndroidStudioProjects\JavaArrays

6:08 AM    Emulator: dsound: Could not initialize DirectSoundCapture

6:08 AM    Emulator: dsound: Reason: No sound driver is available for use, or the given GUID is not a valid DirectSound device ID

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: audio: Failed to create voice `goldfish_audio_in'

6:08 AM    Emulator: C:\Users\Shelby\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: warning: opening audio input failed

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: audio: Failed to create voice `adc'

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: audio: Failed to create voice `adc'

6:09 AM    Gradle build finished in 17 s 347 ms

6:09 AM    Install successfully finished in 566 ms.: App restart successful without requiring a re-install.

6:09 AM    Executing tasks: [:app:assembleDebug] in project C:\Users\Shelby\AndroidStudioProjects\JavaArrays

6:09 AM    Gradle build finished in 3 s 339 ms

6:09 AM    Install successfully finished in 667 ms.: App restart successful without requiring a re-install.

Here's the entire project which I am building from an android classroom from udemy.com by my instructor .

Code:
package com.swayzeconstruction.javaarrays;

public class Main {
    public static void main(String[] args) {
        String[] names = new String[5];
        names[0] = "Shelby";
        names[1] = "Jaam";
        names[2] = "Bisous";
        names[3] = "Felix";
        names[4] = "Hadi";

        System.out.println(names[3]);
        int[] numbers = new int[5];  //apparently gives all values of array
        //or the following
    }

    {
        String[] names2 = new String[5];
        System.out.println(names2[2]);  //gives second value of array
        // or the following
    }

    {
        String[] names3 = new String[5];
        {
            System.out.println(names3[2]);
            int[] numbers = {1, 2, 3, 4, 5};  //note: using curly braces
            System.out.println(numbers[1]);   // to get second element
        }

    }
}

Any ideas? Thanks
 
Last edited:
Looks like the audio driver is failing but doesn't seem to be a crashing. Is the emulator starting up, just without audio?
 
Yes, the emulator displays, but only with a single phrase: Hello World. It seems to me as though it's a default display. There never needs to be audio with my project so I can't understand how to solve this supposed problem with the audio. My computer's audio is fine generally.
 
I got a message saying that sometimes an antivirus can mess up the working of android studio so I eliminated the following items from being scanned by my eset: nod32 virus protection:
Gradle cache
%USERPROFILE%\.gradle
Android Studio projects
%USERPROFILE%\AndroidStudioProjects
Android SDK
%USERPROFILE%\AppData\Local\Android
Android Studio system files
C:\Program Files\Android\Android Studio\system

So far I've seen no improvement. (However, I must say that some of my small project attempts don't seem to have a problem, while others do.)
 
Last edited:
Wseng, It didn't seem to crash, it just shows the 'Hello World' text.

Based on reviewing your code, that's not surprising. You have a standard Java program, not an Android app.

You need to define a main activity, both the XML and the Java code for it. Since you're getting "Hello world" I would say you have that already, so you need to update your code there.

And you can't use System.out.println for Android data output on the screen. You will have to set the text in the text fields defined in the related XML.

As for the audio error, if you don't need audio, I would ignore it.
 
Wseng, It didn't seem to crash, it just shows the 'Hello World' text.
There are nothing wrong with your emulator since it has successfully shown the "Hello World" text. The real issue is that you are not writing android app, instead you are writing a java program which include the main function, as what @23tony mentioned.
 
Thanks Guys,
I appreciate your clearing that up for me. I suppose I'm still lost as to how I can get my emulator to function, but I have a better idea of the workings of the IDE, etc.

Code:
package com.swayzeconstruction.operators;

public class HiWorld {
    public static void main(String[] args) {
        int a = 4;
        int b = 5;

        String hello = "Hello";
        String name = "Shelby";
        String greeting = hello + name;
        System.out.println("Greeting");


//SSS Can't get console view; don't know why

    }

My biggest problem now is that I cannot get my console to open and show the System.out.println to work (as it works on the tutorial that I'm learning from on Udemy.com).
 
Last edited:
You are still trying to run a regular Java program. You can't use System.out.println on Android. You don't really have a console. You need to work through the logs and the UI.

When you created your project, you should have had a Java file called something like MainActivity. You also should have had an XML file like activity_main.xml - this is where you need to do your work.

I've generally heard good things about Udemy, so I suspect you're trying a generic Java tutorial, not an Android one. You may want to consider working on learning Java in general first, before moving to Android - that way you're not trying to learn too much at once. If you want to do that, then you should get NetBeans or Eclipse, and the Java SDK - install those and try your program there.

If you really want to focus on Android, you'll need an Android-specific tutorial. I used this: https://developer.android.com/training/basics/firstapp/ but it's pretty dense. If that doesn't work for you, there's a ton of results searching for "Android Programming Tutorial" - just be sure whatever one you choose is specifically Android.

A couple more specific pointers:

In your MainActivity file you should have a class MainActivity. You will first be able to get code to execute in a function onCreate:
Code:
public class BaseActivity extends AppCompatActivity {
    private TextView mTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mTextView = findViewById(R.id.textView);
        mTextView.setText("Goodbye");
    }
}

- use that as an example. Find your activity_main.xml file and you can add new text boxes & such. That will be in the folder app/res/layout. If any tutorial you are using doesn't talk about what I just described, it's probably not an Android tutorial.
 
Thanks Tony for such a concise and easily readable reply. My udemy.com tutorial called "Complete Android Course for 2019" is starting with Java projects I guess and although I assume that it's not realized by the instructor (Meisam Mansourzadeh), that it's not clear to me what type of project he's using, i.e. types: Add No Activity, Basic Activity, Empty Activity, etc. when he starts a new project. Consequently I'm guessing which type of project I should use in the platform.
 
Last edited:
My udemy.com tutorial called "Complete Android Course for 2019" is starting with Java projects I guess

Which lesson are you on?

I reviewed the course outline. Based on that, it looks to me like you're plain Java up until the User interface section. It's definitely Android as of the Constraint Layout section.
 
Tony,
I was on lesson 10. Java Arrays but I backed up trying to see if I screwed up. I'm going through #6 now trying to ignore my inability to make my project respond like the instructor's project. Don't worry I'll hang in there trying to get what I can out of the course. Thanks for your efforts and comments. I'm concurrently learning B4A app code. That, I've been working on for a year.
 
Last edited:
Back
Top Bottom