Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve the Android Studio error where it cannot find the project's Manifest file?

I am migrating my legacy project from Eclipse to Android studio. I did the following things:

  • Export and generate gradle build files in eclipse
  • Imported the Gradle.build file in Android Studio
  • Changed my gradle version dependencies to: classpath 'com.android.tools.build:gradle:0.9.+'

My root folder of the project contains 3 library projects: Actionbarsherlock, Authbahn and library. My root folder also contains the main project called JohelpenHulpverlener.

enter image description here

After resolving a lot of errors I get the following error:

Error:A problem was found with the configuration of task ':checkDebugManifest'.
> File 'C:\android\jeugdformaat\JohelpenHulpverlener\AndroidManifest.xml' specified for property 'manifest' does not exist.

My root build.gradle looks like this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
    compile project(":actionbarsherlock")
}

android {
    compileSdkVersion 17
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 19
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

My build.gradle in the main project looks like this:

apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':library')
    compile project(':actionbarsherlock')
    compile project(':autobahn')
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

I am trying to understand this, hopefully someone can help me out here!

like image 735
Fergers Avatar asked Mar 12 '14 15:03

Fergers


2 Answers

You've got a bunch of stuff in your root-level Gradle build file that's making the build system think there's an Android module there (it's not; it's a subdirectory below inside JohelpenHulpverlener) , and it's failing because it's not finding the manifest.

I think if you take a lot of stuff out of your root-level build.gradle file and replace it with the default version for new projects, which is this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

it will work.

like image 50
Scott Barta Avatar answered Oct 09 '22 10:10

Scott Barta


Make sure you have tags on the outside like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example"
    android:versionCode="1"
    android:versionName="1.0" >

    ...

</manifest>
like image 37
ElectronicGeek Avatar answered Oct 09 '22 10:10

ElectronicGeek