Android Studio `Plugin with id 'com.android.application' not found` [duplicate] - java

This is my first attempt at Android Studio. I installed 0.8.0 and updated to 0.8.2. As soon as a project is created I get the error message:
Error:(1, 0) Plugin with id 'com.android.application' not found
C:\Users\Bob\AndroidStudioProjects\HelloAgain6\app\build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.bob.helloagain6"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
and C:\Users\Bob\AndroidStudioProjects\HelloAgain6\build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}

Updated Answer (Dec. 2, 2020)
Latest Gradle: 6.5
Version check:
./gradlew -v
How to update:
Set URL: ./gradlew wrapper --gradle-version=6.5 --distribution-type=all
Update: ./gradlew wrapper
Latest Android Gradle Plugin: 4.1.0
If you add the following code snippet to the top of your build.gradle file. Gradle will update the build tools.
buildscript {
repositories {
google() // For Gradle 4.0+
maven { url 'https://maven.google.com' } // For Gradle < 4.0
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
Read more here: https://developer.android.com/studio/build/index.html and about version compatibility here: https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle and https://dl.google.com/dl/android/maven2/index.html.
Original Answer
I had this same error, you need to make sure your Gradle version is compatible with your Android Gradle Plugin.
The latest version of Gradle is 2.0 but you need to use 1.12 in order to use the Android Gradle Plugin.

This can happen if you miss adding the Top-level build file.
Just add build.gradle to top level.
It should look like this
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.xx.y'
}
}
allprojects {
repositories {
mavenCentral()
}
}

In my case, I download the project from GitHub and the Gradle file was missing. So I just create a new project with success build. Then copy-paste the Gradle missing file. And re-build the project is working for me.

Root-gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:x.x.x'
}
}
allprojects {
repositories {
jcenter()
}
}
Gradle-wrapper.properties file:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-x.x-all.zip

In the project level build.gradle file, I have replaced this line
classpath 'com.android.tools.build:gradle:3.6.3'
with this one
classpath 'com.google.gms:google-services:4.3.3'
After adding both of those lines, and syncing, everything became fine.
Hope this will help someone.

I am writing this not as a solution meant for many, but for some people who may commit a simple mistake like specifying the wrong url for importing projects from SVN. It is intended for those guys :)
This happened to me when I imported the project from SVN -> automatic prompt by Studio to open the project -> It asked for Gradle location -> D:\Software\Android\gradle-2.5 -> Then the error.
The same project in a different SVN branch works fine with the Gradle plugin and Gradle which I have configured in Studio. I tried changing Android Gradle plugin and Gradle to get it working on the erring branch without any success.
Finally, I figured out that it was my following mistake:
I tried importing a specific Application alone instead of importing the application along with dependent library projects.
The url which I used for import initially had the Application porject's name at the end. Once I removed it, and specified the parent directory which contained both application project and its dependent project, everything went smooth :)

I found the problem after one hour struggling with this error message:
I accidentally renamed the root build.gradle to filename in builde.gradle, so Android Studio didn't recognize it anymore.
Renaming it to build.gradle resolved the issue!

I still got the error
Could not find com.android.tools.build:gradle:3.0.0.
Problem: jcenter() did not have the required libs
Solution: add google() as repo
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
}
}

I was using IntelliJ IDEA 13.1.5 and faced with the same problem after I changed versions of Picasso and Retrofit in dependencies in build.gradle file. I tried use many solutions, but without result.
Then I cloned my project from remote git (where I pushed it before changing versions of dependencies) and it worked! After that I just closed current project and imported old project from Gradle file to IntelliJ IDEA again and it worked too! So, I think it was strange bug in intersection of IDEA, Gradle and Android plugin. I hope this information can be useful for IDEA-users or anyone else.

Go to your grade file where you can see this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
And change classpath to this:
buildscript {
repositories {
jcenter()
}
dependencies {
// classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle-experimental:0.7.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

The other answers didn't work for me, I guess something wrong happens between ButterKnife and 3.0.0 alpha5.
However, I found that when I annotated any one sentence, either BUtterKnife or 3.0.0 alpha5, it works normally.
So, you should just avoid the duplication or conflict.

For future reference: For me, this issue was solely caused by the fact that I wasn't running Android Studio as administrator. I had the shortcut on Windows configured to always run as administrator, but after reinstalling Android Studio, the shortcut was replaced, and so it ran without administrator rights. This caused a lot of opaque errors, including the one in this question.

This issue happened when I accidently renamed the line
apply plugin: 'com.android.application'
on file app/build.gradle to some other name. So, I fixed it by changing it to what it was.

[FOR FLUTTER] go to your build Gradle then check if you have three paths
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
I somehow removed the android tools classpath and was getting the error.

This just happened to me using Android Studio 1.3.2, however, since I had just created the project, I deleted it and created it again.
It seems that it had not been properly created by Android Studio the first time, not even the project folders where as expected.

If you run a the module task with android plugin 1.2.3 in module directory , the problem appears. Try this:
../gradlew -b ../build.gradle -c ../settings.gradle :module:xxx

Make sure your two build.gradle and settings.gradle files are in the correct directories as stated in https://developer.android.com/studio/build/index.html
Then open "as existing project" in Visual Studio
Gradle is very finicky about this.

I got this error message after making the following change in my top-level build.gradle to update to the latest version of gradle:
//classpath 'com.android.tools.build:gradle:2.3.2' old
classpath 'com.android.tools.build:gradle:2.3.3' //new
I foolishly made the change while I was connected behind a hostile workplace proxy. The proxy caused the .jar files for the new version of gradle to become corrupt. This can be verified by inspecting the jars to see if they are an unusual size or whether they can be unzipped.
In order to fix the mistake, I connected to my network at home (which is not behind a proxy) and did a refresh dependencies from the Terminal:
./gradlew --refresh-dependencies
This caused the newer version of gradle to be re-downloaded and the error no longer occurs.

Check the spelling, mine was 'com.android.aplication'

This may also happen when you have both settings.gradle and settings.gradle.kts files are present in project root directory (possibly with the same module included). You should only have one of these files.

i had similar problem and i did following things to resolve it.
i referred to https://developer.android.com/studio/build
and copy / pasted these following lines before apply plugin lines
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
}
}

module app build.gradle file
apply plugin: 'com.android.application'
model{
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig.with {
applicationId "com.iamsafe"
minSdkVersion 15
targetSdkVersion 23
}
buildTypes {
debug {
minifyEnabled = false
useProguard = true
proguardFiles.add(file('proguard-rules.txt'))
}
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.2'
compile files('libs/asmack-android-8-0.8.10.jar')
compile files('libs/commons-io-2.0.1.jar')
compile files('libs/httpclient-osgi-4.2.1-sources.jar')
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.1.2.jar')
}
project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.10'
}
}
allprojects {
repositories {
jcenter()
}
}

In this case of issues check below code
dependencies {
classpath 'com.android.tools.build:gradle:**1.5.0**'
}
and gradle-wrapper.properties inside your project directory check below disctributionUrl:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip
If these are not compatible with each other then you end up in this issue.
For com.android.tools.build:gradle:1.5. you need a version at least 2.8 but if you switch to a higher version like com.android.tools.build:gradle:2.1.0 then you need to update your gradle to 2.9 and above this can be done by changing distributionUrl in gradle-wrapper.properties to 2.9 or higher as below
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

If you work on Windows , you must start Android Studio name by Administrator.
It solved my problem

Just make sure you put the http and https proxy correctly when you create the app

Related

Configuration with name 'default' not found gradle sync failed [duplicate]

I have an Android Studio app. It has a library dependency (Android-Bootstrap), when I try to sync gradle, it gives me an error:
Configuration with name 'default' not found.
My structure is:
-FTPBackup
-fotobackup
-build.gradle
-Libraries
-Android-Bootstrap
-Settings.gradle
-build.gradle
-Settings.gradle
-Build.gradle
The FTPBackup settings.gradle and build.gradle:
include ':fotobackup'
include ':libraries:Android-Bootstrap',':Android-Bootstrap'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
And the build.gradle inside fotobackup is:
apply plugin: 'android'
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'
}
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:+'
compile project (':libraries:Android-Bootstrap')
}
The library is downloaded from https://github.com/Bearded-Hen/Android-Bootstrap and it has build.gradle, settings etc.
whats wrong?
For one, it doesn't do good to have more than one settings.gradle file -- it only looks at the top-level one.
When you get this "Configuration with name 'default' not found" error, it's really confusing, but what it means is that Gradle is looking for a module (or a build.gradle) file someplace, and it's not finding it. In your case, you have this in your settings.gradle file:
include ':libraries:Android-Bootstrap',':Android-Bootstrap'
which is making Gradle look for a library at FTPBackup/libraries/Android-Bootstrap. If you're on a case-sensitive filesystem (and you haven't mistyped Libraries in your question when you meant libraries), it may not find FTPBackup/Libraries/Android-Bootstrap because of the case difference. It's also looking for another library at FTPBackup/Android-Bootstrap, and it's definitely not going to find one because that directory isn't there.
This should work:
include ':Libraries:Android-Bootstrap'
You need the same case-sensitive spec in your dependencies block:
compile project (':Libraries:Android-Bootstrap')
compile fileTree(dir: 'libraries', include: ['Android-Bootstrap'])
Use above line in your app's gradle file instead of
compile project (':libraries:Android-Bootstrap')
In my setting.gradle, I included a module that does not exist. Once I removed it, it started working. This could be another way to fix this issue
If you're getting this error with react native, it may be due to a link to an NPM package that you removed (as it was in my case). After removing references to it in the settings.gradle and build.gradle files, I cleaned and rebuilt and it's as good as new :)
Just a note on this question:
I had this exact error in my React Native app when trying to build to android. All you should have to do is $ npm i.
Case matters
I manually added a submodule :k3b-geohelper
to the
settings.gradle file
include ':app', ':k3b-geohelper'
and everthing works fine on my mswindows build system
When i pushed the update to github the fdroid build system failed with
Cannot evaluate module k3b-geohelper : Configuration with name 'default' not found
The final solution was that the submodule folder was named k3b-geoHelper not k3b-geohelper.
Under MSWindows case doesn-t matter but on linux system it does
I had this issue with Jenkins. The cause: I had renamed a module module to Module. I found out that git had gotten confused somehow and kept both module and Module directories, with the contents spread between both folders. The build.gradle was kept in module but the module's name was Module so it was unable to find the default configuration.
I fixed it by backing up the contents of Module, manually deleting module folder from the repo and restoring + pushing the lost files.
The message is a known Gradle bug. The reason of your error is that some of your gradle.build files has no apply plugin: 'java' in it. And due to the bug Gradle doesn't say you, where is the problem.
But you can easily overcome it. Simply put apply plugin: 'java' in every your 'gradle.build'
I also faced the same problem and the problem was that the libraries were missing in some of the following files.
settings.gradle, app/build.gradle, package.json, MainApplication.java
Suppose the library is react-native-vector-icons then it should be mentioned in following files;
In app/build.gradle file under dependencies section add:
compile project(':react-native-vector-icons')
In settings.gradle file under android folder, add the following:
include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
In MainApplication.java, add the following:
Import the dependency: import com.oblador.vectoricons.VectorIconsPackage;
and then add: new VectorIconsPackage() in getPackages() method.
I am facing same problem, I was fixed it by generating gradle project and then adding lib project to android studio
First, See build.gradle file is present in project root directory
if not then, Create gradle project,
export your required lib project from eclipse then (File->Export->Android->generate Gradle build file
Click on Next->Next->Select your lib project from project listing->Next->Next->Finish
See build.gradle file present in your project root directory
Move this project to Android Studio
Your module name must be camelCase eg. pdfLib. I had same issue because I my module name was 'PdfLib' and after renaming it to 'pdfLib'. It worked.
The issue was not in my device but in jenkins server. So, check and see if you have such modulenames
Step.1
$ git submodule update
Step.2
To be commented out the dependences of classpass
You are better off running the command in the console to get a better idea on what is wrong with the settings. In my case, when I ran gradlew check it actually tells me which referenced project was missing.
* What went wrong:
Could not determine the dependencies of task ':test'.
Could not resolve all task dependencies for configuration ':testRuntimeClasspath'.
Could not resolve project :lib-blah.
Required by:
project :
> Unable to find a matching configuration of project :lib-blah: None of the consumable configurations have attributes.
The annoying thing was that, it would not show any meaningful error message during the import failure. And if I commented out all the project references, sure it let me import it, but then once I uncomment it out, it would only print that ambiguous message and not tell you what is wrong.

Android Studio 3.0 Canary 2: Failed to apply plugin, when using gradle 3.0.0-alpha2

I just updated to using Android Studio 3.0 Canary 2. Upon opening my project Android Studio suggested I update the gradle version to 3.0.0-alpha2. My goal is to use the "Enable advanced profiling" Run Configuration so I can run a realtime memory-analysis. However the instant my gradle version was updated, my project fails to build. I followed the update instructions here.
The only changes made were to my top-level build.gradle file and the gradle-wrapper.properties file.
My top-level build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
classpath 'com.github.Archinamon:GradleAspectJ-Android:2.3.0'
classpath 'me.tatarka:gradle-retrolambda:3.5.0'
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://repo.adobe.com/nexus/content/repositories/releases/' }
maven { url 'http://maven.localytics.com/public' }
}
}
And I updated the gradle-wrapper.properties distributionURL to:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
The error I get is:
Failed to apply plugin [id'com.archinamon.aspectJ']
And here is the offending part of my app-level build.gradle file:
import java.text.SimpleDateFormat
apply plugin: 'com.android.application'
apply plugin: 'com.archinamon.aspectj'
aspectj {
includeAspectsFromJar 'Android_MTAgent'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
....
}
So the problem seems to be with the aspectJ plugin. If I remove the plugin for aspectJ and the related aspectJ block (both shown above) then it compiles (I get a dimen error then though, but I already saw that mentioned elsewhere, so I guess that can be solved.)
I'd appreciate any pointers/ideas in regard to the above issue.
Change your project build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
}
and update your Archinamon classpath reference in the same build.gradle file to:
classpath 'com.github.Archinamon:GradleAspectJ-Android:3.0.2'

Could not find com.android.tools.build:gradle:2.2.2

A friend of mine copy pasted a libgdx project folder on his pc and sent the project to me(through google drive). We are both using Android Studio. I downloaded and imported the project and it is working properly on the emulator. However it is not working on the desktop. On his pc, it works both in desktop and in the emulator.
When I try to run it in the desktop, Android Studio gives me this error message:
Error:Gradle: A problem occurred configuring root project 'bouncerGDX - Copy'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:2.2.2.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.jar
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.jar
Required by:
:bouncerGDX - Copy:unspecified
How can I fix this? I have no experience with Gradle.
UPD:
It seems can't resolve com.android.tools.build:gradle:2.2.2 dependency for the classpath.
For me, adding the jcenter to build.gradle resolves the issue:
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
or, alternatively, the line in build.gradle
classpath 'com.android.tools.build:gradle:2.2.2'
can be changed to
classpath 'com.android.tools.build:gradle:2.1.3'
^^^ this version exist in repo1.maven.org
WRONG SUGGESTION:
Resolve all dependencies by running gradle task (can be done from Android Studio's terminal):
For Linux:
./gradlew buildDependents
For Windows:
gradlew.bat buildDependents
Also, this commands might also help later
Linux:
./gradlew cleanIdea idea
Windows:
gradlew.bat cleanIdea idea
This is the reference to libgdx How-to-setup-development-env instruction
I was getting the same issue after updating Android Studio 2.2.2 to 2.3.1
Could not find com.android.tools.build:gradle:2.2.2.
Solution:
Open the gradle location and make changes in build.gradle accordingly(module and project both)
I replaced
classpath 'com.android.tools.build:gradle:2.2.2'
with
classpath 'com.android.tools.build:gradle:2.3.1'
And gradle build successfully :-)
gradle location
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
add google() below jcenter(),this works for me
Seems like you hav dependency on the library project bouncerGDX
You can open build.gradle of that project and change gradle version which is available with you. e.g.
classpath 'com.android.tools.build:gradle:2.1.0'
My fix for the same error was to configure Android Studio for the proxy I'm stuck behind.
Android Studio + Gradle did not assume system proxy settings, at least not on my copy of macOS. Set your proxy settings in Preferences > Appearance & Behavior > System Settings > HTTP Proxy, save them and restart Android Studio. It then prompted me to set Gradle's proxy settings to match Android Studio's. Once I did this, no more error.
Adding the maven url solved the issue for me.
buildscript {
repositories {
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
[Solution For Android 2.3.1 built in 2017 April]
In gradle.build(Project)
Add missing repositories
mavenLocal() and jcenter()
To
buildscript { repositories { }}
Notice there are TWO gradle.build files!! Pick the right one.
In my case I was updating Gradle as Android Studio recommended
Solution:
When you import the project make sure not to update Gradle (click "Don't remind me again for this project") and it should work.
Note: Use latest gradle version.

Gradle: how do I include a local jar from a dependent java project in an Android build?

In my Android app, I'm getting a java.lang.NoClassDefFoundError when the code that references code in a dependent .jar is executed. My project includes an Android module as well as a java-only library module, which is where the jar dependency is. I'm using gradle 1.10 to build the project. Here is my project layout:
myProject
- app (Android)
- src
- build.gradle
- lib (java)
- src
- libs
- local-dependency.jar
- build.gradle
- build.gradle
- settings.gradle
The main project build.gradle is blank while the main project settings.gradle looks like:
include ':app', ':lib'
The Android app build.gradle looks like:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "19.0.2"
defaultConfig {
minSdkVersion 18
targetSdkVersion 18
versionCode 1
versionName "1.0"
}
}
dependencies {
compile project(':lib')
}
The library build.gradle is:
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile <some-dependency-in-maven>
compile files('libs/local-dependency.jar')
}
Everything compiles and packages with no errors and I'm not seeing any errors in the IDE (IntelliJ 13). For some reason, my local-dependency.jar is not getting added to the dex-ing process during the Android compile. Any maven dependencies specified in the lib project get added to the Android .apk just fine; it's just my local jar dependency. Is there something I'm missing?
Thanks!
This is not directly possible as local jars are not declared as transitive dependencies in Gradle.
You have two options:
merge the two jars in your java library so that the output contains the local jar.
create a different project with no source, only the jar, and make the project depend on it.
The second option gives you the ability to have more than one project depend directly on the local jar (on top of it becoming a transitive dependency). To do it, create a new gradle project and just put in its build.gradle the following:
configurations.create("default")
artifacts.add("default", file('somelib.jar'))
This simply register your jar as the default artifact published by the project and this will get consumed by the other projects.
In recent (4+, IIRC) versions of gradle, you can achieve this with the following configuration:
compile (project(':ProjectIDependOn')) {
transitive = true
}
Setting transitive to true when depending on another project will expose all of that project's libraries to this project.

How to use code from a project in a maven repository

I am trying to use code from this project: https://github.com/gabrielemariotti/cardslib, and I am trying to do this with intelij. In the instructions provided with the library it simply says to add this to build.gradle file:
dependencies {
compile 'com.github.gabrielemariotti.cards:library:1.3.0'
}
however when I add this and try to use code from the project intelij gives errors such as unable to resolve symbol, etc. So I am wondering what are the other steps needed to use code from this project that must be done using intelij. Any help is appreciated.
My build.gradle file currently looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/GoogleAdMobAds.jar')
compile files('libs/libGoogleAnalyticsV2')
compile files('libs/amazon-ads-5.1.10.jar')
compile project('libraries/cardslib/library')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
dependencies {
// Cards Library
compile 'com.github.gabrielemariotti.cards:library:0.6.0'
compile project(':libraries:cardslib:library')
}
The documents here are also helpful to new Maven users.
Download and Install Maven - Download the latest version of Maven and install it
Quick Start - Get started building the project quickly
Use Maven - Learn how to use Maven on your own project
Refer this the below link to get much more details...
http://maven.apache.org/run-maven/
You need to add the maven central repository to your build file.
The simplest way is to just put this in your build.gradle directly under apply plugin: 'android':
repositories {
mavenCentral()
}
Resync your IDE with the gradle file after doing so.
It should resolve the dependency like any other maven central dependency (e.g. ABS).
If you are using sources (git repo cloned) at rootProject/libraries/cardslib, then add its library in rootProject/settings.gradle:
include ':appModule', ':libraries:cardslib:library'
and then in rootProject/appModule/build.gradle:
dependencies {
compile project(':libraries:cardslib:library')
}
Or, if you use maven, then just do this in rootProject/appModule/build.gradle:
dependencies {
compile 'com.github.gabrielemariotti.cards:library:1.3.0'
}
so the library's jar/aar will be downloaded in ~/.gradle/caches/modules-2/... and be compiled.
Pick one of above, don't do both.

Categories

Resources