I am trying to add AdMob sdk to my android project using Android SDK.
Here is what is did.
i added admob jar file to the lib folder.
added as module
then added dependencies to my build.gradle.
Below is the build.gradle file looks as
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
}
dependencies{
compile files('libs/android-support-v4.jar','libs/GoogleAdMobAdsSdk-6.4.1')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Below is the error.
Gradle 'StoriesIndian' project refresh failed:
Could not fetch model of type 'IdeaProject' using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Build file 'C:\Users\lokesh\Desktop\MyStoryProject\StoriesIndianProject\StoriesIndian\build.gradle' line: 11
A problem occurred evaluating project ':StoriesIndian'.
A problem occurred evaluating project ':StoriesIndian'.
No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection) values: [file collection]
Possible solutions: module(java.lang.Object
)
Please help, what do to make it work and where to include module java.lang.object.
thanks
Related
I am trying to import an external library into my application, the library is FFmpeg. Here is a link to the module.
I add the library to my libs folder (after downloading it), then from File > New > Import module > select FFmpeg. Now within my apps build gradle I add the line
compile project(':FFmpeg')
Now when I try and sync the project I get this error:
Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found.
When I open the file, this is the affected line
apply plugin: 'com.github.dcendents.android-maven'
Basically my end goal is to get the above lib into my project as an external library so I can modify the source code to fix some bugs within the library.
Any help is much appreciated, I have been trying to fix this problem for a really long time but I am not too good with Gradle besides just using dependencies.
Update 1
Apply problems are now fixed however it cant find variables like version name and rootProject.ext.compileSdkVersion as Integer
Error:(6, 0) Could not get unknown property 'VERSION_NAME' for project ':FFmpegAndroid' of type org.gradle.api.Project.
You need to add the plugin to your classpath root build.gradle. You can found it in the Gradle Android Maven plugin. Something like this:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// This is the classpath for the plugin
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
allprojects {
repositories {
jcenter()
}
}
UPDATED:
You should look at the ffmpeg android gradle.properties and add it to your root project, here it is:
VERSION_NAME=0.3.2
VERSION_CODE=28
GROUP=com.writingminds
POM_DESCRIPTION=Java implementation of ffmpeg for Android
POM_URL=https://github.com/writingminds/ffmpeg-android-java
POM_SCM_URL=https://github.com/writingminds/ffmpeg-android-java.git
POM_SCM_CONNECTION=scm:https://github.com/writingminds/ffmpeg-android-java.git
POM_SCM_DEV_CONNECTION=scm:https://github.com/writingminds/ffmpeg-android-java.git
POM_LICENCE_NAME=GNU GPLv3
POM_LICENCE_URL=https://github.com/writingminds/ffmpeg-android-java/blob/master/LICENSE.GPLv3
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=hiteshsondhi88
POM_DEVELOPER_NAME=Hitesh Sondhi
The VERSION_NAME is needed in the Ffmpeg Android build.gradle:
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"
// This is the library version used when deploying the artifact
version = VERSION_NAME
...
ADVICE:
It's better if you run the ffmpeg-android-java as independent project and then configure it so it can be installed to local maven. Read the details at my answer https://stackoverflow.com/a/46330142/4758255
You have to add the plugin in your buildscript block. You can add in the top-level build.gradle file or in your module/build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
//..current plugins
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
About the variables not found you have to check the build.gradle in the library on github
You have to define in your project these variables. Of course use your values.
ext {
compileSdkVersion = 22
buildToolsVersion = '22.0.1'
targetSdkVersion = 22
minSdkVersion = 16
versionCode = 28
versionName = "0.3.2"
}
I git clone a complete gradle project "CompleteGradleProjA" from github and include it into my local project as a submodule. By "complete gradle project" I mean that I can go into directory "CompleteGradleProjA" and issue command
cd CompleteGradleProjA && gradle build
to build it.
My directory structure looks like this,
MyProj
|---CompleteGradleProjA
| |---build.gradle
|
|---build.gradle
My question is: How can I call "CompleteGradleProjA/build.gradle" without changing anything of it from my root "build.gradle"?
The following root "build.gradle" config does not help.
apply plugin: 'java'
dependencies {
compile project(':CompleteGradleProjA')
}
I got error message
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':compileJava'.
> Could not determine the dependencies of task ':compileJava'.
"CompleteGradleProjA" is an android porject and "CompleteGradleProjA/build.gradle" looks like this
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
CompleteGradleProjA/build.gradle
apply plugin: 'com.android.library'
// if your project isn't library then use this:
// apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '21.1.2'
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.0' // if needed
}
settings.gradle
include ':CompleteGradleProjA'
Use apply plugin: 'com.android.library' or apply plugin: 'com.android.application' instead of apply plugin: 'java'
To include a custom project as part of your gradle build, first ensure the submodule is already included within the project folder and accessible via your settings.gradle. i.e.
include ':app', ':your_project_name'
You then register the project as a dependency of another by using in your project's build.gradle:
dependencies {
compile project(path: ':your_project_name')
}
In newer versions compile has been deprecated. See here on what to use.
In Android Studio I'm trying to compile an Android application module which uses an Android library.
The library includes a jar file for Bugsense (included automatically by gradle).
Although the library module compiles correctly, the application module fails because it is looking for the Bugsense jar file that is used within the library module.
I do have a workaround which allows the project to compile. By also including the Bugsense dependency in the project everything works.
My question is: How do I make the project compile without duplicating the Bugsense dependency?
Here is my build.gradle file for the library project.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
maven { url 'http://www.bugsense.com/gradle/' }
}
android {
compileSdkVersion 15
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
}
}
dependencies {
compile 'com.bugsense.trace:bugsense:3.6'
}
The library project is called "util"
Following is the android section of the build.gradle for the application
android {
compileSdkVersion 15
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
}
dependencies {
compile project(':util')
}
}
When I compile this I get the following error:
* What went wrong:
A problem occurred configuring project ':br'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':br:_DebugCompile'.
> Could not find com.bugsense.trace:bugsense:3.6.
Required by:
dss:br:unspecified > dss:util:unspecified
I can make the compile work by adding Bugsense to the repositories section of the build.gradle file for the application. Following is the code I added to the build.gradle file for the application project.
repositories {
mavenCentral()
maven { url 'http://www.bugsense.com/gradle/' }
}
Remember, the above code is in the build.gradle for the application project AND the library.
How do I avoid adding the Bugsense dependency to both the application and library projects?
UPDATES:
I'm using Gradle 1.8
I'm compiling from the command line with "gradle clean assembleDebug"
The following is the complete build.gradle file for the application project:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
//maven { url 'http://www.bugsense.com/gradle/' }
}
android {
compileSdkVersion 15
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
testPackageName "com.myapp.test"
}
dependencies {
compile project(':common')
compile project(':util')
}
}
dependencies {
instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:4.3'
instrumentTestCompile 'com.squareup:fest-android:1.0.+'
instrumentTestCompile 'com.squareup.spoon:spoon-client:1.0.+'
instrumentTestCompile 'com.google.guava:guava:15.0'
}
configurations { spoon }
dependencies { spoon 'com.squareup.spoon:spoon-runner:1.0.5' }
It's the expected behavior. Only the repository declarations for the project whose configuration is currently resolved are taken into account, even when transitive dependencies are involved. Typically, repositories are declared inside the root project's allprojects { .. } or subprojects { ... } block, in which case this problem can never occur.
PS: dependencies { .. } needs to go outside the android { ... } block.
I have been following this tutorial for integrating ActionBarSherlock in the Android Studio IDE.
After following all the steps I get the following error:
Gradle: A problem occurred evaluating project ':MyApp'.
> Could not find property ':actionbarsherlock' on DefaultProjectDependency{dependencyProject='project ':MyApp'', configuration='default'}.
The source of the error is my AndroidStudioProjects\MyApp\myapp\build.gradle file with the contents as follows:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'com.google.code.gson:gson:2.2.+'
compile project ':actionbarsherlock'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Maybe a late answer, but try like that :
compile project(':actionbarsherlock')
I am trying to make use of some maven dependencies in a new Android project, but I am new to using Android-Studio and Gradle. I looked at a few other solutions such as this:
How to import Maven dependency in Android Studio/IntelliJ?
and thought it looked simple enough. So I modified the build.gradle file to this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.android:android:4.1.1.4'
compile 'com.factual:factual-java-driver:1.7.7-android'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
but when I compiled the project I got the error:
Gradle: A problem occurred configuring root project 'LookAroundYouProject'.
> Failed to notify project evaluation listener.
> Main Manifest missing from /home/tstewart/AndroidStudioProjects/LookAroundYouProject/src/main/AndroidManifest.xml
I am not really sure what this is telling me. Currently it is just a simple hello world example and it worked before modifying the gradle file.
EDIT:
I moved the compile statements from the Top-level build file to the one within the application itself and for some reason this seemed to work and I no longer appear to be getting errors. Sadly I have no idea why this is the case.