I am new to android development. I was going through this Guide to setup a roboelectric test project. In one of the steps, we need to add maps.jar as dependency to the project. The maps.jar is usually located inside addons folder in SDK directory.When i tried to locate the maps.jar in my SDK directory, I found that addons folder is not there. Is there any way to get it ?
I am using Eclipse Juno
I have finally figured out the reason , why i dont have the addons folder inside my SDK directory. It is because, i have not downloaded even a single Google API's of any version of android in Android SDK Manager.Finally fixed it by downloading Google API's for the required android version.
There was another question similar to this:
importing jar libraries into android-studio
To quote ant2009 from that question:
This was actually fixed with the new updated 0.2.8 version. All I did was create a new directory called 'libs' Dragged the jar file into it. Right click the jar file 'Add as library'. This will expand the jar file. Entered this into the build.gradle file 'dependencies { compile files('libs/jtwitter.jar')}. Entered the import statement to bring the classes into my source file. Everything worked fine. – ant2009 Sep 19 '13 at 6:33
Hope that helps.
Related
I changed the name of the Android Studio project folder in the Windows Explorer before I started Android Studio. Bad idea.
Now I get the error:
Gradle sync failed: No toolchains found in the NDK toolchains folder for ABI with prefix: mipsel-linux-android
And all my Activity files are replaced with one MainActivty that doesn't contains the things I've made.
Unfortunately I can't get a previous version with "show history" in Android Studio and i can,t get an older version via windows explorer "restore previous version"
I also tried to decompile it from the .apk on my phone. I got the layout and xml files but can't find my java classes.
I worked since weeks on this project and don't want to lose it.
Can anyone help me either fix the error or restore the .apk?
Thanks so much for all suggestions and ideas
First close the broken project this can be done with File > Close project
Then you have to reopen the project from the new location ie. the renamed folder.
File > Open... browse in your filesystem for the project, select the folder and press OK
Wait for the gradle to sync and hopefully you won't have any problems!
I have the same problem when updating ndk-18. You updated the NDK to version 18 and it is missing the folders/files. You can download ndk-v17 manually and extract the search folder "toolchains" to copy the missing folders/files to your folder android-sdk/ndk-bundle.
From github.
I am trying to import this project, even I tried to import other few projects too, I am getting below error.
https://github.com/ashdavies/data-binding
I have spent my 5 hours on it, even I tried many solutions on google but nothing gonna worked for me.
I tried following solutions, nothing worked.
1) delete .gradle directory
2) Restart IDE,
3) I tested with com.android.tools.build:gradle-experimental:0.7.0-alpha1
I am frustrated because of this Gradle and these issues.
Gradle Version : Gradle-2.13, I do not want to change this version.
Android Studio Version : Stable 2.1.1
Note : My other project is working fine and I can build it too.
You can try different workarounds for this problem :
1- Clean project and Rebuild it.
2- Before importing the project, remove the contents of the Build folders.
Then replace the contents of your gradle-wrapper.properties file with the following lines, to make it use a local distribution for building the project :
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=file\:/opt/gradle/gradle-2.13-all.zip
in which, the last line prevents android studio to download or use a corrupted gradle cache.
Go to any browser
type gradle and press enter
you can specify any version you want after the
gradle keyword
i am downloading gradle 3.3
https://services.gradle.org/distributions
click on this link which is in description directly if you want
click on gradle 3.3 all.zip
wait for the download to complete
once the download is complete
extract the file to the location
c://user/your pc name /.gradle/wrapper/dists
wait till extraction it takes 5 mins to complete
Now open your project in android studio
9.go to file > settings >bulid ,exec,deployment > gradle
now change use default gradle to
use local gradle distributn
select the location where you had extracted gradle 3.3.zip
C:\Users\your pc name.gradle\wrapper\dists\gradle-3.3
click on OK
Now build starts again and
you can see now the build is successful and error is resolved
or
watch tutorial
https://www.youtube.com/watch?v=u92_73vfA8M
In my case, it was happening because i haven’t set the JDK path in environment variable.
Please check from your Android studio studio that your JDK path is correct.
Go to Project Structure> SDK Location and check JDK Path. Give it the correct JDK path and also set the JAVA_HOME environment variable.
You can try this solution as i was facing this issue showing Error2 Gradle's dependency cache may be corrupt and gradle build not working and resolved it. Already answered this question on stack. You can reffer to this answer link
It includes firstly downloading latest graddle version from official site then replacing that unzipped file with home/yourUser/.graddle/wrapper/dists containg older version file on Mac.
Because your gradle path for project is incorrect.
Go to
->Settings
->Gradle
and select "use default gradle settings"
and than sync project. and issue will be resolved.
delete .gradle, .idea and gradle folder from the project and then invalidate cache and restart.
problem will be resolved.
Thanks :)
Sometimes it's a cache issue and sometimes due to interruption in download.
Step 1:
Try to download gradle distribution manually
https://services.gradle.org/distributions/
and then go to project settings -> gradle -> and use the file which you've downloaded
Step 2:
If step#1 still not working, then it may be a cache issue. If you are a mac user, go to your finder user folder, show hidden items by pressing [Command + Shift + .] , Go to gradle folder and
In my case is that gradle-5.1.1-all.zip download failed, so I go to zipStoreBase+zipStorePath(configured in gradle-wrapper.properties, eg: E:\gradle-home\wrapper\dists), and delete the gradle-5.1.1-all directory, and let android studio to download that zip file again.
I'm using eclipse ADT (most recent version) to develop some android apps. I've followed the getting started tutorial at the dev.android.com and it worked just fine.
But when i tried to create another project with the same targets and sdk's, i've got nothing but errors:
Some errors and my sdk's:
That's the same sdk's i used before these errors started showing up.
What can be causing this?
EDIT: my project won't generate the R.java file
You might need to add a support library to your new project.
Check this link for downloading the support libraries -
http://developer.android.com/tools/support-library/setup.html#download
Please notice that you need to import them into your eclipse and then include one (preferably the newest, not sure about this) in your project.
EDIT:
Before downloading the support libraries you should first check if you have them already.
Try this, right click project folder in the eclipse package explorer, Properties>Android>Library>Add>select a library if you have one.
There might be an invalid library included in your project already, if that happens then you will see it in the Library>Add> menu, remove it and add a new one.
You might have clean your project ........
if yes.....you must check whether R.java file is present in **Project(your project)->gen->package name->R.java**
if not than u have to update Tool Folder in SDK manager
You can find the project here: https://github.com/googlesamples/cardboard
The last time I worked with android was about a year ago and I'm trying to use this VR project to get back into it. All I want to do is mess around with the app to get a feel for it.
However, I haven't been able to get it running. I installed a fresh copy of Eclipse (juno) with the JDK and android SDK and got the android 4.4W stuff from the SDK manager. I also made a Nexus 5 AVD.
My problem is that I've tried choosing multiple 'root' folders to 'import as existing android project' and none of them have been runnable. Each time the eclipse terminal gives an 'Installation error: Unknown failure' error after installing 'MainActivity.apk'.
I figured the 'main' folder would be most likely to work since it has the manifest and all the other folders associated with android projects.
How do I get it running?
#CommonsWare: I have the project up and running on Eclipse(Juno) with Android 4.4.2
#ThroatOfWinter: These steps should help you. They worked for me.
Download the project from github as a ZIP file
Extract the contents of the ZIP file (named cardboard-master) into a folder and then import the whole folder into Eclipse as a new android project
Create a new "libs" folder in your project
To use the Cardboard API, download the VR Toolkit .jar file and include it in your project in the "libs" folder.
If everything has worked fine so far, you'll find that the "src" folder in your new Cardboard project is empty but the "java" folder contains 3 .java files.
Create a new package in "src" called "com.google.vrtoolkit.cardboard.samples.treasurehunt"
Copy the 3 files from the "java" folder and paste in the package you created in the previous step.
Clean and build the project
Test on an android device (preferably) with the cardboard app installed
You shouldn't need to edit the manifest at all.
That is not an Eclipse project. It is for use with Android Studio and Gradle. Your choices are:
Switch to Android Studio, or
See if somebody else has already reorganized that code into an Eclipse project, or
Attempt to reorganize it yourself, moving the contents of src/main/ into appropriate locations and fixing up the manifest for things that are set now in build.gradle, or
Find something else as a project to get back into Android development
This alternative worked for me: https://github.com/raasun/treasurehunt
It's pretty much the same as the Cardboard sample project from Google except that it's compiled with Eclipse/ANT instead of Android Studio/gradle.
Just follow the first part of moyheen's instructions to set it up.
To make it work on Eclipse, I just placed the Cardboard API jar (cardboard.jar) at the root folder of my app (alongside AndroidManifest.xml), and then in Build Path dialog I just did "Add Jar" and selected cardboard.jar.
Warning: Placing cardboard.jar in libs/ folder won't work, I tried, and it will produce an invalid APK that can't be installed.
I have been successfully using android-support-v7-appcompat library for last few months in my app to support action bar in older devices. Recently I have downloaded the Android 4.4(kitkat) updates with system image and SDK platform from the SDK Manager. I also added targetSdkVersion to "19" in manifest file. But my project was showing error as 'android-support-v7-appcompat jar mismatch. Fix your dependaecies.' Then I added the jar from /extras/android/support/.... to the project as an external jar using build path menu > add external jar. Now there is no error in the project and android-support-v7-appcompat.jar & android-support0v4.jar file is showing twice under 'Referenced Libraries' folder and also once under 'libs' folder. The project is not showing error and running, but crashing in different activities.
Previously I imported the android-support-v7-appcombat library as an external project in the workplace. I can see error in that project. Please suggest what should I do now. Also, android-support-v7-appcompat.jar umder Android Dependencies in Java Build Path showing error.
The error I see is:
Found 2 versions of android-support-v7-appcompat.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time).
All versions of the libraries must be the same at this time.
Versions found are:
Path: C:\<project hierarchy>\libs\android-support-v7-appcompat.jar
Path: C:\Users\....\sdk\extras\android\support\v7\appcompat\libs\android-support-v7-appcompat.jar
Jar mismatch! Fix your dependencies
After getting idea from different forum, I removed all the android-support-v7-appcompat libraries from different places, and imported android-v7 support library again in the project. Still it's showing error. Should I also delete android-support-v4 libraries from buildpath and libs/private librariry/referenced library folders?
This error occurs when there are multiple and different instances of the same library are found in the same project, or libraries used by it. A very simple way to resolve this is use the common lib at both the places. To do so:
Just copy your C:\Users....\AppData\Local\Android\android-studio\sdk\extras\android\support\v7\appcompat\libs\android-support-v7-appcompat.jar
and paste it in your libs folder, replace the old one with this. Clean the project, and it shall compile now..
Edit 1:
Basically the idea is if you are using the same libraries, it shall be the common jar, or the same jar.
In your case if you are using the appv7 as an external project, please go to libs folder of your project copy android-support-v4.jar, and paste into the libs of android-support-v7-appcompat project.
Also, make sure if there are other external jars or support libraries used by you, they shall be the similar jars in all the projects you are using.
I hope it helps!
I had exactly the same problem after installing all the updates mentioned in the question. I am sure there are different ways to solve this problem. Here is the way I used:
Previously, when an activity was created, the following project was automatically generated by the wizard:
androi-support-v7-appcompat and this project was added to the build path.
After all the updates, the following equivalent is generated when an activity is created:
appcompat_v7 with the jars of the same names.
I deleted androi-support-v7-appcompat and made sure the projects use appcompat_v7 to replace androi-support-v7-appcompat in their build paths. This made hundreds of errors generated by the duplicates go away.
I am glad that i finally found the answer. I was encountering the same problem again and again and i was like fed up.
Here is the answer to your question.
whenever you get such an error just don't touch anything other than libs folder. Just go directly into the libs folder and right away delete the android-support-v4.jar. and clean build your project. You will be relieved to get rid of errors.
Hope its useful to you.
Keep coding..
I have actually figured out the solution by trying different options suggested from different forum. I had manually change the android-support-v7-appcompat project's(which was added as an external project) project.properties file and had to set 'target=android-19'.