Reputation: 9502
I have just started learning Android development. On my Android Studio 1.2.2, I created an Blank Activity. According to my understanding, this empty project should still be able to run on both real android device and emulator.
But, When I run the project, I run into this following error:
I have checked my Android SDK Manager and the correct (i believe?) SDK build tool is installed.
Also, the correct version is specified in build.gardle
file.
What could be the cause of this problem?
UPDATE 1
This is the auto-generated code from the project.
UPDATE 2
The error message suggest that line 7 of my activity_myactivity_my.xml
AGPBI: {"kind":"ERROR","text":"Resource id cannot be an empty string (at \u0027id\u0027 with value \u0027@+id/\u0027).","sourcePath":"C:\Users\Chris Aung\AndroidStudioProjects\MyFirstApp\app\src\main\res\layout\activity_myactivity_my.xml","position":{"startLine":7,"startColumn":17,"startOffset":487,"endColumn":22,"endOffset":492},"original":""}
And my line 7 of that file looks like this
Upvotes: 1
Views: 608
Reputation: 43322
Just remove the android:id
.
I just created a Blank Activity project, and here is the default layout created that gives no errors:
<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=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
Upvotes: 2
Reputation: 9502
I managed to solve this problem by deleting the line 7 android:id="@+id/"
from the activity_myactivity_my.xml
. Now it is running fine.
Upvotes: 0
Reputation: 3043
This can happen when gradle fails to process resources. The resource can be your XML file or might be drawable file. An example, when you have a jpeg file, but you change the extension to PNG, it will generate the same error too. Check your resources folder. And you have red(error) in your activity. Is it code error or because gradle fail to build Resource class (R.java)?
Upvotes: -1