Maven, IntelliJ Idea and Android Sources - android

I am using combination of Maven and IntelliJ Idea.
Although javadoc and sources are shown using Android Module in Idea, I can not see any of them using Android maven.
Any help, how to show sources also with Maven in Idea? Should I set it in pom.xml or somewhere in Idea preferences?

Please check the related issue for the workaround:
manually attach the sources to "Maven: com.google.android..." project library
See the Module Dependencies for details how to do it.

First of all make sure you downloaded the sources from the Android SDK for the target that you are using in your project.
Now in IntelliJ, under Project Structure (CMD+;) => Modules => Dependencies you should be seeing "Maven: com.google.android:android:4.1.1.4" and also "Android X.X Platform (java version... )". Select the "Android X.X" and press the up arrow at the bottom to move it up so it's at the top.
Now you should be running with the SDK module which include the sources

Related

Adding crashlytics in an Android project without Gradle

I'm working with an Android Project which does not have Gradle. It is an old-style structure project which has not been updated for using Gradle.
I'm trying to find the way of adding Crashlytics but I cannot find a way.
Is there any easy way to add crashlytics without Gradle?
Thanks.
Are you using Android Studio?
All the ways you can integrate are listed on Fabric's download page
If you are not using gradle, I guess it's still a Eclipse project. And Crashlytics is now part of Fabric, so I guess it's Fabric too what you are using.
About Eclipse, I'd recommend migrating it to Android Studio and take advantage of Gradle, but anyway, the steps would be:
Clip on Help -> Install New Software
Click "Add..." and add a new repository with the name Fabric and in the location, type in https://fabric.io/download/eclipse.
Look for "Fabric" and check its checkbox
Install it, restart eclipse, and you should be seeing a new blue icon in Eclipse's toolbar, for Fabric.
Edit: for using the library files (jar and aar) directly, in a IDE independent way, or with maven, the artifactory repo for twitter can be useful: https://twittersdk.artifactoryonline.com/twittersdk/webapp/home.html?3
There, you can find crashlytics libraries: http://twittersdk.artifactoryonline.com/twittersdk/webapp/search/artifact/?4&q=crashlytics, and also fabric: http://twittersdk.artifactoryonline.com/twittersdk/webapp/search/artifact/?5&q=fabric
For every dependency, Twitter's Artifactory help with code for Ivy, Maven or Gradle integration.

How to Use Android PagerSlidingTabStrip library or any other gradle built library in Eclipse

I have a problem importing the PagerSlidingTabStrip library into Eclipse, I get multiple errors and I know this happens because the library was built using gradle.
I tried to follow this answer but I can't find use as source folder in the build path menu.
I've never used gradle previously and don't know how to go about this in Eclipse. Please guys, help most of us who have this problem out of our dilemma. Would be very grateful.
Okay in the end this was what i did:
I checked the build.gradle file of the library for target and min sdks. I then put what i found in the android manifest.xml which I know Eclipse uses.
I deleted the build.gradle and gradle.properties files.
Made sure the project was marked as a library. And it works!
I think the most crucial step was to check the build.gradle for the sdks and whatever else the project requires and replicating that the way it should be in the manifest file.

NoClassDefFoundError: org.slf4j.LoggerFactory on an Android applicaton with Graphhopper

I am currently developing an Android application and I'd like to use Graphhoper 0.3 embedded in the application (I have no way of setting up a server).
I am working with Android 4.0, Eclipse Kepler, Maven 3.2.1, Android for Maven Eclipse 1.0.1.
I first tried to pull branch 0.3 and set the "core" folder up as an Eclipse project, then adding it in the Build Path of my android project. I also tried to use the graphhopper-0.3-android.jar directly.
Android Project Main Activity onStart():
GraphHopper hopper = new GraphHopper().forMobile();
Unfortunately, everytime I got the following error:
java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
It does not pop in a regular Java project; only in Android.
I've tried to add the slf4j JAR's to the build path, with no success.
Any help would be greatly appreciated! It's my first post here, and I really don't know what I could try more. If you need any more information on my setup or anything, please ask!
Edit
Complete solution in comments of the validated answer.
Because you are trying to use Graphhopper directly, the Maven is not downloading all the dependencies of the Graphhopper. In order to fix this, you should either add the Graphhopper as Maven dependency, or try to resolve the dependencies 'by hand' - i.e. by adding missing classes to the build path and exporting them to the APK (if you are using Maven, then simply add the dependencies to the pom.xml without scope tag).

How do I import com.google.android.gms.* in Android Studio using a Gradle build?

I have followed the procedure as described here : Setup
I have clicked on the little 'Sync project with Gradle' button. Gradle and Android Studio seem to find everything but then I can't actually use the gms code. If I try to import, I will get autocomplete for com.google.android.gms but no further. I have updated all the packages with Android SDK Manager.
I'm running Android Studio 0.4.2.
My minSdk is set to 9
my build.gradle includes compile 'com.google.android.gms:play-services:4.0.30'
As far as the procedure is concerned I should be ready to code, but it just doesn't work. Any ideas?
[Edit, added info]
I can find the ComGoogleAndroiddGmsPlayServices3265.aar file in my exploded bundles directory. Inside of that file I also find the common directory and inside that I find the GooglePlayServicesUtil.class (which is what's not being found in my app)
I am lost.
[Edit 2]
The problem is not specific to Google Play Services OR Android Studio. I tried adding another library (HoloColorPicker) and had the same results. However, I was able to add the library's resources to my project! I was able to add them in my XML layouts and view them in my application. I was able to interact with them, they worked fine. The problem arose again when I tried to reference them in the code. Exactly like the case with gms, I had code completion when trying to import up to the point of the actual class, and I could not declare the class in the code.
I was able to use the library by cloning it and importing the project.
Also, this is not an Android Studio problem because the same thing happens on the command line with "./gradlew clean build"
This is a current bug in Android Studio: https://code.google.com/p/android/issues/detail?id=64508 to be fixed this week.
The workaround is to close the project, delete the .iml files and .idea project and re-import the project.
Keep Your compile 'com.google.android.gms:play-services:4.0.30' as very first line in build.gradle dependencies like
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:+'
}
`
Open File> Project Structure and do the following steps
Select your main module in which you want to add dependency and click on OK.
Now try to import.
I think the most important question is what you want to achieve. Not all code is under this package. Not even sure which one is.
As noted before, this is a bug with Android Studio. It just don't recognize the path for classes and shows you like if there is an error. If you try compiling you'll see that everything just work fine.
A googler recently said it'll be addressed in this week release, so, be patient and lets see whats coming.
The fact that AS is in Preview mode tell us this sort of things are going to happen :)
Android studio is crazy one, I think.
It's removed "Import module" function and you can do "New module" only.
If you are developed on Eclipse, you need export all your projects to Gradle before switch to Androids studio (WTF?)
I prefer "IntelliJ IDEA Community Edition", although It's similar Android studio but it's better than Android studio (at least until now). You just import your project as eclipse format, IntelliJ IDEA will detect dependences libraries automatic (May be you need import jar libraries by hand) and rebuild project. That Done.

Android Library Dependencies broken after SDK/ADT-Update

Today, I updated my Android SDK and Eciple ADT to the most recent versions (ADT Rev 22). After restarting Eclipse it is quite unhappy with the Build Paths whenever I reference custom libraries.
An example is shown in this screenshot:
My custom "Android Utilities Library" compiles fine, but everything that depends on it shows build path errors. E.g. when I investigate the build path settings for "Android URA Library" it shows me an error with the android_utilities_library.jar missing under "Android Dependencies" (which in fact is true, the libraries will be built to individual class files in bin/classes).
After reading the solution to Build path errors with library projects I tried to clean and manually build my projects in the correct order, but to no avail.
I've never dealt with this before, so I don't know how to attack the problem.
Any help is appreciated. Thx!
Installing the new Build Tools did the trick. They were not automatically included when I updated the SDK (probably need to run the update twice I guess).
I found a solution that works for me:
Go to Project Properties > Build Path > Order and Export
Then you have to check each checkbox.
In my case my libraries were restored
I hope it will help.
I can see that your project Android URA Library is referring to Android Utilities Library, then the problem should not relate to SDK/ADT update.
Please check:
Project Properties of Android URA Library, choose Project tab and make sure you added Android Utilities Library as dependency project. Otherwise, please add it.
If the problem is still existing, then Projects \ Clean All Projects
Go to libraries and check the build path of the dependent libraries. It should be same as your projects build path.
if you have import all the Dependencies in your workSpace.maybe you can:projetc-->build all.
I meet the problem,and it works well

Categories

Resources