dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
i'm trying to add compile method to build.gradle but i get this problem
i have android studio 3.5.2
and 5.4.1 gradle
You can replace compile with implementation:
implementation 'com.android.support:appcompat-v7:24.1.1'
implementation 'com.android.support:design:24.1.1'
But you are putting your dependencies in your build.gradle module Project. Place them in build.gradle module app.
Related
I'm using Gradle and I wonder how I can implement a run task so I can run the program from the command "./gradlew run". I have a project named "demo" and it have the task "application run". Then I created the project "HouseObserver" and it have not the task "application run".
My build.gradle file looks like this.
plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
}
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
apply plugin: 'java'
task runApp(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'HouseObserver.Main'
}
// Using and creating an Executable Jar
jar {
manifest {
attributes('Main-Class': 'HouseObserver.Main')
}
}
task runExecutableJar(type: JavaExec) {
// Executable jars can have only _one_ jar on the classpath.
classpath = files(tasks.jar)
// 'main' does not need to be specified
}
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:28.0-jre'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
// Need at least basic JME
compile "org.jmonkeyengine:jme3-core:3.3.0-beta1"
compile "org.jmonkeyengine:jme3-desktop:3.3.0-beta1"
compile "org.jmonkeyengine:jme3-lwjgl3:3.3.0-beta1"
compile group: 'com.simsilica', name: 'lemur', version: '1.13.0'
compile group: 'com.simsilica', name: 'lemur-proto', version: '1.11.0'
// needed for the style language
runtime "org.codehaus.groovy:groovy-all:2.4.5"
// Standard utility stuff
compile 'com.google.guava:guava:19.0'
compile 'org.slf4j:slf4j-api:1.7.13'
runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
runtime 'org.apache.logging.log4j:log4j-core:2.5'
}
I'm also trying the way to implement a task from a plugin.
plugins {
id 'application'
}
application {
mainClassName = 'my.packages.to.the.Main'
}
But nothing happens. Why?
EDIT:
Here is my latest gradle file.
plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
id 'application'
}
application {
mainClassName = 'HouseObserver.Main'
}
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:28.0-jre'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
// Need at least basic JME
compile "org.jmonkeyengine:jme3-core:3.3.0-beta1"
compile "org.jmonkeyengine:jme3-desktop:3.3.0-beta1"
compile "org.jmonkeyengine:jme3-lwjgl3:3.3.0-beta1"
compile group: 'com.simsilica', name: 'lemur', version: '1.13.0'
compile group: 'com.simsilica', name: 'lemur-proto', version: '1.11.0'
// needed for the style language
runtime "org.codehaus.groovy:groovy-all:2.4.5"
// Standard utility stuff
compile 'com.google.guava:guava:19.0'
compile 'org.slf4j:slf4j-api:1.7.13'
runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
runtime 'org.apache.logging.log4j:log4j-core:2.5'
}
I am trying to add a subproject to my main one in Android Studio. I have it compiling in the build gradle of the whole project. When ever I try to build the project or compile it it gives me out this error.
Error:(9, 0) Could not find method compile() for arguments [project ':subProject.exude'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open File
Here is the code for the build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
compile project('subProject.exude')
I think this can be a solution to your problem. Let's say there are two modules in your project, typically named as app and lib. Now you want to use lib module in your app module. So, you need to add it to your build.gradle(app module).
compile project(':lib')
I have it compiling in the build gradle of the whole project.
It may imply two cases:
You're adding compile project('subProject.exude') to your root/project build.gradle
You're adding compile project('subProject.exude') to all of your module build.gradle
In first case, you must not add the compile project to your root build.gradle. Because it not belong there.
In second case, you're incorrectly adding the classpath to your dependencies block in your module build.gradle. This is incorrect, because you're adding classpath for dependencies:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
compile project('subProject.exude')
...
}
This is corrrect:
dependencies {
compile project('subProject.exude')
...
}
Module dependencies should not exist in root/project build.gradle.
I am trying to use Dagger 2 for dependency injection. Currently I am adding the depenecies like this.
In build.gradle
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
In app/build.gradle
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
testCompile 'junit:junit:
compile 'com.android.support:appcompat-v7:23.2.0'
apt 'com.google.dagger:dagger-compiler:2.2'
compile 'com.google.dagger:dagger:2.2'
provided 'javax.annotation:jsr250-api:1.0'
}
The problem is, We are creating a SDK (module), which will be included by other apps so I don't want to include the dependency in build.gradle. Because of this, I will have to tell the other apps to include Dagger2 dependency in their main build.gradle file.
Also, let me know if there is any way to include dagger library using jar.
Thanks in advance :)
Try this
add this to your build.gradle
dependencies {
// other classpath definitions here
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
Then in your app/build.gradle:
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
// apt command comes from the android-apt plugin
apt 'com.google.dagger:dagger-compiler:2.2'
compile 'com.google.dagger:dagger:2.2'
provided 'javax.annotation:jsr250-api:1.0'
}
Note that the provided keyword refers to dependencies that are only needed at compilation.
Hope this helps
Normally in android I can just edit the build.gradle file and place my compile dependencies like this:
dependencies {
compile 'com.android.support:support-v4:23.+'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services-base:8.3.0'
}
How can I add a compile dependency in a codenameone project?
The generated project utilizes the jcenter() repository.
In order to add a compile dependency you will need to use the 'gradleDependencies' build hint, for example:
gradleDependencies=" compile 'com.facebook.android:facebook-android-sdk:4.7.0'\n"
I have a java EE project. I am using gradle as a build tool. My build.gradle file looks as follows:
apply plugin:'war'
apply plugin:'eclipse'
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "com.eriwen:gradle-js-plugin:1.12.1"
}
}
apply plugin: "com.eriwen.gradle.js"
minifyJs {
source = file("src/main/webapp/js/App.js")
dest = file("build/all-min.js")
closure {
warningLevel = 'QUIET'
}
}
war.doFirst {
tasks.minifyJs.execute()
}
war.webInf {
from "build/all-min.js"
into "/js/"
}
dependencies{
compile 'org.springframework:spring-context:4.1.4.RELEASE'
compile 'org.springframework:spring-core:4.1.4.RELEASE'
compile 'org.springframework:spring-web:4.1.4.RELEASE'
compile 'org.springframework:spring-webmvc:4.1.4.RELEASE'
compile 'org.springframework:spring-jdbc:4.1.4.RELEASE'
compile 'org.springframework:spring-tx:4.1.4.RELEASE'
compile 'org.google.code.gson:gson:2.3.1+'
compile 'log4j:log4j:1.2.17+'
compile 'org.slf4j:jcl-over-slf4j:1.5.8+'
compile 'org.slf4j:slf4j-api:1.5.8+'
compile 'org.slf4j:slf4j-log4j12:1.5.8+'
compile 'org.apache.commons:commons-dbcp2:2.0.1+'
compile 'org.mybatis:mybatis-spring:1.2.2+'
compile 'org.mybatis:mybatis:3.2.8+'
compile 'com.oracle:ojdbc14:10.2.0.4.0+'
compile 'commons-fileupload:commons-fileupload:1.2.1+'
compile 'commons-io:commons-io:2.4+'
compile 'junit:junit:4.11'
compile 'javax.servlet:servlet-api:2.5'
}
However when I try to execute gradle build I get the following error
couldnot resolve all dependencies required for configuration for all the dependencies that I have mentioned in my build.gradle file. I think I have correctly mentioned the repositories . I cant figure out why my build is failing. Any suggestion would be appreciated.
You need to add a repositories {...} configuration block to your build script. The one declared inside the buildscript {...} block is only used for resolving dependencies of the build script itself (in this case, the javascript plugin), but it is not used for resolving project dependencies.