android hello world

Answered

this is my android hello world project trying to familiarize myself with this.


So this is a basic program and i was working off the example from this link ==> https://developer.android.com/training/basics/firstapp/creating-project

I couldnt run it and i believe i followed the instructions on that page.

0
19 comments

It looks like you don't have Android SDK configured in IntelliJ IDEA. Make sure the project builds from the command line first.

0
Avatar
Permanently deleted user


my current SDK path

0

You need Android platform added in the SDKs and specified for the module:

0
Avatar
Permanently deleted user

my settings match yours.

 

MY projet sdj is also set to android 28 api.

0

Please share a sample project to reproduce the issue.

0
Avatar
Permanently deleted user
package com.example.syn.coinpay;

import android.os.Bundle;

public class MainActivity extends AppCompactActivity {

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

}

This is literally it.
0
Avatar
Permanently deleted user

0

Does it also fail in the command line Gradle build outside of IntelliJ IDEA?

0
Avatar
Permanently deleted user

how would i do that? I dont use gradle at all.

0

Your Android project is Gradle based, run `gradle build` in the project root directory in the command line.

0
Avatar
Permanently deleted user

cant find tools.jar, check java/jre1.8.0_191 contains a valid jdk installation?

0

Make sure you have JDK installed and JAVA_HOME pointing to the JDK, not JRE. Also make sure PATH contains bin location from JDK.

0
Avatar
Permanently deleted user

this is what i got

 

> Task :app:compileDebugJavaWithJavac FAILED
file or directory 'C:\Users\Syn\Desktop\Bitcoin Project\CoinPay2\app\src\debug\j
ava', not found
Task ':app:compileDebugJavaWithJavac' is not up-to-date because:
Task has failed previously.
All input files are considered out-of-date for incremental task ':app:compileDeb
ugJavaWithJavac'.
Compiling with source level 1.7 and target level 1.7.
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed,
no previous execution, etc.).
file or directory 'C:\Users\Syn\Desktop\Bitcoin Project\CoinPay2\app\src\debug\j
ava', not found
Compiling with JDK Java compiler API.
C:\Users\Syn\Desktop\Bitcoin Project\CoinPay2\app\src\main\java\com\example\syn\
coinpay\MainActivity.java:5: error: cannot find symbol
public class MainActivity extends AppCompactActivity {
^
symbol: class AppCompactActivity
C:\Users\Syn\Desktop\Bitcoin Project\CoinPay2\app\src\main\java\com\example\syn\
coinpay\MainActivity.java:7: error: method does not override or implement a meth
od from a supertype
@Override
^
C:\Users\Syn\Desktop\Bitcoin Project\CoinPay2\app\src\main\java\com\example\syn\
coinpay\MainActivity.java:9: error: cannot find symbol
super.onCreate(savedInstanceState);
^
symbol: variable super
location: class MainActivity
C:\Users\Syn\Desktop\Bitcoin Project\CoinPay2\app\src\main\java\com\example\syn\
coinpay\MainActivity.java:10: error: cannot find symbol
setContentView(R.layout.activity_main);
^
symbol: variable activity_main
location: class layout
4 errors
:app:compileDebugJavaWithJavac (Thread[Task worker for ':',5,main]) completed. T
ook 0.582 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

path is set to jdk 1.8.0 bin folder

 

java home is set to just jdk 1.8.0 folder.

 

I echoed both to verify the settings is there.

 

0
Avatar
Permanently deleted user

uploaded https called CoinPay2.rar

0

The problem appears to be with your code (a typo, most likely):

public class MainActivity extends AppCompactActivity

it should be:

public class MainActivity extends AppCompatActivity

instead. Notice the name AppCompatActivity, it comes from Compatibility, not from Compact.

Another problem is that you don't have CoinPay2\app\src\main\res\layout\activity_main.xml layout file, you will need it for the project to compile since it's referenced from the activity:

setContentView(R.layout.activity_main);

The dummy layout/activity_main.xml file may look like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

</LinearLayout>
0
Avatar
Permanently deleted user

got it to parse fine now. but im getting emulator issues.

 

in event log...

 

6:57 PM Emulator: Warning: Quick Boot / Snapshots not supported on this machine. A CPU with EPT + UG features is currently needed. We will address this in a future release.

6:57 PM Emulator: audio: Failed to create voice `goldfish_audio_in'

6:57 PM Emulator: qemu-system-x86_64.exe: warning: opening audio input failed

6:57 PM Emulator: audio: Failed to create voice `adc'

 

when the emulator device is semming finisheed loading it never loads the test app.

 

[code]

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

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

}
[/code]

[code]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

</LinearLayout>
[/code]
[code]
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.syn.coinpay">
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
[/code]
0
Avatar
Permanently deleted user

it didnt like MainActivity so i changed it to mainactivity and it works. I gotten used to those naming conventions.

 

I was able to successfully run the program on the emulator and build the apk to put it on my phone. But what i would like is for it to pick up my phone and just push the app that way saves time.

 

But the problem is when my phone tries to download the drivers but fails on the "Android" driver. Any suggestions?

0

Please direct general programming and Android development questions to https://stackoverflow.com/.

0

Please sign in to leave a comment.