Android studio not fetching libs for my android twitter app - twitter

dependencies {
compile('com.twitter.sdk.android:tweet-ui:1.2.0#aar') {
transitive = true;
}
}
As described in
https://dev.twitter.com/twitter-kit/android/twittercore
But It is not Importing library
Android studio error
Error:Failed to resolve: com.twitter.sdk.android:twitter-core:1.3.3

Did you include the Fabric/Twitter Maven repository at the top of your build.gradle?
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}

I found answer as per suggestion by "Adam S" below
Simply install fabric plugin from here
https://get.fabric.io/native-social
and thats it see the magic
Credit goes to https://stackoverflow.com/users/1217087/adam-s

Related

Could not resolve all files for configuration gradle build

I want tagsoup jar as dependency for one of my test case which reads a html.
In my build.gradle I have done these changes
asciidoctorj {
version = '1.5.4'
}
repositories {
maven {
url "http://mvn-nexus.my.company:8081/nexus/content/groups/public/"
}
mavenCentral()
}
compile(
'org.codehaus.groovy:groovy-all:2.4.14',
'org.codehaus.groovy.modules.http-builder:http-builder:0.7',
'org.apache.httpcomponents:httpclient:4.5.2',
'org.apache.httpcomponents:httpmime:4.5.2',
'commons-cli:commons-cli:1.2',
'ant:ant:1.7.0',
'com.cloudbees:groovy-cps:1.19',
'org.codehaus.gpars:gpars:1.2.1'
)
testCompile(
'junit:junit:4.12',
'org.codehaus.groovy:groovy-all:2.4.14',
'org.spockframework:spock-core:1.1-groovy-2.4',
'org.mockito:mockito-core:2.12.0',
'com.athaydes:spock-reports:1.4.0',
'org.slf4j:slf4j-api:1.7.13',
'org.slf4j:slf4j-simple:1.7.13',
'com.lesfurets:jenkins-pipeline-unit:1.0',
'org.ccil.cowan.tagsoup:1.2.1'
)
varsCompile sourceSets.main.output
}
But I get the following error in my jenkins build while building this project
What went wrong:
Could not resolve all files for configuration ':testCompileClasspath'.
Could not find org.ccil.cowan.tagsoup:0.9.7:.
Required by:
project :
What am I missing?
You miss the artefact name. Try :
'org.ccil.cowan.tagsoup:tagsoup:1.2.1'

getting gradle to execute JUnit Test (Android app, Android Studio)

I am currently working on an android app and lately switched from Eclipse to Android Studio (wasn't my idea;)). However I want to configure a jenkins server to run JUnit Tests and other tests on a regularly basis. To achieve this, I try to configure a gradle buidlfile. Here is my setup:
Directory structure:
-app
-src
-main
-test
The build.gradle file: (located in "src/build.gradle)
apply plugin: 'android'
sourceSets {
unitTest {
java.srcDir file('src/test/java/[appName]/app')
}
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
instrumentTest.setRoot('src/test')
}
}
task unitTest(type:Test) {
testClassesDir = sourceSets.unitTest.output.classesDir
classpath = sourceSets.unitTest.runtimeClasspath
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v13:+'
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:+'
unitTest 'junit:junit:4.10'
}
Testclass MainActivityTest.java
package [appName].app;
import android.test.InstrumentationTestCase;
import junit.framework.Assert;
public class MainActivityTest extends InstrumentationTestCase{
public void testMain(){
Assert.assertEquals(1,2);
}
}
and the most important piece, the error message:
Error:(41, 0) Build script error, unsupported Gradle DSL method found: 'unitTest()'!
It is my first time working with gradle and Android Studio and I have really no clue what I am doing wrong. On the internet I only find people with similar problems, but no one with a solution which worked for me. I'd be really glad if you could point me in the right direction!
Regards
The error message tell that there is no such property unitTest. Test dependency are declared with instrumentTest (old) or androidTest (New).
Android sdk comes already with a junit 3 dependency. So just remove that line
Unit testing doesn't appear to work out of the box in Android Studio. I have a working Gradle configuration that runs unit tests using Robolectric after some minor configurations.
See: Gradlectric
Also to specify a different test folder you need to instead use androidTest:
sourceSets {
androidTest {
setRoot('src/test')
}
}

IntelliJ IDEA: Gradle indexing files - infinite loop

I'm developing a web application, using Grails 2.2.3 with Ember.js (rc3). I'm using IntelliJ IDEA 12.1 Utlimate as IDE and also the IntelliJ TeamCity CI Server - everything's on Windows 7 Professional SP1. Now I wanted to use Gradle 1.7 to better organize my build tasks (combining Grails, Grunt, testing and so on...) and I expected paradise but all I got was hell...
As soon as I started to use the gradle.build file and started JetGradle in IntelliJ IDEA it started to scan and index files over and over (actually it is still running now - 14 hours and counting), the IDE is blocked and I can't do anything... it's really frustrating.
If it's of any interest, here's my gradle.build:
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.tasks.Exec
import org.grails.gradle.plugin.GrailsTask
buildscript {
repositories {
maven { url "http://my.company.archiva:8080/repository/internal" }
maven { url "http://repo.grails.org/grails/repo" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT",
"org.grails:grails-bootstrap:2.2.3"
}
}
apply plugin: "grails"
apply plugin: "base"
repositories {
maven { url "http://my.company.archiva:8080/repository/internal" }
maven { url "http://repo.grails.org/grails/repo" }
}
grails {
grailsVersion "2.2.3"
}
configurations {
all {
exclude module: "commons-logging"
exclude module: "xml-apis"
exclude module: "grails-plugin-log4j"
exclude module: "slf4j-log4j12"
}
test {
exclude module: "groovy-all"
}
compile {
exclude module: "hibernate"
}
compileOnly
}
dependencies {
compile("com.my.company:grails-custom-plugin1:0.1.7#zip")
compile("com.my.company:grails-cusotm-plugin:0.2#zip")
compile("com.my.company:backendapi:1.1")
compile("org.mozilla:rhino:1.7R4")
compile("io.netty:netty:3.3.1.Final")
compile("com.google.protobuf:protobuf-java:2.4.1")
compile("org.grails.plugins:cache:1.0.1")
compileOnly "org.grails:grails-plugin-tomcat:$grails.grailsVersion" // No tomcat-*.jar in the war
bootstrap "org.codehaus.groovy:groovy-all:2.0.5"
}
/*
GRADLE Wrapper
*/
task wrapper(type: Wrapper) {
gradleVersion = '1.7'
}
/*
GRUNT Section
*/
task npm(type: Exec) {
group = "Build"
description = "Installs all Node.js dependencies defined in package.json"
workingDir "web-app"
commandLine = ["npm.cmd", "install"]
inputs.file "package.json"
outputs.dir "node_modules"
}
task production(type: GruntTask) {
gruntArgs = "prod"
}
class GruntTask extends Exec {
private String gruntExecutable = Os.isFamily(Os.FAMILY_WINDOWS) ? "grunt.cmd" : "grunt"
private String switches = "--no-color"
private String workDir = "web-app"
String gruntArgs = ""
public GruntTask() {
super()
this.setExecutable(gruntExecutable)
this.workingDir(workDir)
}
public void setGruntArgs(String gruntArgs) {
this.args = "$switches $gruntArgs".trim().split(" ") as List
}
}
/*
WAR creation
*/
task war(type: GrailsTask) {
command "war"
env "prod"
}
Is anybody out there who is able to help me? I searched the internet up and down but it seems that either nobody is using the combination of Grails, Ember.js, Gradle, IntelliJ IDEA or everything is dead simple and I'm just to stupid to use the tools...
I don't recommend to use the Gradle integration in IDEA 12 as it's too limited. (IDEA 13 will be better.) Instead you can use Gradle's "idea" plugin to generate IDEA files. Not sure how well all of this works together with Grails. Grails' own build tool is deeply integrated with the rest of Grails, and from what I've heard, using anything else means to make compromises. (I don't have first-hand experience though.) There have been plans for Grails to switch over its built-in build tool to Gradle one day.
PS: I'd search the IDEA issue tracker and file an issue if there is none.

How to tell Grails to use Gradle for dependencies resolution

I'm trying to setup a grails project with gradle but i came a problem, i can't make grails to use gradle for dependencies resolution. If i config the dependencies in gradle build file and run gradle grails-run-app, it always report can't find classes in dependencies jars.
When i cut and paste the dependencies into grails BuildConfig.groovy and everything is ok.
How to tell Grails to use Gradle for dependencies resolution?
I paste my build.gradle file here, Any suggestion?
apply plugin: 'grails'
apply plugin: 'java'
apply plugin: 'jetty'
version "1.0-SNAPSHOT"
buildscript {
repositories {
mavenCentral()
mavenRepo urls: 'http://repository.jboss.org/nexus/content/groups/public/'
}
dependencies {
classpath 'com.connorgarvey.gradle:gradle-grails-wrapper:1.0'
}
}
grails {
version '2.2.3'
}
repositories {
mavenLocal()
mavenCentral()
mavenRepo urls: 'http://repository.jboss.org/nexus/content/groups/public/'
}
dependencies {
compile 'org.modeshape.bom:modeshape-bom-embedded:3.3.0.Final'
compile 'postgresql:postgresql:9.1-901.jdbc4'
compile 'javax.jcr:jcr:2.0'
compile 'org.modeshape:modeshape-jcr:3.3.0.Final'
}
I would recommend using the grails-gradle-plugin instead.
UPDATED ANSWER, cleanup and usage of bootstrap scope to exclude Tomcat jars from war.
General info
I followed a presentation from Luke Daley (aka alkemist) on Youtube at gr8conf 2013. I was able to create a small POC and Gradle seems to work fine with Grails 2.2.3.
Gradle build file
buildscript {
repositories {
mavenCentral()
maven { url 'http://repository.jboss.org/maven2/' }
maven { url 'http://repo.grails.org/grails/repo' }
maven { url 'http://repo.grails.org/grails/plugins' }
maven { url 'http://repository.springsource.com/maven/bundles/release' }
maven { url 'http://repository.springsource.com/maven/bundles/external' }
maven { url 'http://repository.springsource.com/maven/libraries/release' }
maven { url 'http://repository.springsource.com/maven/libraries/external' }
}
dependencies {
classpath 'org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT',
'org.grails:grails-bootstrap:2.2.3'
}
}
version='0.0.1'
apply plugin: 'grails'
repositories {
mavenCentral()
maven { url 'http://repository.jboss.org/maven2/' }
maven { url 'http://repo.grails.org/grails/repo' }
maven { url 'http://repo.grails.org/grails/plugins' }
maven { url 'http://repository.springsource.com/maven/bundles/release' }
maven { url 'http://repository.springsource.com/maven/bundles/external' }
maven { url 'http://repository.springsource.com/maven/libraries/release' }
maven { url 'http://repository.springsource.com/maven/libraries/external' }
}
grails {
grailsVersion '2.2.3'
version '2.2.3'
}
configurations {
all {
exclude module: 'commons-logging'
exclude module: 'xml-apis'
}
test {
exclude module: 'groovy-all'
}
compile {
exclude module: 'hibernate'
}
}
dependencies {
compile( "org.grails:grails-crud:$grails.grailsVersion",
'org.grails:grails-gorm:1.3.7')
bootstrap "org.grails:grails-plugin-tomcat:$grails.grailsVersion"
}
Send a text.... ;) Kidding.
You must include a version of the 'grails-bootstrap' artifact in the
'classpath' configuration. You should also add whichever Grails
artifacts you need. 'grails-crud' and 'grails-gorm' will give you
everything you need for a standard Grails web application.
Have a look at the plugin docs.

Jenkins build for project with provided dependencies

While I am building Gradle based project via Jenkins I'm getting compilation errors. It occurs because a have several jars in build.gradle file with scope 'provided'. I need this to do not include them into generated jar-file. How can I specify path or smth else to let project build on integration server?
Thanx in advance.
Listing of build file provided
configurations {
provided
}
sourceSets {
main {
java { srcDir 'src/main/java' }
resources { srcDir 'src/main/resources' }
compileClasspath += configurations.provided
}
}
dependencies {
provided 'somelib1'
provided 'somelib2'
provided 'somelib3'
}

Resources