I need help with a project dependency issue in the Android SDK.
I have the following projects:
"Sync" (a Java only project)
"Agonis" (an Android Library project)
"Dragonis" (an Android application project)
Agonis has a project dependency on Sync, and Dragonis has a project dependency on Agonis, like so:
Dragonis->Agonis->Sync
I have correctly used the Properties->Android->Library dialog to add Agonis as an Android Library. I have exported the Sync project in the Agonis build path setup:
http://i.stack.imgur.com/GsQIR.png
In the Dragonis project, I see both Agonis and Sync in the "Android Dependencies" virtual folder:
http://i.stack.imgur.com/EhH8L.png
From here, I would expect everything to just work, but it doesn't.
I can start the app, but as soon as I instantiate a type from the Agonis project (com.mob.agonis.AgonisServer), I get a NoClassDefFoundError. If it matters, the Agonis type I am trying to instantiate extends a type that is in the Sync project (com.mob.sync.Server).
I tried cleaning all the projects, and using Android Tools->Fix Project Properties on both Agonis and Dragonis to no avail.
Am I overlooking something?
Put the jar library in the folder libs and add it to the java built path.
Right click on the file -> Build Path -> Add to Build Path
Hope it helps.
I figured it out.
The Sync Java-only library was compiling to 1.7 Java byte code. Android only supports converting Java 1.6 byte code to DEX.
Scroll to the top of the console, kids.
You can solve this through the command line tool. You could create/update the Dragonis and Agonis android projects - one as an application and other as library. See http://developer.android.com/tools/projects/projects-cmdline.html
You can easily set up the dependency from D -> A using the command line tools as shown in section called referencing a library project. At this stage, a build of D automatically triggers a build of A.
Now modify the build.xml of A - to include a dependency on : build and copy Sync.jar at the pre-compile stage (look inside build.xml to find the placeholder). The build and copy tasks can be done by starting a sub ant process using subant. See http://ant.apache.org/manual/Tasks/subant.html
At this stage all your dependency work properly on command line if you trigger ant build. Now you can also use eclipse by importing the android project Dragonis from source.
From the project properties of "Sync" set the "Java Compiler"-> "JDK Complience" to 1.6. Rebuild and enjoy!
Related
Previously I had a project, used Gradle as build system and Git as VCS and only added src/, res/, assets/ and manifest.xml to the repository. (As it is recommended I ignored all build files). Now I use android-studio-3.1.2 and tried to import that project:
Checkout project from Version Control → Git → clone
Then selected yes for Would you like to create an Android Studio project for the sources you have checked out to … ?
create project from existing source → select project name, location and type (.idea) → …
But I ended by this warning:
Migrate Project to Gradle?
This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system.
What causes this problem and how I can solve that?
Problem is caused by ignoring build.gradle files (in project and it's modules) and settings.gradle.
Also I did not find any way to solve that automatically by Android Studio. I have to create a project from scratch and move my files to that.
You dont need import project from scratch!
It is gradle problem which doesnot come from git
If you have latest android project,
You can copy paste "The Gradle" to project which have not gradle configuration!
It is more easy
Hi I am trying to make an android app on my Mac but am getting the following error when creating a new project
[2015-03-09 18:33:06 - appcompat_v7] WARNING: unable to write jarlist cache file /Users/shareennainar/Documents/workspace/appcompat_v7/bin/jarlist.cache
any help will be appreciated
Try this :
Project->Properties->Java build path. On the "Order and Export" tab, make sure you have checked all the libraries the project is referring to in your case appcompat_v7
Be sure you have android:minSdkVersion="14", else change it to 14 and do Project -> Clean
Also you can take a look -> this or this
If you don't need specifically use eclipse I encourage you to use Android Studio. I changed from eclipse to Android Studio and I think it's one of the best choices I did in my work.
P.S: That error looks like you don't have the appcompat library installed in your project. Are you using gradle? if so try to add it using the following line.
compile 'com.android.support:appcompat-v7:21.0.+'
If you don't use gradle you must add it manually.
EDIT: Here you can see how to import different libraries into your android project.
http://android-er.blogspot.com.es/2013/12/create-library-project-with-appcompat.html
This error means you're trying to load a Java "class" file that was compiled with a newer version of Java than you have installed.
For example, your .class file could have been compiled for JDK 7, and you're trying to run it with JDK 6. To solve this, you may take one of these solutions:
In Eclipse's menu
Window -> Preferences -> Java -> Compiler
Check "Configure Project Specific Settings".
Upgrade your Java runtime or
Recompile the class if you have the source, using your local Java compiler (if you have one).
javac FileName.java
I have a setup of android project on eclipse and I want to migrate to Android Studio. So, I have android-support-v4.jar that I use for my main project and my Facebook lib-project.
I guess I have to exclude lib-projects as a folder in my main module (lets call the main module Jack). Jack has dependancy on the facebook lib-project.
How should I define the android-support-v4.jar as a separate library and use it in both projects? Or should I just use directly the jar files and leave them in both Jack's libs folder and Facebook libs folder?
If the first option should be done, will ant clean release still work (with the build.xml android generated file)?
In Android Studio, builds are done with Gradle now. Gradle is different. With gradle, you tell your project which jar's you need, and it will connect to a server and download them if it doesn't already have them when you compile your apk.
A few things to note:
When you install Android Studio, it has it's own Android sdk directory. You have to download everything from the sdk downloader (from inside the Android Studio App) again. Don't bother trying to switch the sdk download path to your current one. You will only encounter bugs (Or at least I did).
So your question is worded very confusingly. It sounds like you have a main module, and then you have a library module, and the library module uses the support library.
You'll need to set it up so the main module has a dependency on your library module. From there, you'll need to go into your library module's gradle file and tell it that you want to include the android support library
dependencies {
compile 'com.android.support:appcompat-v7:19.0.0'
}
The support library is a little weird in gradle. Gradle normally would download the dependencies you need. However, android studio requires that you have the support library installed through their sdk downloader (top-right group of icons in android studio. The download icon).
After you get all your dependencies entered into your gradle file, you'll then need to go to Tools -> Android -> Sync gradle files with project. From there compile errors should go away, and you should be able to run the project.
Best of luck. By the way, Here is the documentation on Gradle on the android website. I find myself having to go to it A LOT, especially when I made the switch from Eclipse to Android Studio. This + Various tutorials I found as needed via google. http://tools.android.com/tech-docs/new-build-system/user-guide
EDIT: This link might also be helpful. Google has some steps for switching from eclipse to Android Studio: http://developer.android.com/sdk/installing/migrate.html That with some of the stuff above may prove helpful.
While I haven't tried this myself, I suggest you use the recommended migration steps provided by Google in this article.
Before you do that, though, make sure that you either:
Check that both support libraries on the main project and dependencies have the same version (Eclipse will complain about it during build time, and will likely cause problems during conversion to Gradle script.); OR,
Uncheck the "Android Private Libraries" entry on the Order and Export tab of the dependency project's build settings.
If the migration process described doesn't work smoothly for you, you can always call the Ant build script from within the Gradle script, as described here.
The Android Studio uses only Gradle, but you can export Android ant project from eclipse.
To do that go to File -> import project usually next, next, next... works.
If not go to project setting Shift + Ctrl + Alt + S and under modules -> PROJECT_NAME -> Dependencies you can add your support library.
To add a Facebook library you must add it as another module to your project.
If you still want to use Ant there is another option: Use Intellij IDEA which support Ant.
I have a simple Android library project, which contains network calls functionality only. It doesn't need to inherit any XML/resources etc… to calling application. When I build this project using Eclipse IDE (right click on project and click on Build Project), it generates a JAR under bin/libproject.jar. I can simply drop this file to any project's build path and it works fine.
Now, I want to implement continuous integration for my library. That means, I need some command-line way to achieve the same (building jar, when I build the project using ant). Ant builds the project differently. It creates classes.jar in bin/ folder, which is not the same as as libproject.jar.
I believe Eclipse's Build Project (ADT rev-21) is doing something magical to build this complete JAR for my library project (this is more like a java project like JAR).
Do you know how can I achieve the same using command line?
im using eclipse 4.3 w/ ant and with sdk tools 21.1
IMO - they recently changed the sdk regarding lib dependencies.
http://tools.android.com/recent/dealingwithdependenciesinandroidprojects
see the above link.
my example lib dependency(transitive) as follows:
ABS <== SlidingMenu <== MyProject
so, in SM.project.properties...
android.library.reference.1=../../src/ABS/library
and, in MP.project.properties ...
android.library.reference.1=../../src/SlidingMenu/library
The ant build, run on proj=SM using either eclipse internal, ant build tools OR ant on CLI in a terminal session outside eclipse
does following:
[javac] Note: Recompile with -Xlint:deprecation for details.
[echo] Creating library output jar file...
[jar] Building jar: /home/rob/src/tools/ActionBarSherlock-4.2.0/library/bin/classes.jar
and ant build, run on proj=MP does the following:
Setting project property: out.library.jar.file -> /home/rob/src/SlidingMenu/library/bin/classes.jar
..
[jar] Building jar: /home/rob/src/SlidingMenu/library/bin/classes.jar
IMO - you should focus on 2 things :
get the lib reference correct in the file=project.properties of the dependent.
double check in eclipse the project /properties/ java build path / order and export
read the link as it contains multiple , specific NOTEs relating to 'order export'...
When you build the dependent project in ant , it should trigger internally, builds of the other projects. I think that is controlled in the build path of the dependent project.
An additional NOTE on debugging - i could not debug directly from the project explorer because the launcher did not like the "classes.jar" for the 2 , dependent projects. Debug insisted on there being jars with names "${project-name}.jar" in the ./bin directory of each library. But ant assigns "classes.jar" as shown above.
So, to debug, i used the alternate method of DDMS tab in eclipse w/ the app already running. then u find the process and attach the debugger.
I'm trying to build my project using ANT. My project uses ActionbarSherlock, and Roboguice-Sherlock. ActionbarSherlock is an Android library project, but Roboguice-Sherlock is not. It's not even an Android project at all. See here:
https://github.com/rtyley/roboguice-sherlock
I can get ActionbarSherlock to build using ANT no problem, the problem lies with Roboguice-Sherlock. It's not an Android project, yet it has dependencies on Android and ActionbarSherlock, as well as Roboguice. When I try to build I get a ton of errors saying it can't find the Roboguice-Sherlock stuff.
If your project has the Roboguice .jar and the library project reference to ActionBarSherlock already configured you should be able to just drop it into your libs/ folder to have it automatically picked up.
I am working with Roberto to ensure that the .jar of his project gets uploaded to GitHub for non-Maven users to use.
For now, you can clone the project simply run mvn clean package to get a standalone .jar in the target/ folder which will enable you to do as I described above.
You need to add robiguice-sherlock as a .jar to your Android project. You can download it here (click Download (JAR)). Trying to build the source in Android will fail because it is not an Android project. Once it is in your directory, you need to open project properties and add the .jar to your build path.