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

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:
How to resolve this issue? I tried for several hours different approaches but nothing seemed to work.

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.

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')
}
}

Related

Gradle apk file missing dependencies

I am new to Gradle. I have been looking for a solution to my problem for several hours now but cannot get my build to work correctly. Basically I have an Android project that I am trying to build using Gradle. I have a libs directory in my project that contains dependencies. It appears the build knows that they are there because it uses them when compiling the application. However, when the apk is assembled the dependencies are not in the apk. I am trying to get this to generate an apk file that is similar to the apk that is generated when you perform an Export from MyEclipse. The apk generated from the MyEclipse export has a lib directory as well as an org directory so I know the dependencies are in that apk. The apk generated from Gradle has neither. Here is my build.gradle file.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "23.0.2"
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}

build.gradle file error in Android Studio can't applied main & dependencies

I have problem with Android Studio in build.gradle after I converted Eclipse project to Android Studio project.
I spent more than 2 hours finding a solution, with no results!!
build.gradle code:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "17.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')
}
}
It gives: Error:(1, 0) Plugin with id 'com.android.application' not found.
Screen Shot
Any help will be appreciated ...
This error message means that it can't find the plugin at all. In Gradle, you need to tell it where to go to look for plugins, which is different from telling it where to go to resolve module dependencies. Add this block to the beginning of your build file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
In projects that Android Studio creates, the New Project wizard will put this in the top-level build file in your project, but based on the screenshot it looks like your project only has a single build file, so there's only one place to put it.

Adding dependencies in Gradle

I am trying to move my Android project form IDEA to Android Studio with Gradle.
However, I am having difficulties with the dependencies. I removed my "lib" dir, so the jars would be retrieved from maven. But how do I correctly add them?
E.g. org.apache.commons.lang3
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
dependencies {
compile 'com.google.android.gms:play-services:4.1.+'
compile 'org.apache.commons:commons-lang3:2.6.+'
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
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')
}
}
This results in:
Failed to refresh Gradle project 'idoms-android'
Could not find commons:commons-lang3:3.0.
It seems to be in the Maven Repository though.
You are missing this at the top level (i.e., a peer of android and dependencies):
repositories {
mavenCentral()
}
The buildscript block has repositories and dependencies for the build process. You also need repositories and dependencies at the top level for the dependencies for your project itself.
dependencies {
compile 'org.apache.commons:commons-lang3:3.4'
}
Add above line in your build.gradle file, this is the latest version.
Also you can check it from here:
mvnrepository, Apache Commons Lang ยป 3.4

Could not call incremental task error in Android Studio

So I have bees stuck on this all day on android studio.
I have tried to follow this tutorial to add support for google maps API for my application
https://developers.google.com/maps/documentation/android/start#install_the_android_sdk
but when I try to build the application this error appears
Gradle: Execution failed for task ':dexDebug'.
Could not call IncrementalTask.taskAction() on task ':dexDebug'
here is my build.gradel
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:4.0.30'
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 16
buildToolsVersion "18.1.1"
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')
}
}
When I remove remove this line for testing the said error doesn't appear.
compile 'com.google.android.gms:play-services:4.0.30'
Does anyone know what the error code be?
Do you have the Play Services installed? In Android Studio, go to the SDK Manager. Under Extras, make sure you have the latest revision of Google Play services. After you install, you may have to restart Android Studio.
To double-check that 4.0.30 was downloaded, you can check that the Android Studio's local Maven repository contains the folder. The path is something like:
/Applications/Android Studio.app/sdk/extras/google/m2repository/com/google/android/gms/4.0.30

Gradle not able to find dependencies when use build script named anything other than "build.gradle"

Gradle noobie, a little confused. I'm trying to tell gradle to use a different build script, from the command-line, but whenever I do so, it tells me it can't find my dependencies.
Whenever I call:
gradle -b build.gradle
It works fined.
But when I call:
gradle -b other.gradle
It pukes trying to find my dependencies. e.g.
* What went wrong:
A problem occurred evaluating root project '<main_app>'.
> Project with path ':facebook-android-sdk-3.0.1:facebook' could not be found in root project '<main_app>'.
I'm using the exact same build script in the exact same directory, just named differently. Here it is:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android'
dependencies {
compile project(':facebook-android-sdk-3.0.1:facebook')
}
android {
buildToolsVersion "17.0"
compileSdkVersion 17
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
My settings.gradle file:
include '<app_module>'
include '<:facebook-android-sdk-3.0.1:facebook>'
-b only works for single-project builds. In multi-project builds, settings.gradle determines which build scripts constitute the build, which project they belong to, and where they are located.

Categories

Resources