I added the following dependency to to build.gradle file in Android Studio and resync-ed the project successfully:
compile 'se.emilsjolander:stickylistheaders:2.1.3'
However I was unable to use any of the class in this library. Feeling strange I opened the source tree and see if there's anything wrong. I noticed the following:
You can see Android Studio can found the available classes for other downloaded archives, but not the one I mentioned in this question. The classes.jar file is reported empty.
I tried adding an older version of the stickylistheaders library (2.1.3). Still an empty classes.jar.
When I start this question I found a similar post here. But the author of that post tried to include the downloaded project in settings.gradle, and he finally managed to include the library through the "compile" directive. My problem is that I AM using the "compile" directive, but the downloaded archive has a "empty" classes.jar. I also tried adding the library mentioned in that question (i.e. 'se.emilsjolander:StickyScrollViewItems:1.0.0'). Also an empty classes.jar.
Some notes:
The actual classes.jar file found in build/exploded-bundles is not empty.
I tried cleaning the project. I suppose this will cause all dependencies be removed and re-downloaded. However, after that, Android Studio still cannot spot any class in stickylistheaders' classes.jar.
So far, this problem only exists for se.emilsjolander's libraries. Strangely, the answerer of this post1 posted a screenshot showing that he does see a non-empty classes.jar.
Update:
I also tried deleting .gradle's cache directory in my profile directory, clean the project and rebuild again. No luck.
I can unzip the classes.jar in question. Looks like the file isn't corrupt.
Anyone knows what's wrong here? Thanks.
I think I have found the cause: it should be a bug in Android Studio.
https://code.google.com/p/android/issues/detail?id=64008
In fact, the code can build and run despite seeing errors in Android Studio. So it is obviously an issue with Android Studio.
Update 27 Jan: It should have been resolved in Android 0.4.3. As from the release notes:
Fixed a bug around library syncing (where library dependency classes
and resources could suddenly not be found by the IDE)
Have you tried syncing your project with Gradle?
Tools -> Android -> Sync project with Gradle Files.
That should reload the build.gradle file and download the (missing) dependencies.
Try this once and make sure you are not getting any error in project Structure saying that "your_lib_name not used/added"
Open File > Project Structure
and check for erros. If error is shown click on it , it will expend the errors and will show some options on right, click on the Red bulb and choose "Add to dependency".
This seems be a bug in Studio which will be fixed in next release(Android Studio 0.4.3).
Related
I am trying to import an external project into Eclipse for further coding.
Once the project was import, following errors were found:
found 2 versions of android-support-v4.jar in the dependency list appcompat in android.
Then, I have studied this link and found the solution.
Found 2 versions of android-support-v4.jar in the dependency list appcompat in android
I have deleted the android-support-v4.jar in library folder of the project but I cannot find
<sdk>/extras/android/support/samples/Support4Demos/ and copy android-support-v4.jar to replace the original file. Can anyone tell me the location???
Besides, are there any standard steps for importing an android project in the latest version of adt?? I find that there are many people has the similar problem but the solutions provided by others were so different. I am a bit lost about the correct steps.
I had the same problem and I fixed it really easy way: Firstly, I've checked which of the libraries android-support-v4.jar was the last updated. Generally, you can check the modification date and also the size of the file (normally, not always, the last version is heavier than the older versions).
Ok, you already have the last one? ok, replace (copy/paste) this .jar file in all the projects . The error will dissapear.
At least, for me was the solution. You need to have the same .jar file in all the projects imported and main project.
Clean all the project and build again!!!!
I have a strange issue where project specific root level files (.gitignore, gradlew, gradle.properties, etc) show up twice in Android Studio's project view. Does anybody know how to fix this?
I've tried re-importing the project (after deleting the .iml and .idea file/folder).
I found exactly the same problem recently when I created a new Gradle project and imported into IntelliJ. However, the root cause seems to be the use of symbolic links when importing the project.
I have the following symbolic link:
/data -> /Users/<user>/data
When I originally imported my project, I imported /data/checkouts/<project_dir> but found that I had duplicate files from the top level directory exactly like as shown above.
However, I removed the project and attempted to import it again, this time using the full path of /Users/<user>/data/checkouts/<project_dir> and found that I no longer see the duplicates.
I haven't seen this problem before when importing an eclipse or Maven project, so can only imagine that it might be related to the use of the Gradle plugin for IntelliJ.
I know that there are different solutions with different libraries posted. But, could anyone help me with this one?
I've busting my head for the past couple of days, and I really don't know what to do. I already tried importing the modules in all the suggested ways from different posts. (Project Structure --> Dependencies --> Add dependencies), etc. My project does not show any errors, but when I run it, it throws me a compilation error that complains about some classes missing. The library only depends on the ViewPagerIndicator's library which I also imported.
here is a picture. Thanks!!!
NOTE:I also have tried it with Eclipse, but the problem is different there. The app crashes when I run it. When I uncheck isLibrary from Properties -> Android and erase those libraries, the app works.
Inspired by this answer, these are the steps I did:
Put the jar file (in my case, 'xxx.jar') into the libs folder of your project
Right click it and select Add as library
Type this in the dependencies part of build.gradle file: compile files('libs/xxx.jar')
Do a clean build. It can be done inside the android studio, but I also ran the gradlew.bat included inside the project folder
Now, the project should be built and run just fine.
You are referencing the library wrong. You need to add the dependency in the build.gradle file. I recommend you to read the documentation first. It's a long read, but totally worth it.
I noticed that a user uploaded the library as .aar file in his maven repo. You might want to use the library from his repo. The setup is very easy (you only need to include the dependency of the better picker library).
I'm trying to make an app with Gradle in Android Studio, but all I get is this error message:
java.lang.IllegalArgumentException: Argument 0 for #NotNull parameter of com/android/tools/idea/jps/builder/AndroidGradleBuilder.createBuildTask must not be null: Argument 0 for #NotNull parameter of com/android/tools/idea/jps/builder/AndroidGradleBuilder.createBuildTask must not be null
I've tried debugging this and I actually can't figure out what the problem is.
Anyone with any ideas?
If you are using Linux, remember that uninstalling an application does not remove the previous configuration files used by Android Studio and X-Window.
So before launching your updated AS, remove the following files:
~/.AndroidStudio*
~/.java/.userPrefs
I've had and read some discussion on Google+ about this and I figured I still do a few things wrong since my project still does not compile with Gradle.
BUT, I've fixed this issue and from my understanding is that if you use Gradle you should not have to go into Module Dependencies, because it should be setup from the Gradle files.
So the first advice I can give you is to quit Android Studio and delete the .idea folder and all the .iml files in the project folder.
After this, open Android Studio and import the project, and remember to point to the build.gradle in the root directory (basically you have a build.gradle file for the project folder and then one build.gradle file for every module), basically mimic the structure that a new project has.
This will almost certainly fix this problem and also start the project from Gradle.
But you might encounter other errors along the way which could be a hazzle to debug.
But at the moment Android Studio gives really non-infomative error messages sometimes.
I had this error, and it appeared to be because android and android-gradle facets were somehow added to the parent module the project.
Removing these facets in Project Properties> Modules fixed the problem.
I have a rather big Android App project that is referencing several library projects. Everything was fine until i upgraded the eclipse ADT plugin to the newest version (v22). I also upgraded the SDK of course. I do not see any compile errors in eclipse, but when i run the project on the phone i get a NoClassDefFoundError.
java.lang.NoClassDefFoundError: org.acra.ACRA
....
The arca library is included in one of the referenced library project (in the libs folder) and i can see it in the "Android Private Libraries" in the package explorer, also as i said, no compile errors. The project runs fine on everyone else's computer that did not upgrade ADT.
I have already tried a whole bunch of stuff including but not limited to:
re-install the android SDK
download a fresh ADT bundle
delete all my code an get it again from git
copy the library in question to the app project
comment out the code that uses this library - i just get the same error for the next library
all without any success, so i'm getting really desperate here.
I would be really happy if anyone could give me a hint on how to solve that problem.
Quoting Streets of Boston from his adt-dev post:
When upgrading, the 'Order and Export' of the new 'Android Private
Libraries' is not always checked. And the android-support-v4.jar is now in
this 'Android Private Libraries' section.
To fix this, go to 'Order and Export' and check 'Android Private
Libraries'. Then refresh/clean/rebuild.
After you done this 'fix' for a library project, you may need to just close
and re-open any depending project, because they may not see this 'fix'
immediately.
Give this a shot and with luck it will solve your problem.
Simply checking Android Private Libraries was not enough, I also had to install Android SDK Build-tools in Android SDK Manager.
I had also the same problem and my adt was 22.0.1. And none of the solution above worked. Further when adding a external library project to a working project.I always check the gen folder of working project and if R of external library project is there (along with package name),then only external library project is exported. And on my gen folder no packagename of external library was shown.
So I checked on project.properties file and there wasn't any external library link present android.library.reference.1= present. So I manually added the external library reference there ,even though I had added from project->properties->Java Build Path->Projects->Add. So manually editing the project.properties did all the work for me.
I have encountered a similar problem, spent about 3 hours, but none of the proposed here decisions did not help... Finally I found a source of the problem: my project files & project.properties were read-only. Eclipse is simply silently ignoring any changes in library dependencies when I doing it in the GUI!
I had the same problem. It was because of the eclipse project.
To solve it I created a new project in eclipse, copy my existing project classes and resources into it and then launched eclipse again and added my custom includes.
I had the similar issue and my answer is slightly different from CommonsWare's. Here is my screenshot:
After checking the libs back in my build started to work again.
I had also the same problem,
i) add gson lib as referecend librairies
ii) check it in java Build Path