IntelliJ can't build Gradle project due to missing libraries - android

A while back I started a project that uses libgdx. It supports all platforms so I have a module for each in my project structure. The project worked for a long time and then I updated a few things in the IDE (I don't know what, I just accepted the updates) and nothing would build or run. Since I hadn't really made any changes I backed up my project folder, deleted it, checked out the project from github and tried to start over. Unfortunately no.
Every time I build the project I get this error:
Error:Android Gradle Build Target: java.lang.NoClassDefFoundError: com/android/utils/ILogger
When I go to file > project structure > Modules > android > dependencies the following libraries are all missing classes:
appcompat-v7-25.3.1
support-compat-25.3.1
support-v4-25.3.1
support-core-ui-25.3.1
support-core-utils-25.3.1
support-fragment-25.3.1
support-media-compat-25.3.1
support-vector-drawable-25.3.1
animated-vector-drawable-25.3.1
According to the IDE they are all supposed to be located in:
PROJECTDIR\android\build\intermediates\exploded-aar\com.android.support\LIBNAME
but \exploded-aar\ doesn't exist.
I have spent the whole day searching and trying different solutions to no avail so I don't even know if this is the problem. Any help is much appreciated.

There is an open bug logged for this problem. Please follow for updates.

Related

Android studio NDK Gradle build "Source ... and destination ... must be different"

I'm using Android Studio with NDK, Gradle and CMake to build several shared libraries and link them together.
I keep getting the same error again and again in the build log:
:app:processDebugManifest [Passed]
:app:externalNativeBuildDebug [Passed]
Source C:\XXX\app\build\intermediates\cmake\debug\obj\arm64-v8a\libBGS-d.so and destination C:\XXX\app\build\intermediates\cmake\debug\obj\arm64-v8a\libBGS-d.so must be different
It's like gradle is trying to copy my library at the same position.
The thing is, I have no idea where this instruction comes from and how I can debug it. There's really not much indication in the build log.
What's confusing is that is doesn't occur 100% of the time. Seems like there is a race condition somewhere. Also sometimes it's another library that triggers the build to fail. Also, cleaning the project doesn't help.
So here's my question: is there any place where I can get granular control over the Gradle build sequence ?
According to Dan Albert at https://stackoverflow.com/a/62223434/8068814 this appears to be a bug and he suggests cleaning the project, then triggering "refresh linked c++ projects" and then building the project. Since it is sometimes working for you, this might be a reliable solution in your case.
For me this did not help, but reverting the Gradle plugin to 3.6.2 was the only way for me to build my project.

How to get verbose messages of gradle sync?

I have a multi-module (>20) project in Android Studio. The problem which I am facing is that whenever there in some change in build.gradle file of any module or if a new module is added, Android Studio asks for gradle sync which takes insanely high time (~12-15 minutes) and memory (order of 5GB). I want to know why what is causing this? Is there a way to find out what happens during gradle sync? Is there a terminal command to run gradle sync?
Please help!
I have been trying to figure out what actually happens during a gradle sync and how one can improve gradle sync timings. I am summarizing what I have found in this answer.
Gradle sync is an Android Studio feature. Its sole purpose is to update the project model in Android Studio with respect to the build.gradle files in the project. For example, you might notice that a newly created module in your app is shown as a directory, but after gradle sync (assuming you have appropriate build.gradle for that module which points towards java sources, tests, resources etc.) the module is shown as a library (with a icon on your module's directory) in Android Studio. You may refer to helpful answer here.
In a project which has large number of modules, you might notice that the gradle sync process consumes a lot of time and memory. I do not completely understand the reason behind this, but changing the vmstudio.options file to following configuration has helped me improve the gradle sync time to some extent:
-Xms512m
-Xmx4g
-XX:MaxPermSize=2g
-XX:ReservedCodeCacheSize=512m
-XX:+UseCompressedOops
I hope this is useful!

Could not find BaseGameUtils.apk

For the last 2 days I've been trying to simply get Google play game services Integrated into my game. I've followed the instructions here...
https://github.com/playgameservices/android-basic-samples/blob/master/README.md
...many many times. I have been trying to get it to build with Gradle but for now, I'll just focus on Eclipse building until that works. I've imported BaseGameUtils project into my workspace as an Android library project. My game android project has two Android library dependencies: google-play-services_lib and BaseGameUtils. Everything in Eclipse is showing without any errors. When I build and run on a real device, I see an error that says -
[2014-10-27 20:39:25 - BaseGameUtils] Could not find BaseGameUtils.apk!
I don't know why it's even looking for BaseGameUtils.apk since it should be an Android library. That said, I'm not sure how an Android library is really handled so maybe it should be a .apk. In any case, I couldn't find any information on this bug and the error message doesn't give me much to work with. I've tried adjusting things in the Build Path but no luck. I did have to remove some redundant dependencies in my Build Path earlier since I was getting some kind of duplicate DEX error but I'm not sure that's related in any way to this. I am desperate for help, anyone have any idea?
Can you try this? It has to do with conflicting methods of specifying that a project is a library.
I found the source of the problem!
It turns out that "with the new library feature, you don't specify the
Android projects you depend on in the Java Build Path section of the
Properties. You do it in the Android section of the Properties".
So all I had to do is go the Application Project's Properties, hit the
Projects tab, select my own library project and click the Remove
button. That's it. No more problem.
In Eclipse Java EE select the project Properties, then select Project
References, then check the FacebookSDK (see screen capture)
From: Android Eclipse - Could not find *.apk
If that doesn't help, you may want to double check that you selected "Is Library" in BaseGameUtils.
Also, when you hit "Run" in Eclipse, are you running your application and not BaseGameUtils?
Please would you check that BaseGameUtils has "is library" checked and that your application project DOES NOT have "is library" checked.
If this is correct, then please would you review the following in detail (especially as regards checking and unchecking "is library" ) :
Android Eclipse - Could not find *.apk
I presume that the DEX error related to two or more versions of the same lib. What is the specific GameHelper error ?
As a general point, I find it productive to get a sample project working first to ensure that I have got the environment working correctly before I start integrating game services into my own projects. If you have been changing the build path then it may be quicker to start from scratch and get a sample working. I have followed those instructions in the past and they are accurate.

Android Studio Gradle error

Everything is ok but when i try to run it gets one error
Gradle: : java.lang.NullPointerException
Please help me, because i wanna to throw all this stuff with my NTB down from the cliff, after about five hours of configuring git, android studio and copying my projects from Eclipse, still got this
I had the same problem. I solved it by going into 'Project Structure' and one of my modules had both 'Android' and 'Android - Gradle'. I deleted the 'Android - Gradle' and rebuilt the project and the error disappeared.
Edit: I had bigger problems than this and ended up creating a new project...
You need to make sure Gradle is installed and properly configured in the preferences.
I had the same problem. It was because the path to android studio contained a whitespace. Installing android studio to the recomended location solved my problem.
As easycheese underlined the problem is related to the presence of the android-gradle item below one or more modules in your project. Go to the "project structure" (from the File menu) and check which module has two sub-items, one of them must be the android-gradle, delete it and rebuild your project. It should fix the issue......as J.Romero says...Android Studio is far from being ready for professional use, but what it is really annoying is that Google, with all its resources, gives developers such "immature tools" that make rather waste time than anything else....shame
I wont re-write my whole answer, but check out the following page in which i replied to a Gradle common error with over 10 common solutions across the web including mine.
Long story short, for me it turned out to be system resources were getting low (Google Chrome was the greedy one)
If it works after a fresh reboot, but after a few minutes or hours it starts.. This would indicate this.
Gradle Error In Android Studio

Conversion to Dalvik format failed with error 1 with javax/net/SocketFactory.class

Encounter this problem when trying to Build Project getting such output in console:
[2010-07-19 23:29:23 - myProject]
trouble processing "javax/net/SocketFactory.class":
[2010-07-19 23:29:23 - myProject]
Attempt to include a core VM class in something other than a core library.
It is likely that you have attempted to include the core library from a desktop
virtual machine into an application, which will most assuredly not work. If
you really intend to build a core library -- which is only appropriate as
part of creating a full virtual machine binary, as opposed to compiling an
application -- then use the "--core-library" option to suppress this error
message. If you go ahead and use "--core-library" but are in fact building
an application, then please be aware that your build will still fail at some
point; you will simply be denied the pleasure of reading this helpful error
message.
[2010-07-19 23:29:23 - myProject] 1 error; aborting
[2010-07-19 23:29:23 - myProject] Conversion to Dalvik format failed with error 1
I was looking for my project to use the package javax, not found, clean all also does not help. what I am doing wrong?
Update
Sorry guys, but I could not find good fix for that, I want to emphasize the fact, that i dont use SocketFactory class in my project at all! source code was not changed before this problem, and that's why i think that problem in eclipse or adt or something else, BUT if i use ant(generated by sdk) to build this project there is no problem!!!
I solve this problem by removing Eclipse, Android SDK, Eclipse workspace, and just reinstall them, after this all works fine for now.
Hope this will help someone.
I had the same problem..
This worked for me
project-->properties->java build path->libraries-> remove all including android jars
now go the project browser, right click on the project you are working on,
then android tools---> fix project properties...
do a clean and then build...
I solved the problem (at least for me).
Here's what I did:
Go to Project » Properties » Java Build Path » Libraries
Remove all except the "Android X.Y" click OK.
Go to Project » Clean » Clean projects selected below » select your project and click OK.
That did the trick for me.
Hope it works for you as well
Update: well actually I might have to retract my opinion.. the actions removed the error messages but now I am missing certain classes and methods... arggghhhh
I just restarted Eclipse, and the error didn't appear anymore!
I had the same problem,and solved it as follows:
First clean all jars; (This problem must because your some jars)
Delete the project;
Reimport project;
Make sure your sdk is right, and project select one sdk version;
(This is my issue to solve the problem) Right click your project, and select "build-path", next select "add Librarys", and add your private jars;
clean-build, the problem has fixed;
I just had the same problem and I tried all of the solutions listed here with no success (I was starting to get annoyed). Then I removed the project from the workspace and then imported it again, and there were no problems!
This happened to me this way,
I have a quite an old project which I had to start working again today. I use 'Universal Image Downloader' library for basically every project where I have to deal with lots of images. So in this old project I had the source files of 'Universal Image Downloader' included to it's 'src' path. Back then I was a newbie and slowly I started developing my own library which could handle every day simple Android development tasks very easily. Obviously I included the 'Universal Image Downloader' to this.
After dusting off the old project today the first thing I did was to reference my library to speed up the development process but as I was trying to debug I ran into the "Conversion to Dalvik format failed with error 1" over and over again. First I thought it was the support library but even after clearing all libraries and adding only mine and doing a quick 'Fix project properties' I still got it. After trying various solutions I noticed this in the console "java.lang.IllegalArgumentException: already added: Lcom/nostra13/universalimageloader/cache/disc/BaseDiscCache;"
It was as simple as that... I'm trying to compile a class which has already been compiled.
Solution : I just simply removed all the class files I got from 'Universal Image Downloader' library from the 'src' directory. Since my library references "Universal Image Downloader" library the old project started working just fine.
Hit same problem shown on your log when trying to run an example project which was imported into eclipse.
Additional Info: in eclipse's Problems View I see the following error:
"The project cannot be built until build path errors are resolved"
In my case the imported project find the libraries just right(by just right I mean I can see the external path to each of the android libs in this case 2 libs, android.jar and maps.jar). So no shuffling of libs in my case, but might be your problem.
I followed Spock's suggestion of cleaning the project which I had to clean multiple times until it somehow resolve its issues. After, issue was solved I had to specify an AVD for the project to run and soon after was up and running on the emulator. Also, note that my eclipse is set up to Build Automatically.
In my case I'm not missing any class files or anything after the clean as the build is properly generating them.
Regards!
I was getting the same error. My problem was that i had an android device hooked up to debug with. As soon as I unplugged it I was able to export.
The answer I found was checking the source and library build path in the project's properties. Most likely there will be a duplicate as in something being referenced in both the source and library tabs. So delete the extra in the source tab and then clean the project and you should be good to go.
Either:
javax.net.SocketLibrary is in your source code, or
javax.net.SocketLibrary is included in a JAR file in your project
Under certain conditions it gets its knickers in a twist and the best fix I've found is to remove referenced jars, clean, add them back in and then compile again.
I believe the error can be caused by including the same classes twice.
This error will also occur (and you won't be able to get rid of it by cleaning) when using classes that are not part of the Android environment.
To summarise the information in the link bimbim.in provided (well my understanding when I glanced over it)
The Android Davik VM tries to compile the jars but finds some stuff that it can't compile to .dex files
so
Just create a "lib" directory in the root of the project (where the src, bin res directories are) and add them to the build path. Project Properties... Java Build Path... Libraries.. Add JARs..
I could resolve this issue by creating a new project, looks like the some project settings were creating this issue and could not really find the root cause for that. But, dumping the existing source code onto the new project resovled this issue. If anyone has found the root cause for this problem pls do let me know.
I had the same problem and solved it as follows:
- Go to Project/Properties/Java Build Path/Libraries and remove all JARs except Android
- Do a project clean
- Add the JARs again as External JARs (first time I added them internally, so that might be the problem)
After that the error was gone.
I solved the problem by updating available packages in the Android SDK et AVD manager. No need to remove Eclipse.
Whenever the Project is having the ambitious data. This problem is caused. May be android can't able to find which one choose.
From what I understand, this same cryptic error could be caused from a wide variety of reasons. I've got "Conversion to Dalvik format failed with error 1" error too. In my case the problem was that for some reason Project -> Properties -> Java Compiler was not set to "Enable project specific settings" with proper Java 1.5 settings, but was left to defaults instead (1.6 in my case). Debug, build and test on devices/emulators worked fine, but export always failed with the above error message.
If unsure about the proper settings, create the same project on some alternative location and just copy all needed files from the old project into the new one. This fixed the issue for me.
The next problem with the same error message came from using proguard. Updating to the latest version by replacing the one that came with android sdk, fixed that.
Hope this helps
My problem was having a jar file in my src folder. Removing jars from the build path works, but only if you don't need the jar in question. For people who need the jar in question, make sure that your jar file is not in the project folder (maybe just src subtree, but I would keep it separate to test). Put it on your desktop or something and try the "Add external jar.." option. Be sure to remove the jar from the project filesystem before adding another external. Having both is what causes the problem.
I have done it as the instruction of the first answer and it works.(Linux)
I think the problem may caused by SDK or ADT updates.
I do have to clear all the lib in Java Building path and then use android tools to fix the project. After cleaning and rebuild, it works as before.

Categories

Resources