Install repository and sync project - android

I am trying to make a new project for android wear but this error keeps showing up, I thought it was because I wasn't making new projects in the location I was making before but changing back the location didn't work.
but I when I am making a regular project for android phones there is no problem like this

Try doing the recommended steps that was provided in the SO Post.
in Android Studio, open Tools -> Android -> SDK Manager
under tab "SDK Tools" un-check the libraries causing problems
click "apply" to uninstall them
re-check the same libraries click "apply" to reinstall them
close SDK Manager and run Gradle sync / build
Need to take note the update last July 2017 as well.
Important: The support libraries are now available through Google's
Maven repository. You do not need to download the support repository
from the SDK Manager. For more information, see Support Library Setup.
Here are some important points that you needed for google maven taken from SO post:
In your root build.gradle, you have to add the google maven just like this:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}

Somehow the 26.0.0 Versions didn't worked for me as well.
Try to use the version 25.3.1.

first of all disable your Anti-Virus if have any.
secondly follow the steps
In Android Studio, open Tool > Android > SDK Manager
under tab "SDK Tools" un-check the libraries that are previously checked
click "apply" to uninstall them
re-check the same libraries click "apply" to reinstall them
close SDK Manager and run Gradle sync / build
if this doesn't work then one who has a working A.S take his SDK files from App data

Related

Cannot run my app, asking to select Android SDK

Today I've installed Android Studio Canary 1
Now I cannot run my app. This following dialog appears.
I've already set the right SDK location through File-> Project Structure-> Android SDK location.
Expecting your help to solve this problem.
Warning Dialog image:
Go to project structure settings and set Source Compatibility and Target Compatibility to your current java development kit version:
Just you need to sync your project file with your gradle file.
File -> Sync Project with Gradle Files
I tried every answer in this post but my problem only got resolved when I made these steps:
File -> Close project -> Remove project -> Open existing project (same
project)
Maybe this will save a morning to another person with the same bug.
EDIT
This happened to me a lot on a MacBook. After I posted this answer it just kept happening so what I did was:
uninstall the Android Studio version I had from the App Store;
download the desktop stable version from Android Studio website;
start using the desktop version of Android Studio.
Never happened again.
Sometimes the SDK path will be incorrectly configured. You would need to fix it.
To Settings/Preferences( command + , on mac).
Search for SDK
Under Android SDK, click on edit and point it the root of sdk directory on your file system. (If ther is no SDk installed then install in from the below list).
i suggest you go to build.gradle and sync again.
Or Tools -> Android -> Sync Project with Gradle Files (Android 3+)
You need to insall SDK api 19 check this out.
https://developer.android.com/studio/releases/platforms
Go to sdk manager and install sdk according to your device and check your device api. Example if your device is jellybean then install api 19 sdk.
Go to Tools> Android > SDK Manager and make sure you have selected default Setting under System Setting. In this image I have selected Android 7.1.1 as default SDK
Just click on the button ..."Sync Project with gradle file"
Error will be remove
I had the same problem and what it worked for me was just sync with gradle.
I just did what I've found in this similar question:
How do I "select Android SDK" in Android Studio?
The original answer:
go to build.gradle and click sync now. Then it worked.
Update :
File -> Sync Project with Gradle Files (Android Studio 3.1.1)
Tools -> Android -> Sync Project with Gradle Files (Android Studio
3.0.1) Or You can click on the icon from the toolbar.
Sync Project Icon
This answer may not help works for later version as Android studio Team work on making the tool more better, the way to sync may be
different in the next version of Android Studio.
COMMON WAY that may helps is try to sync project and then Invalidate
Caches and Restart Android Studio.
Solution for Android Studio 3.1.2
Before that, by the way, I had invalidated cache and restarted too, but it didn't work.
Please, try and let us know.
P.S.
I had this problem after I imported a project from Git, just in case someone would like to replicate.

How do I "select Android SDK" in Android Studio?

After a successful import of an Eclipse-Android-Project into "Android Studio 1.4", I get the error
"Please select Android SDK"
when I click on the button to run the application in the simulator, I can't find any way of doing that.
This dialog opens when I click on "run":
This is the "project structure" dialog:
What should I do now?
I go to build.gradle and click sync now. Then it worked.
Update :
File -> Sync Project with Gradle Files (Android Studio 3.1.1)
Tools -> Android -> Sync Project with Gradle Files (Android Studio 3.0.1)
Or You can click on the icon from the toolbar.
This answer may not help works for later version as Android studio Team work on making the tool more better, the way to sync may be different in the next version of Android Studio.
COMMON WAY that may helps is try to sync project and then Invalidate Caches and Restart Android Studio.
Solution for Android Studio 3.1.2 [See below answer]
See Latest Android Studio version
FIX FOR 3.1.2 OR NEWER VERSIONS
Some of my colleagues and I have faced the same issue on AS 3.1.2, but a simple Sync didn't help us. For us, the solution was a bit different:
File -> Invalidate Caches -> Invalidate
File -> Close Project.
Remove the project from the AS project selector window.
Quit from Android Studio
Start AS and open project again
EXTRA ADVICE IF YOU ARE FACING THIS ISSUE CONSTANTLY
Some of you are constantly facing this issue, and this "solution" fixes it only temporarily. At the time we started getting this error, we used gradle wrapper 4.6 and Android gradle plugin 3.1.0, but since then we went back to gradle 4.4 and we use it with the latest Android gradle plugin, and we haven't seen this issue since then.
In Android Studio 3 and above, for Windows, Mac and Linux:
File -> Sync Project with Gradle Files
Solved!
Or you can do this by shortcut key:
Press ⌘ + Shift + A (Mac) or Ctrl + Shift + A (Windows, Linux). Then pop-up a Edit-Text and write "Sync Project with Gradle Files". Then press double click on the option.
Your problem is solved! It'll sync your gradle file with your project file.
Screenshot:
Click this icon to sync gradle
or edit any of your module gradle and then sync
Press "Ctrl+shift+A" and in the pop-up EditText, write "Sync Project with Gradle Files". After that double click on the appeared option. It will then sync your Gradle file SDK with the project file.
Just go to the (app level) build.gradle file, give an empty space somewhere and click on sync, once gradle shows sync complete then the Error will be gone
This is the easiest way to fix this issue:
Add a comment line to the gradle file
It will then ask you to Sync.
Click 'Sync Now'
Viola! You're done.
Now on Android Studio 3 and above, you can try to sync project with gradle like:
File -> Sync Project with Gradle Files
The menu structure and options have changed slightly as of Android 3.2.0. I fixed this error by changing the Module SDK in the following menu:
File > Project Structure > Modules > App File > Dependencies Tab > Module SDK
Make sure to hit Apply to save your changes.
The comment from #Nisarg helped: "set latest version in Compile Sdk Version"
I changed from API 8 to API 23 and the error message disappeared.
Press the first refresh button on the gradle vertical tab in Android Studio on the right
Press " ⌘ + Shift + A" on Mac (or "Ctrl+Shift+A" on Windows) and in the pop-up EditText, write "Sync Project with Gradle Files". After that double click on the appeared option. It will then sync your Gradle file SDK with the project file.
Follow these steps:
Goto Android Studio Settings
Search for "Android SDK" using search bar
Ensure the path to your android sdk folder is correct.
After that also ensure the path is automatically updated after a prompt in your project (local.properties) file. If not, do it manually.
Hope this helps.
There are multiple hit & trial solutions for this error. One of them will surely work for you.
Below are the solutions:
1.
Tools -> Android -> Sync Project with Gradle Files (Android Studio
3.0.1)
Go to build.gradle and click sync now
Click hammer(Build) icon to sync Gradle
or edit any of your module Gradle and then sync
File -> Settings -> Android SDK -> Android SDK Location Edit ->
Android SDK
Open build.gradle file, just add a space or press enter. Then sync
project.
File -> Invalidate Caches / Restart
Go to File >> ProjectStructure(⌘;). This would open this window then select the app module. Then choose the Compile SDK version . Choose the latest one and click apply.
I was having this problem on all versions of AS 3.0+. Syncing with gradle did not solve the problem for me. The solution from András Klöczl was the only thing that would allow me to get some coding done. The problem was, anytime I had to do a gradle sync, the problem came back. So I had to go through that process any time I wanted to make a change in my build.gradle. What ended up working for me was to downgrade my kotlin version from 1.2.40 to 1.2.30
My problem was that if I changed the project (for example opened new window of Android Studio with different project) this error happened.
So I read every answer in this question and the "clear caches and open the project again" solution wasn't so useful in my case.
Instead I discovered that if the Kotlin's plugin's version in Android Studio was lower than in gradle file, the problem appeared.
My setup was:
Android Studio 3.1.3
Kotlin plugin (in Android Studio) 1.2.30
Kotlin version in gradle file 1.2.51
What fixed the problem?
I updated the Kotlin plugin:
File -> Settings -> Plugins -> Install JetBrains plugin...
Then search for Kotlin and click Update. After update just restart the Android Studio and sync Gradle.
Just change build tools version to 25.0.3.. and sync now
I hope it will help..
This worked for me.
File -> Settings -> Android SDK -> Android SDK Location Edit -> Android SDK
Go to : File > Project Structure > Modules -> app > Properties
please choose : Compile 'SDK' version = API26 Build Tools
Version = 27.0.0 Source Compatibility = 1.8 Target Compatibility =
1.8
open build.gradle file. just add a space or press enter. then sync project. it works...
Sometimes android studio just acts stupid and needs some kind of reset..
Go to settings.gradle file it should contain include ':app'
change it to include ':ap' and sync.
after sync, change it to include ':app' again.
It should be working OK now.
The simplest solution for this problem:
First make sure your sdk path is currect.
Then
Please close current project and in android startup menu click on import project and choose your project from explorer.
This will always solve my problem
In my case there there is no selected java sdk version in project structure-
I had to select the -
1.Source Compatibility (1.7)
2.Target Compatibility (1.7)
as shown in image.
If you are using 'Profile or Debug APK...', then you might come across this error.
My solution is to first check SDK for updates in SDK manager: click on "Edit" at the right side of SDK location and go through to install any updates:
Then I clicked on "Logcat" at bottom of Android Studio and find out I also need to configure Android SDK, so choose latest Android API Platform:
After that, I'm able to run the APK in Emulator.
In latest android studio 3.3.2 the icon of sync project with Gradle Files is changed
Now try this
File -> Sync Project with Gradle Files (Android Studio 3.3.2)
For Android Studio 3.5, "File -> Sync project with gradle files" is enough.
Go to gradle.build file and click sync now
OR
click icon on Sync project with Gradle file
OR
Go to Tools-> Android -> Sync project with Gradle file
If your android SDK path is given and still you facing this issue then it might because your android studio not synced well, even you have clicked on "Sync now" link.
So for re sync it go to app gradle file and make any change or just give a space and now sync again. It will work perfectly.
In my case I downloaded a git repository for an android project. The project required minimum sdk version 21 and target sdk version 27. When I tried to run the project it gave me "Please select Android SDK error". I checked that I had already downloaded the required sdk files.
For me the solution was to "sync project with Gradle Files"

Android Studio "Unable to save plugin settings"

When I opened android studio today, it showed me the following errors:
Then, when after I restart Android Studio, I get these errors:
After I enable "Android Support", and restart, the first two errors show again, and when I restart again, I get this 3rd error again and the "Android Support" plugin is disabled again. (I even tried uninstalling and reinstalling Android Studio)
How can I fix this?
I have solved this problem this way:-
Go to File >> Invalidate caches/restart >> Invalidate and Restart
After restarted, If warning comes just click on Enable Android Support
I was using Gradle 4.1 and AS 3.0.1 when I got this error.
Look at Gradle console. If it looks anything like this, read on:
Plugin Error
Problems found loading plugins:
Plugin "Android Games" was not loaded: required plugin "Android Support" is disabled.
Plugin "Android NDK Support" was not loaded: required plugin "Android Support" is disabled.
Plugin "Android APK Support" was not loaded: required plugin "Android Support" is disabled.
Plugin "Google Developers Samples" was not loaded: required plugin "Android Support" is ...
...
Plugin "Fire... (show balloon)
Note that all say “required plugin Android Support is disabled."
Also note the link “show balloon”.
Click show balloon.
Choose to enable Android Support.
Restart AS.
I hope this helps you, too.
This can happen if a module is not added correctly.
Instead of adding the module folder, adding the build.gradle results in a broken project and issues with the Android Support plugins.
To check if this is the issue, try creating a new Android project. If the new project can be open fine (may require enabling the plugins and restarting Android Studio), then it is a project issue.
If this is the case, delete the incorrect module from the project, and if required re-enable the plugins and restart Android Studio.
TL;DR
I finally fixed it by removing .idea/workspace.xml and reenabling plugins worked.
Same issue happened to me when I installed AS 3.1 beta alongside AS 3.0.1(stable) and opened my project in it. It was ok for few sessions, until it wasn't. Can't figure out what exactly broke project configuration, but project would open in 3.0.1 and not in 3.1. Any other project would work on 3.1 too. Symptoms were the same: android support plugin is disabled, and it wouldn't enable. I tried invalidating caches, reinstalling AS (even 3.1 stable version won't work).
Eventually I noticed projectBackup and projectBackup2 folders created by studio in the project's root folder. They contained versions of workspace.xml file. So I removed these backup folders, and workspace.xml from .idea folder. Then studio asked to reload project and that's it - after that I could reenable all the plugins
For my case this seems to be a rights issue. When starting Android Studio with admin rights no problems occur.
Re-enabling the plugins as admin and starting AS again with my default user does not help.
Edit
I updated to the latest canary.
With the admin user I've installed AS.
I completly removed .AndroidStudio/config, .AndroidStudio/system and .AndroidStudio/plugins beforehand (I use a different location for these files, so I have to replace idea.properties after every installation. While doing this, I've noticed, that they renamed .AndroidStudio to AndroidStudio.2. That gave me the hint to remove those dirs.)
After this, I had no problems, regardless of which User ran AS.
None of the single solutions above where sufficient for me. I had the same issue after updating from android studio 2.3.3 to 3.1.2.
Close Android Studio
Remove .idea/workspace.xml
Restart android studio (your project with the issue is opened automatically)
A new .idea/workspace.xml is created
Sync project with gradle files
Open File -> Settings - > Plugins -> Enable
"Android Support" Plugin.
Android NDK support (I had to disable and re-enable it)
Restart Android Studio
I got this error today, I updated the Android Studio from Help>CheckForUpdates>Update.
After that installed the missing Google Cloud plugins.
Now it is working fine.
Got this problem recently with Android Studio 1.3 and 1.4.2 (beta). This was caused by an OutOfMemoryError in the Java heap.
I solved it by increasing the -Xmx and -XX:MaxPermSize values in the studio.vmoptions file
In android studio Go to file->settings->plugin-> enable androidsupport
In my case, I am using Ubunto and I had to Unlock the Folder of my project:
type this command on Terminal:
sudo chown -R $USER: $HOME
You can try this:
Rename the folder where the project is in
Open the project in Android Studio (now you'll have to browse for it)
Wait until it's synced and close the project
Rename the folder back to original
That solved it for me. Just deleting the idea folder and invalidating caches did not solve the problem.
If you are getting "Unable to save plugin settings" or "unable to save settings" Error window,
and you have tried all of the other solutions listed here, but they don't work for you, try the following:
Invalidate Cache: but don't select restart yet, select just "invalidate".
Close project and then exit Studio
If you have a previous backup of your Settings folder, restore it now.
If not, you will need to Delete your settings folder. For example, in Windows:
/ < USER_HOME_DIR >/.AndroidStudioPreview3.2
or on Mac :
/Users/<USER_NAME>/Library/Preferences/.AndroidStudioPreview3.2
Delete the .idea folder for your project
Re-launch Android studio, but this time select import project
Android Studio will re-index your project, but now the error will be gone.
After Android Studio has completed a Gradle Sync, it's probably a good idea to also make a backup of the settings folder
In my case, I installed a plugin, and on an android restart, it was failing to start. This was causing the plugin workflow to not run completely, and give the above error.
Disabling the faulty plugin solved the issue.
I just replace the project build.gradle like below. And it works.
buildscript {
...
repositories {
mavenLocal()
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url "https://jitpack.io" }
mavenCentral() // jcenter() works as well because it pulls from Maven Central
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
...
}
allprojects {
repositories {
mavenLocal()
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url "https://jitpack.io" }
mavenCentral() // jcenter() works as well because it pulls from Maven Central
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
}

Android Studio refuses to accept that Google Repository is installed

I am trying to get AdMob running. But for some strange reason, I can not get Android Studio to accept that the Google Repository is installed.
Thing is, it is installed in the SDK manager. And reinstalled multiple times now. Project Structure SDK path is the same as in Android SDK Manager.
When I mouse over the compile 'com.google.android.gms:play-services:6.+' line in my build.gradle, I get this tooltip:
"Dependency on Play Services, but the SDK installation does not have the "Extras > Google Repository" installed. Open the SDK manager and install it"
When I try to compile, this error:
Error:Failed to resolve: com.google.android.gms:play-services:6.+
With that error comes a link to install the Repository, which I used multiple times now. Android Studio does not care. Help.
edit: When I use a fresh empty project, it works, and Android Studio finds the Repository. No clue what is going on here.
I was suffering with the same problem and finally found a simple solution (I'm using Android Studio 1.5.1 on MacOS):
Go to File --> Project Structure
On the left hand of the opened window, under Developer Services, select Ads
Check the checkbox next to AdMod. Your window should look like this:
Click OK
This will add the required dependency to the Android's build.gradle, and sync Gradle.
When the sync is done, and just to make sure, clean and rebuild your project:
Build --> Clean Project
Build --> Rebuild Project
That's it! I hope this helps.

How to build a Maven Android project in eclipse

I am testing the code here : https://github.com/nkzawa/socket.io-client.java. Under features there is this sweet sounding line : "Android is fully supported". But being completely new to maven I can make neither head nor tail of the instructions. How do I build a basic Android test project with this code? Simply adding the source code from the repo to my project is showing lot of errors. If there is a command line way of doing this that would be fine too.
The Android for Maven Eclipse connector is an Maven Eclipse (m2e) plug-in that adds maven support for Android Developer Tools (ADT) and the Maven Android Plugin. It brings the power of Maven dependency management into the ADT.
Before you start
You will need Eclipse Indigo or Juno installed.
Install Android Connector
You can install the Android Connector for Maven via the Eclipse Marketplace. Select Help -> Eclipse Marketplace... and search for "android m2e".
Click the Install button next to the Android Connector for Maven that appears and follow the path through the wizard dialog to install the plug-in and its dependencies (including the Android Development Toolkit and the Maven for Eclipse m2e plug-in). Accept the terms-and-conditions and click Finish.
Once you restart your Eclipse workspace you should be ready to start using the Android Connector.
Create Eclipse project
If you already have an Android project please make sure you have created a POM for your project using version 3.0.0 or greater of the maven-android-plugin.
Then right-click on your project and select Configure -> Convert to Maven Project.
If you are starting with a new project you can use the Maven Android archetypes to create Android projects completely within Eclipse:
1. Create a new Maven Project (File -> New -> Project... then select Maven -> Maven Project).
2. When prompted to Select Archetype click Add Archetype...
3. In the dialog that appears enter "de.akquinet.android.archetypes" for Archetype Group Id.
4. In Archetype Artifact Id enter "android-quickstart".
5. In Archetype Version enter "1.0.10" and continue.
6. When prompted enter your desired project group and artifact ID, version and, optionally, set the "platform" property for the Android version (defaults to '16').
7. Click Finish
Either way you should end up with an Eclipse project looking something like this:
Steps to build a Maven Android project in eclipse
Install m2e(mavel plugin) to your ecplise.
Right click Create Maven project
Click next and in Catalog select Android
Give group id com.example and Artifact id Project name
click finish.
Typically you do this by importing an "Existing Maven Project". You get this option in the Import dialog when you have installed m2e. For Android you will additionally need the Android Connector before doing the import. Here it gets nasty. You can install the connector from Window -> Preferences -> Maven -> Discovery -> Open Catalog.
To be honest I had no luck with this connector yet. So the second option is (you don't even need m2e here):
Install Maven
Open the command line and navigate to your downloaded sources where the pom.xml is located
run mvn eclipse:eclipse to create eclipse project files
Import it as "Existing Project into Workspace" in the import dialog.
install m2e plug-in your eclipse.
install android m2e plug-in.
create new maven project.
select archtype:android-quickstart by typing android in filter.
finish you will get maven android project.
and add this plugin in pom
org.eclipse.m2e
lifecycle-mapping
1.0.0
com.jayway.maven.plugins.android.generation2
android-maven-plugin
[3.8.2,)
consume-aar
finally update the project by rightclicking on project->maven->update project.

Categories

Resources