0

I'm very new to Android Studio and I'm basically trying to open an existing project that I had downloaded and compile/run it. I am getting the following error when Gradle attempts to sync...

Error:Cannot read packageName from /Users/Amanda/Desktop/MyProject/src/main/AndroidManifest.xml

I have researched online and have tried several solutions, none of which have fixed my problem :/ I have also tried to "invalidate caches and restart" but it did not work either...

This is my Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="me.amanda.myproject.app">
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="My Project">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity
            android:name=".resourceListing"
            android:label="My App Listing">
        </activity>
        <activity
            android:name=".ListApps"
            android:label="@string/title_activity_list_apps">
        </activity>
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
</manifest>

My build.gradle:

buildscript {
    repositories {
       jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
apply plugin: 'com.android.application'

allprojects {
    repositories {
        mavenCentral()
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

}
dependencies {
}
unconditionalcoder
  • 723
  • 1
  • 13
  • 25

2 Answers2

0

some times clean cant delete some of build folder files.

try these steps :

1- make a copy of your manifest file and delete your manifest file from project.

2- delete your app/build folder.

3-then clean your project

4- add the manifest file again to src/main directory

5- clean the project again

6- rebuild the project

Amir Ziarati
  • 14,248
  • 11
  • 47
  • 52
0

Set your packageName as applicationIdin your build.gradle file.

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "me.amanda.myproject.app"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0.1"
}

Now, when you build apk your packageName will replace with defaultConfig > applicationId

Love Bdsobuj
  • 53
  • 1
  • 9