i am getting diff gradle configuration when i migrate eclipse project has without library and with library. i am getting error when importing project with libary.does any know the exact build.graddle, settings.gradle?
1)without library project build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 18
buildToolsVersion "18.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')
}
2)with library build.gradle
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':sdk:extras:google:google_play_services:libproject:google- play-services_lib')
}
android {
compileSdkVersion 18
buildToolsVersion "18.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')
}
}
}
Related
I am new to gradle and was wondering if I am doing something wrong or not when i try to load dependencies from the main Maven repo
this is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.github.clans:fab:1.6.2'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
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')
}
}
and the error i get is
Error:(15, 17) Failed to resolve: com.facebook.android:facebook-android-sdk:4.7.0
Error:(14, 17) Failed to resolve: com.github.clans:fab:1.6.2
What is going on? Why am i seeing those errors? This text here is only so that stackoverflow stop complaining.
UPDATE:
This is gradle-wrapper.settings:
#Tue Nov 17 20:36:30 GMT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
Those are my dependencies in Android Studio. It even found it through the search ....
It seems, that you've forget to add the repository to your project. According to your build.script, you've added repo just in your buildscript. Just add repositories into the build.script root, before declaring dependencies, as:
repositories {
mavenCentral()
}
dependencies {...
Try with this:
apply plugin: 'com.android.application'
allprojects {
repositories {
jcenter()
mavenCentral()
}
dependencies { classpath 'com.android.tools.build:gradle:1.5.0' }
}
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
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')
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.github.clans:fab:1.6.2'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}
Or try:
Gradle settings -> Then uncheck Offline work
For some unknown reason Gradle is refusing to download every dependancy that I put in my gradle.build file. I'm trying to get the 'me.dm7.barcodescanner:zbar:1.7' dependancy but every time I try to sync my gradle it just gives me the following error:
Error:(6, 13) Failed to resolve: me.dm7.barcodescanner:zbar:1.7
It's not just the zbar library either, it's every library this isn't a com.android library. I'm not in offline mode so that can't be it either. Is there something wrong in my .build file?
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':MetaioSDK')
compile 'com.android.support:support-v4:22.0.0'
compile 'me.dm7.barcodescanner:zbar:1.7'
}
android {
compileSdkVersion 19
buildToolsVersion "21.1.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['../../templatesContent_crossplatform']
}
// 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')
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
Alright, managed to fix it. Added this inside the dependencies block:
repositories {
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'me.dm7.barcodescanner:zbar:1.7'
}
android {
compileSdkVersion 22
buildToolsVersion "22.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']
}
instrumentTest.setRoot('tests')
}
}
Put repository block independently from from other blocks
I did everything as it is explained on all forums but i still get the same error.I did everything as described here http://tools.android.com/tech-docs/new-build-system/migrating-from-eclipse-projects
Here is my code in build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
'com.android.tools.build:gradle:1.0.0-rc4'
}
}
apply plugin: 'android'
android {
compileSdkVersion 18
buildToolsVersion "21.1.1"
buildTypes { release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.txt' } }
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')
}
}
What am i doing wrong?
Try change 'com.android.tools.build:gradle:1.0.0-rc4' to 'com.android.tools.build:gradle:1.0.0' at dependencies.
change your current dependencies like
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
i have previous code in eclipse-NDK and it is in running successfully in eclipse i need to import this project into android studio and run ,but it is now showing a run-time error (unfortunately force close) error why is it happened if it is clean code need a help urgently.my build file is :buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
ndk{
moduleName "filters"
abiFilter "armeabi-v7a"
stl "gnustl_static"
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
// 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 using Robotium for my test case. When i am using eclipse for run a test case it is working and showing 2 fail result but when i am using gradle for test case it is showing BUILD SUCCESSFUL.But in my code 2 fail results.
I am using this command - gradle clean connectedCheck build
My build.gradle file--
buildscript { repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.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']
}
instrumentTest.setRoot('MyTestCase')
instrumentTest {
java.srcDirs = ['MyTestCase/src']
manifest.srcFile file('MyTestCase/AndroidManifest.xml')
resources.srcDirs = ['MyTestCase/src']
res.srcDirs = ['MyTestCase/res']
assets.srcDirs = ['MyTestCase/assets']
}
}
dependencies {
compile files('libs/android-support-v4.jar')
}
lintOptions {
abortOnError false
}
}