I'm making an interactive login app with Android Studio and wampserver. After creating the Android Studio project, I changed the build.gradle like this:
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Then the IDE keeps showing the following error:
(((Gradle DSL method not found: 'compile()
Possible causes:The project 'Login_wamp' may be using a version of Gradle that does not contain the method.
The build file may be missing a Gradle plugin.
Apply Gradle plugin )))
When I click on Apply gradle plugin, it shows me a lot of plugins. Should I pick one of these options?
What should I do to fix this error?
UPDATE
I have moved the above lines to the other build.gradle file, but I get 2 other problems now:
the support library should not use the different version(21) than the compileSDK version(23).
These lines are my gradles exact shape. Which "21" should be changed to "23" or which "23" should be changed into "21"?
I have changed the
compile 'com.android.support:appcompat-v7:21.0.3' to
compile 'com.android.support:appcompat-v7:23.0.3' and it says that I should Install Repository and sync project.
Here is my build.gradle:
compileSdkVersion 23
buildToolsVersion "23.0.1"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
}
You are using the top level build.gradle
root
|--app
|----build.gradle
|--build.gradle //top level file
|--settings.gradle
In this file you can't use the compile statement:(it is the reason of your issue)
Just move these lines:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
//REMOVE THESE LINES
//compile 'com.android.support:appcompat-v7:21.0.3'
//compile 'com.android.support:support-v4:21.0.3'
//compile 'com.mcxiaoke.volley:library-aar:1.0.0'
}
}
Then you have to add the dependencies in your module/build.gradle file.
EDIT: After your comment.
In your module/build.gradlefile:
use the same version for all support libraries
use the latest (currenlty 23.1.1)
dont' add the same library twice (appcompat)
the 23.0.3 doesn't exist
Here the changes:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1' //update to 23.1.1
//compile 'com.android.support:appcompat-v7:23.0.3' //REMOVE THIS LINE. It doesn't exist and you adding twice
compile 'com.android.support:support-v4:23.1.1' //USE THE SAME VERSION
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
}
I think you are using the wrong build.grade file.
There are two gradle files in your Project.
One is called build.gradle (Project: YourProjectname)
The other one build.grade (Module: app).
Delete the following lines from build.gradle (Project: YourProjectname):
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
Search the dependencies in your build.gradle (app: Module)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
}
and add the compile lines there:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
}
salam Mehdi. first of all you must open freegate and set proxy settings from android studio settings.(IP=127.0.0.1 and port=8580). after that you must click on apply gradle plugin to update your SDK. after updates done the error must gone. Hope this help you.
Related
I am using android studio, while trying to use HttpPost,HttpClient it says cannot find symbol. i surfed on internet and found that if we are at api level 23 we need to add some dependence so i added.
useLibrary 'org.apache.http.legacy'
and
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
}
in my build.gradle file. but even after adding this the same problem exist.
any other solution.
If you are having problem with dependency then download the jar from the following link and add it to your libs folder. Then right click on that jar then select Add as Library.
https://hc.apache.org/downloads.cgi
execution failed for task:app-merge debug resources. Some file crunching failed.
this is the message shown
these i have used
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
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.0.1'
}
You problem seems to be because of the import of different versions of appcompat-v7 and design.
Update the gradle import of design to version 23.2.1, like:
compile 'com.android.support:design:23.2.1'
I have the next gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.android.support:design:23.2.1'
compile 'com.loopj.android:android-async-http:1.4.4'
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.android.gms:play-services-location:7.3.0'
compile 'com.google.gms:google-services:2.1.0-rc1'
}
I'm getting error in the lines starting with: compile 'com.google.android.gms
The error is:
Error:Execution failed for task ':app:processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is
available at
https://bintray.com/android/android-tools/com.google.gms.google-services/)
or updating the version of com.google.android.gms to 8.3.0.
How I can know what version are available for this specific component?
You should keep the version of com.google.android.gms libraries the same. If you are going to use v. 8.4.0 for the services.base, then you should always keep the others the same. So, you should also set services-location to the same version:
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
See Google Play Services for more version information.
Also, here is a similar question that is helpful for general Gradle setup as well: Version conflict updating to 8.4.0
Gradle build error - more than one library with package name android.support.v7.appcompat. This project has Chrome Cast in it, so is using android-support-v7-appcompat and CastCompanionLibary-android-master. Project structure is the following:
BaseGameUtils
CastCompanionLibrary-android-master
VideoBrowserActivity
android-support-v7-appcompat
android-support-v7-mediarouter
google-play-services_lib
Really tough error because the compiler doesn't give much information other than 'more than one library with package name 'android.support.v7.appcompat'. Understand why you don't want to be using different versions of the same library, but why doesn't the compiler reveal what versions are being used, and where they are being called from?
Trying to add leaderboard similar to type-a-number challenge (github example project)
There are a total of (7) build.gradle files. One for the top level and one for each of the packages listed above. Top level gradle file:
// 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:1.0.0'
}
BaseGameUtils:
dependencies {
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services-games:6.5+'
compile 'com.google.android.gms:play-services-plus:6.5+'
compile 'com.google.android.gms:play-services-appstate:6.5+'
}
CastCompanionLibrary-android-master
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:20.0.+'
compile project(':android-support-v7-mediarouter')
compile 'com.google.android.gms:play-services-cast:6.5+'
compile project(':BaseGameUtils')
}
VideoBrowserActivity
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':CastCompanionLibrary-android-master')
}
android-support-v7-appcompat
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android-support-v7-mediarouter
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':android-support-v7-appcompat')
}
google-play-services_lib
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
Any help is appreciated on this.
Just go through you project's libs folder not from the Android Studio but from you windows explorer/finder (for windows)/(for mac). And search for android.support.v7.appcompat. Any evidence found related to Apcompat (whether it is v4 or v7) is recommended to be deleted.
Hopefully your problem will be solved.
In your libs folder dont miss any sub directory that has libs folder.
Follow the Steps
1) Remove This repository:
implementation 'com.android.support:appcompat-v7:28.0.0'
2) Add This Repository
implementation 'com.android.support:support-v4:21.0.3'
compile group: 'com.android.support', name: 'appcompat-v7', version: '26.0.1'
3) That's It You Are Ready To Go
I just launched a project in Android Studio 0.8.1 for the first time since upgrading from 0.6.2.
The error thrown is "Error:Module version com.android.support:support-v13:19.1.0 depends on libraries but is not a library itself".
Does anyone have an idea why this is? I have installed some of the new API20 stuff to play with Android L, but the buildTools for this project are still set to 19.1.0.
Here's the dependencies section of my build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.1.+'
compile 'com.android.support:support-v13:19.1.+'
compile 'com.jakewharton:butterknife:5.1.0'
compile 'de.greenrobot:eventbus:2.2.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.mcxiaoke.viewpagerindicator:library:2.4.1'
compile 'uk.co.chrisjenx:calligraphy:0.7.+'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.google.android.gms:play-services:4.4.+'
}
SDK/Buildtools settings are as follows:
compileSdkVersion 19
buildToolsVersion "19.1.0"
Can anyone explain this or point me towards a fix? I'm stumped.
It looks like the support-v13:19.1.0 might have incorrect metadata. Try switching to
compile 'com.android.support:support-v13:20.0.0' and see if your problem persists?