Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

:checkDebugManifest FAILED => file specified for property 'manifest' does not exist

Using this guide I want to build an existing project in Eclipse with Gradle.

build.grale contains:

buildscript {
repositories {
    mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:0.14.0'
    }
}
apply plugin: 'android'

android {
    buildToolsVersion "19.1.0"
    compileSdkVersion 16
}

repositories {
    mavenCentral()
}

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

But I get: enter image description here

How to resolve this issue? I tried for several hours different approaches but nothing seemed to work.

like image 930
burseaner Avatar asked Dec 10 '14 17:12

burseaner


2 Answers

The default project structure has changed, so unless you either tell the Gradle plugin where to find your manifest (and the rest of your code) or switch to the new structure, the Gradle plugin will look in the wrong place.

In your case, it is looking for the manifest at\src\main\AndroidManifest.xml, which is the default for new Gradle projects. The old project structure (used by Eclipse + ADT) puts the manifest in the root of your project at \AndroidManifest.xml.

You can specify an alternate location in your build.gradle using a sourceSets closure like so:

android {
    // ...

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

        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
}

This will configure the Android Gradle plugin to use the old project structure for your manifest, Java sources, and resources.

If you use Android Studio's import tool, it should take care of all of this for you.

like image 140
Bryan Herbst Avatar answered Nov 04 '22 06:11

Bryan Herbst


That guide has nothing to do with building an existing Eclipse project with Gradle. The word "Eclipse" appears nowhere in the guide.

If you are trying to move to Android Studio, use the Android Studio project import wizard.

If you are trying to use Eclipse, but also offer Gradle builds, you can run the Eclipse export wizard to generate a build.gradle file, though it will require some additional tweaking, as that wizard has not been updated in ages.

Or, start with this build.gradle file and adjust to suit:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}
apply plugin: 'com.android.application'

dependencies {
    compile 'com.android.support:support-v4:21.0.0'
}

android {
    compileSdkVersion 19
    buildToolsVersion "20.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')
    }
}
like image 1
CommonsWare Avatar answered Nov 04 '22 07:11

CommonsWare