unresolved classes and Attribute errors in the manifest

Viewed 170

I am new to android developing, I had some errors which I couldn't find a solution for. The problem is with the Manifest.xml file and the styles file. This is the Manifest file and I get the following errors: Attribute android:allowBackup is not allowed here Attribute android:icon is not allowed here Attribute android:roundIcon is not allowed here Attribute android:supportsRtl is not allowed here Attribute android:theme is not allowed here Unresolved package 'activities' Unresolved class 'MyDiagnosisActivity'

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<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=".activities.MyDiagnosisActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

</application>
This is the strings file
<resources>
<string name="app_name">MyDiagnosis</string>
<string name="drawer_open">Open navigation drawer</string>
<string name="drawer_close">Close navigation drawer</string>
</resources>

This is the build.gradle file

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.mydiagnosis"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        javaCompileOptions({
            annotationProcessorOptions {
                arguments = ["room.schemaLocation":"$projectDir/schemas".toString()]
            }
        })
    }

compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'

    implementation "com.squareup.retrofit2:retrofit:2.4.0"
    implementation "com.squareup.retrofit2:converter-gson:2.3.0"
    implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
    implementation 'com.squareup.okhttp3:okhttp:4.0.0-alpha02'
    implementation("com.squareup.okhttp3:logging-interceptor:4.0.0-alpha02")
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1'

    def room_version = "1.1.1"

    implementation 'android.arch.lifecycle:extensions:1.1.1'
    kapt "android.arch.lifecycle:compiler:1.1.1"

    implementation 'com.facebook.stetho:stetho:1.5.1'

    implementation "android.arch.persistence.room:runtime:$room_version"
    implementation "android.arch.persistence.room:testing:$room_version"
    kapt "android.arch.persistence.room:compiler:$room_version"

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    testImplementation "io.mockk:mockk:1.9.3"

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
}

Also there is an error in the Styles file: Cannot resolve symbol 'colorPrimary' Cannot resolve symbol 'colorPrimaryDark' Cannot resolve symbol 'colorAccent'

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">#673AB7</item>
    <item name="colorPrimaryDark">#512DA8</item>
    <item name="colorAccent">#FF4081</item>
</style>

Note: I have already tried: Rebuild the project, Invalidate and restart, change the android version to beta, change anything in the Gradle file and then sync and then undo and resync. Sorry if my problem may seem so dumb, I am a high school student and I have tried my best to solve these errors. Thank you in advance

1 Answers

UPDATE

Find the build.gradle file in the root directory of your project and rewrite the file as

 repositories {
        maven{ url'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        jcenter()
    }

You need to add the following to your manifest.

<application
        tools:replace="android:icon,android:allowBackup">
<manifest package="xxx"
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools">

Hope this could help with your issue. :)

Related