This question has been asked many times so far, but none of the provided solutions worked for me.
I'm completely new to Android Studio and trying to open this project in Android Studio: https://github.com/monkeyswarm/MobMuPlat.
There is two build.gradle files. One in the root folder and another in in the 'app' folder. is that correct?
When I try to sync the gradle project it says gradle project sync failed and gives me the error: Configuration with name 'default' not found.
This part in the build.gradle file is highlighted:
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
any idea whats going wrong here?
Your app/build.gradle is containing one line
wearApp project(':mobmuplatandroidwear')
Remove that and try to sync the project.
Hope this helps.
In your MobMuPlat-Android/settings.gradle you are defining:
include ':app', ':mobmuplatandroidwear'
Gradle is searching for a build.gradle in the mobmuplatandroidwear module which is not present.
Related
after I update android studio to 3.0.0 then add api27 I couldnt create new project
because of dependency error I found that I must update my dependency the first dependency appcompat-v7:27.0.0 and I insert https://maven.google.com in build.gradle and compile "com.android.support:appcompat-v7:27.0.0"to download dependency but it cause another error could not find method for argument and ask for updating android support repository but it is also updated
my build.gradle(projre}
I'd like to forward your attention to note
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
You opened wrong build.gradle file by mistake. Open your build.gradle file from Module: app, put your compile "com.android.support:appcompat-v7:27.0.0" inside dependencies block there.
Delete the line from where you have it now.
thanks poss i get that code should be in build.gradle (module:app)
but that didn't work and caused another error unable to resolve dependency
then i saw that it use https for downloading dependencies but i only used proxy for http so i add settings for https and done
I built some android projects with android studio 1.4. Today my computer broke and I reinstalled my operating system . I installed android studio 1.5,but it didn't work with the old projects.I built some new projects and there's no errors.When I open the old projects,there is an error.
Error:Unable to tunnel through proxy. Proxy returns "HTTP/1.1 400 Bad Request"
I can't find any information about this error,how can I deal with the old projects?
enter image description here
Put this code in your main build.gridle file, may be it trying to use latest gradle and you have used older one in your previous projects.
// 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:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
I solved this problem.Just changed the information in gradle->wrapper->gradle-wrapper.properties->distributionUrl=https://services.gradle.org/distributions/gradle-2.4-all.zip
to https://services.gradle.org/distributions/gradle-2.8-all.zip.And it works for me.
I have a network restriction at my production environment that causes this issue.
I solved the same problem by downloading a Gradle version manually and use this local deployment directly:
Downloading a proper Gradle version from Gradle site. In my case https://services.gradle.org/distributions/gradle-6.4.1-all.zip
Placing this zip file in a proper disk folder, say /path/to/gradle-6.4.1-all.zip
Editing projRoot > gradle > wrapper > gradle-wrapper.properties, so that
distributionUrl=file:///path/to/gradle-6.4.1-all.zip
A robust and cross-platform setup would be
distributionUrl=gradle-6.4.1-all.zip
This is a relative path to
project_root/android/gradle/wrapper/
So you must copy the Gradle zip ball there.
The error is:
File google-services.json is missing from module root folder. The
Google Quickstart Plugin cannot function without it.
Above asked question has been solved as according to documentation at developer.google.com https://developers.google.com/cloud-messaging/android/client#get-config
2018 Edit : GCM Deprecated, use FCM
The file google-services.json should be pasted in the app/ directory.
After this is when I sync the project with gradle file the unexpected Top level exception error comes. This is occurring because:
Project-Level Gradle File having
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
}
and App-Level Gradle File having:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services:7.5.0' // commenting this lineworks for me
}
The top line is creating a conflict between this and classpath 'com.google.gms:google-services:1.3.0-beta1' So I make comment it now it works Fine and no error of
File google-services.json is missing from module root folder. The Google Quickstart Plugin cannot function without it.
The document says:
Copy the file into the app/ folder of your Android Studio project, or
into the app/src/{build_type} folder if you are using multiple build
types.
It should be on Project -> app folder
Please find the screenshot from Firebase website
Instead of putting in root folder as given in docs of firebase, just copy the google-json file in the projectname/app 's root folder and it works fine then .
Its just simple !
WINDOWS
Open Terminal window in Android Studio (Alt+F12 or View->Tool Windows->Terminal).
Then type
"move file_path/google-services.json app/"
without double quotes.
eg
move C:\Users\siva\Downloads\google-services.json app/
LINUX
Open Android Studio Terminal and type this
scp file_path/google-services.json app/
eg:
scp '/home/developer/Desktop/google-services.json' 'app/'
Click right above the app i.e android(drop down list) in android studio.Select the Project from drop down and paste the json file by right click over the app package and then sync it....
This error indicates your package_name in your google-services.json might be wrong. I personally had this issue when I used
buildTypes {
...
debug {
applicationIdSuffix '.debug'
}
}
in my build.gradle. So, when I wanted to debug, the name of the application was ("all of a sudden") app.something.debug instead of app.something. I was able to run the debug when I changed the said package_name...
Download the "google-service.json" file from Firebase
Go to this address in windows explorer "C:\Users\Your-Username\AndroidStudioProjects" You will see a list of your Android Studio projects
Open a desired project, navigate to "app" folder and paste the .json file
Go to Android Studio and click on "Sync with file system", located in dropdown menu (File>Sync with file system)
Now sync with Gradle and everything should be fine
google-services.json file work like API keys means it store your project_id and api key with json format for all google services(Which enable by you at google console) so no need manage all at different places.
Important process when uses google-services.json
at application gradle you should add
apply plugin: 'com.google.gms.google-services'.
at top level gradle you should add below dependency
dependencies {
// Add this line
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
I'm missing the "Top-Level" project build.gradle script from my project:
I imported it into Android Studio from a very complex Maven/Eclipse project, and it basically made a module ("android") in the top level of the directory, and added all the submodules ("tappurwear", "shared", etc) into that original module's directory.
I know this is a kind of messed up structure, but there's a lot of other build scripts so I can't really just move all the files into a proper separate module.
So now I'm wondering, how do I add a top-level build.gradle script, for the entire project? The usual Android Studio projects I've seen just have one, but it's treating my top-level build script as the "android" module's build script. Can I create a new build.script to be the top-level project script that shares settings with the other modules? Is there a way I can rename the top-level build script that gets used in all other module scripts, in Android Studio or Gradle?
I had the same issue on my multi-module project, this solution worked for me.
Closed all the open projects.
Removed project from recent projects in "Welcome to Android Studio" window.
Now click "Open existing android studio project" & browse to the project repo & select top level build.gradle.
close your project
rename the project directory (in the workspace)
open the project with the new name
wait for gradle sync, build.gradle (project) should be added to the Gradle scripts
close the project
rename the project directory with the original name
reopen the project with its good name
wait gradle sync, the build.gradle should be here again...
// 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:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
It really doesn't matter from my experience, what you need to do is make a build.gradle file, with your favorite .txt writer (make sure it says .gradle). If your root foldere app name is say "Archiver", then you put the gradle file where you see folders like app, .idea, gradle, e.t.c.
One thing you have to keep in mind is that you may need to add a pointer to this gradle if your project can't find it for some reason.
To make sure your project looks good, go to File >> Project Structure >> Module (and every other menu you feel you implemented). If you don't see any red x's then you may be good to go.
Close project.
Remove ".idea\project_name.iml" (name are usually same as project folder).
Remove reference to this file from ".idea\modules.xml".
Open project.
IDEA will re-create this file in projec's root folder instead of ".idea" and project-level "build.gradle" appears. This makes me think that better solution could be just moving this file outside ".idea" and correct reference in ".idea\modules.xml".
You can just add build.gradle for root folder which contains gradle.properties and settings.gradle file
// 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:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
The following steps resolved the issue for me:
Close project.
Remove ".idea\project_name.iml" (name are usually same as project folder).
Remove reference to this file from ".idea\modules.xml".
Open project in IDE
I have read a lot answers related to this topic, but none of them have worked to solve my problem, so need help with this:
I need to import a .aar file into a project created with Android Studio 1.1.0, I have imported it using the "New Module" option and actually I don't receive any error, I can build the application and run it, but when I try to use a class from this .aar file Android Studio doesn´t find the reference to it, let's say it can´t recognize the package that I want to include in my code.
You are maybe thinking that I must add the dependency, I have already done that, It seems to not work.
So someone could tell me which is the correct way to import and use a .aar file in Android Studio 1.1.0
To import an .aar library:
Go to File>New>New Module
Select "Import .JAR/.AAR Package" and click next.
Enter the path to the .aar file and click finish.
Go to File>Project Structure (Ctrl+Shift+Alt+S).
Under "Modules," in left menu, select "app."
Go to "Dependencies" tab.
Click the green "+" in the upper right corner.
Select "Module Dependency"
Select the new module from the list.
After reading a lot of answers on Stackoverflow, I found the solution for my problem, I want you to know which were the steps I followed in order to reproduce it:
Add a .aar file in my libs folder.
Use "New Module" option under File menu.
Import the .aar file.
Build gradle and compile the project.
When I tried to use the new module in my app, It didn't recognize any class inside the new module.
The problem is related to the version of Gradle, I was using 1.1.0 and there is a bug in this version, so my suggestion is to change the version to 1.0.1, there is an Issue already open in order to fix this problem https://code.google.com/p/android/issues/detail?id=162634
You should change the version in the build.gradle file located in the root of your project.
buildscript {
repositories {
jcenter()
}
dependencies {
//classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
You can find additional information about this problem here https://groups.google.com/forum/#!topic/adt-dev/1Ho_c8dALQQ
I guess in version 1.2.0 this problem will be solved.
I follow steps in both answers but finally I need to add this line to my build.gradle:
allprojects {
repositories {
mavenCentral()
flatDir { dirs 'aars'} // this line
}
}
Use the gradle dependency
compile 'com.facebook.android:facebook-android-sdk:4.8.0'