The first error ("The activity 'MainActivity' is not declared in AndroidManifest.xml") means exactly what it says. There is a file in your project named AndroidManifest.xml
and you must declare all Activity
s in this file. Here's the manifest created by Android Studio for a new project:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
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>
Two important things to note:
1) The package
attribute of the <manifest>
tag (on line 3 in this example) must match the package name you're using for your Java code.
2) There must be an <activity>
tag for your MainActivity
(see line 12 in the example).
The second error ("String types not allowed (at 'activity_horizontal_margin')") is harder to debug without your code, but here's a guess. The page you linked two includes these two lines:
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
You have to make sure (a) that you did not remove the @dimen/
prefix from these, and (b) that you have declared a dimen
resource with the name activity_horizontal_margin
. Usually that would be done by creating res/values/dimens.xml
with content something like:
<resources>
<dimen name="activity_horizontal_margin">16dp</dimen>
</resources>
You could also replace these dimen
resource references with in-place values, like this:
android:paddingLeft="16dp"
android:paddingRight="16dp"