Java folder in android project and the src is empty - android

I found a library on git. https://github.com/flavienlaurent/NotBoringActionBar
after imported to the eclipse, I noticed that the src folder is empty and there is a folder called java. Tried to run it anyway but it gave me an error.
Do I have to make some changes before running it?

The project you are trying to import is developed with Android studio, so there is some extra files in it.
To import it in your eclipse you need to import it as normal android project. now your src folder is empty and you have an extra folder named java
copy com package from java folder and paste it in src folder
Delete java and bin folder
Clean and build your project
Run on emulator or device

The Project you are trying to import is a project based on Gradle build system developed using Android Studio.
In such project everything related to code is in App/src/main
/java contains all .java files
/res same as res in eclipse
AndroidManifest.xml
So easiest solution is create a new project in eclipse and copy paste the file accordingly,
In you case
Copy the src/com directory in /src in eclipse
Copy the /res in to /res directory of created project
Replace AndroidManifest.xml
But it is strongly recommended to migrate from Eclipse to Android Studio instead of doing all these because now all the libraries available are migrating in to gradle.

Related

Remove extra folder from Android Project View in Android Studio

I have the library and 2 samples for it. Say my-sdk, sample1, sample2. The file structure is:
Project folder, inside it settings.gradle, my-sdk and samples folder. Inside samples I have sample1 and sample2 folders.
My settings.gradle:
include ':my-sdk', 'samples:sample1', 'samples:sample2'
The problem is:
In Android Project View I see 4 projects:
sample1
sample2
my-sdk
samples (empty)
How to remove samples folder from Android Project View?
BTW. I have file samples.iml inside samples folder. So looks like for me that Android Studio thinks thats samples is a module but it just a folder for other modules.
UPD If I try to remove this empty module from Module Settings F4 than IDE crashes.
Do these steps:
remove from the sample folder the .iml file
remove from the sample folder the build.gradle (if it exists)
run a ./gradlew clean and resync gradle project.
If it is not enough remove:
.idea : in this folder Android Studio saves the settings
.iml in each module. In these files Android Studio stores the module information
Delete these resources, and then reimport again the folder.

Android project not generated regurlary after import from svn in ADT eclipse

Whenever I import an android project from svn the project doesn't generate properly.
So I have errors in the values files and the R.java is not generated.
Be sure about that, if any errors on your res file
Clean your project
Restart your ADT
You can update the whole project folder from outside but while doing a commit instead if committing the the whole project folder only update the following from inside the project folder:
src folder (to update the code)
res folder (to update the UIs, XMLs images, etc.)
AndroidManifest.xml if anything added to it.
libs folder if you have add any external libraries and JARs.
clean and/or refresh your project after each update.
Ask your team to follow this approach because folders like gen etc are auto-generated by the SDK.

Imported Android project still refers to external libraries but can't find them

I imported an Android project into Eclipse (Custom ADT). During the import process, I chose to copy project into Workspace.
My project could compile and run well but after sometime, it stopped working. When I check in the 'Problems' View, I see that it still looks for the BIN folder in the folder from which the project was imported and it can't find the library it wants to reference.
Aren't Libraries copied along with the project in Android? How do I fix this?
A good way to add external JARs to your Android project or any Java project is:
Create a folder called libs in your project's root folder - you already had this
Copy your JAR files to the libs folder
Now right click on the Jar file and then select Build Path > Add to Build
Path, which will create a folder called 'Referenced Libraries' within your
project
By doing this, you will not
lose your libraries that are being referenced on your
hard drive whenever you transfer your project to another computer.
You need to place the Libraries into your libs folder before you copy/import. Because if you just added the Library over the Build-path its just copy the Reference, not the Library itself.

Importing the desk-clock android project into eclipse

I copied the code onto my computer via
svn checkout http://desk-clock.googlecode.com/svn/trunk/ desk-clock-read-only
into the folder C:\Programming\desk-clock-read-only
I try to create the project via File/New/Other/Android/Android Project from Existing Source.
I select the C:\Programming\desk-clock-read-only path.
For some reason eclipse only wants to import C:\Programming\desk-clock-read-only\res.
The source files are in C:\Programming\desk-clock-read-only so they don't get imported.
There's just an empty src folder.
What do I have to do to import the project correctly?
I dont't know how the developer of this project managed it to run this but usually the java files belong inside the src folder and the manifest definitely not inside the res folder. If you change this Eclipse(or the IDE of your preference) might recognize it, but you'll maybe get some errors because just putting the java files inside the src folder shouldn't solve it. You actually need a package. Check your manifest for that.

Android Library assets folder doesn't get copied

I am creating an Android library and it has an assets folder with images.
When I use it in another project the assets doesn't get copied.
Anyone else had this issue?
The new Android Build System that is based on Gradle supports asset folders in library projects!
With ANT based builds it's still not possible:
Library projects cannot include raw assets. (See docs)
But you could
copy the assets manually
or even patch the aapt tool (see http://devmaze.wordpress.com/2011/06/26/enabling-assets-in-android-libraries/)
It is possible to put assets into resulting library jar by small fix:
Put "custom_rules.xml" into you library project home (near the build.xml):
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules">
<target name="-post-compile" if="${project.is.library}">
<echo>Post Compile: add assests from ${asset.absolute.dir} to ${out.library.jar.file}</echo>
<jar destfile="${out.library.jar.file}" update="true">
<zipfileset dir="${asset.absolute.dir}" prefix="assets" excludes="**/*.java ${android.package.excludes}"/>
</jar>
</target>
This will pack your library assets into you resulting library jar. As result, these assets will be included into resulting .apk of your application.
Checked on Android SDK Tools Revision 21.1.0 on OSX
From Eclipse and ANT you can reference the same "assets" folder from multiple projects.
This allows your source tree to have a single copy of the assets files, but have them included in multiple APKs.
See Android: targeted res folders for debugging in eclipse
From ProjectA I was able to reference ..\ProjectA\Assets from ProjectB.
On Eclipse (under Windows at least, I've not tried on Linux yet), I had to create a new variable to reference ..\ProjectA and use that variable in "Linked Folder Location". If I attempted to use ".." in "Linked Folder Location" eclipse wouldn't accept it.
For those using IntelliJ IDEA, you can make a change to your application module's packaging settings to include depedent assets. Note, this was done on version 14.0.2 of IntelliJ Community edition. My main application module now inherits files form my library project's assets folder as if they were right in the main project!
Right click application module > Open Module SEttings. Select Android tree node on module > Packaging Tab. Check "Include assets from dependencies into APK"
Note: I've never used Android Studio, but I would guess there is a similar setting for this in that application.
start by creating android lib project, close after creation. this'll prevert autobuild
use cmd terminal on windows android command is batch file
add tools to path
C:\Users\user_bss>PATH=%PATH%;C:\adt-bundle-windows-x86-20140321\sdk\tools
Generate build.xml for ant
android update project -p C:\Users\user_bss\Documents\Workspace\SDKAdvanced -n SDKAdvanced
notepad custom_rules.xml add the code from above don't forget end tag
run "ant debug" or "ant release" to build
you'll see classes.jar in bin dir this is your packed lib

Categories

Resources