Android Tablets Forum banner

A Guide to Setting Up ADB & Building Android with Fedora KDE

5K views 8 replies 3 participants last post by  3ndymion 
#1 · (Edited by Moderator)
Hello all. I have written a guide to setting up & using Android ADB, & building Android, with Fedora KDE. Almost every guide that I've ever seen for setting up ADB, & a build environment for building Android, is always written for Ubuntu, & ONLY Ubuntu. But I choose to work with Fedora KDE. Why Fedora with KDE??? Because I hate Ubuntu. !!!HATE!!! I also can't stand gnome 3.X. I'm sure I'm not the only one who feels this way, so that's why I'm writing this guide. I've tried different linux distros, & I've found Fedora to be the best of all. It is my favorite now. They also seem to be one of the few distros that stays on top of the linux kernel updates. As of 03/15/13, they're already on kernel 3.8.2!!! Other distros stay way behind. Also, with KDE, you can keep the "windoze" traditional desktop look & feel, especially when you use the "folder view" activity. It's great!!! Well, let's get started.


!!!WARNING!!! Before anything else, I will mention this right now. The Dolphin file manager can destroy your Android build with hidden ".directory" files. Please keep this in mind. I will explain this at the end of the guide.

INSTALL JDK6
-I guess I'll mention this 1st, since this can actually be one of the most painful & confusing parts of all. You'll need to install the java jdk6. As far as I know, Android stuff won't work with the newer jdk7. You can find it on oracle's page here:
http://www.oracle.co...oads/index.html

-Scroll down & you'll see it. Get the "rpm.bin" version. If your working with 64bit, it should look like this:
jdk-6u43-linux-x64-rpm.bin



-Someone by the name of JR already made a very good guide on how to do this. It is what I followed, & you should too. You can find it here:
http://www.if-not-tr...s-red-hat-rhel/
NOTE: When following this guide, be sure to go through only steps 3a & 4a when you reach them. Steps 3b & 4b are for the "non-jdk" jre.

NOTE: The "alternatives" listed in step 4 seems to be some kind of program that creates symlinks for whatever you want, & labels them. When you install, or create the symlinks, you can then use "alternatives" to switch back & forth between the different programs that you make the symlinks for. For example, you can make links for java in jdk6 & jdk7, & then switch to either one or the other, as you please. That way, you can have them both installed, while using only one at a time. You can type "alternatives --config java" to switch, or whatever name you used for the link. For help, type "alternatives --help".

INSTALL SDK
-You can follow these:
http://developer.and.../sdk/index.html
http://fedoraproject...oid_Development

SETTING UP ADB
-Download the sdk & unpack it somewhere in your home directory. For example, I like to put mine in "~/Android-Development/sdk" (the ~ symbol is short for your Home folder).



-cd to your sdk tools location. For example, from my Home folder, I would type this:
$ cd Android-Development/sdk/tools



-NOTE: DON'T TYPE THE DOLLAR SIGN!!! I put it there because that's what you see in the terminal. It's only there for reference.

-NOTE: At any time, you can type "ls", or "ls -l" to see everything in the folder you're currently in.

-Now, execute the android program.
$ ./android

-Install Android SDK Tools & Platform-tools.



-Install 32bit packages. Since Android is a 32bit OS, you must install the 32bit packages regardless if whether your computer is 64bit or not.
$ sudo yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686

NOTE: In order to install packages with yum, you must do it as su. You can either type sudo before the command, or you can just type "su" & enter your password to become superuser. If you're new to the command line, it's probably better to use "sudo" instead, that way you won't stay logged in as superuser & potentially mess things up.

-Now, it's time to install the udev rules. Basically, they are the rules that govern whatever device you plug in with USB. You can find all the info on this page:
http://developer.and...ols/device.html

-Create an empty file named 51-android.rules to write in. We will create it in /etc/udev/rules.d/
$ sudo touch /etc/udev/rules.d/51-android.rules

NOTE: "Touch" is a linux command that you can use to create a new, empty file. To see more info on it, type "touch --help", or "man touch" to see the manual page for it. Of course, you can always google it, & anything else as well. Google "linux commands touch".

NOTE: Since this file is in the root user's directories, you will need to enter commands as superuser, or else it won't save. Either type "sudo" before the command, or, if you're comfortable with the command line, log in as superuser by typing "su" & entering your password.

-Now, you can use any text editor to write inside that file you just created. I like to use nano from the command line, so let's use that. ("nano --help", "man nano", google "linux commands nano")
$ sudo nano /etc/udev/rules.d/51-android.rules

NOTE: In linux, you can copy & paste without even "right-clicking" & selecting copy or paste from the menu. Instead, you can just highlight some text, & go somewhere else & press the mouse middle button to paste it. Highlighting text will automatically copy it, & pressing the mouse middle button will automatically paste whatever you highlighted. No need for "right-clicking" anything. You can do this for the next step.

-Now, from the webpage listed above, just copy & paste the lines with the USB Vendor IDs that you want to use. For example, for Asus, HTC, & Samsung, write these:
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="plugdev"



-Save & exit the file.

NOTE: In nano, you can always see important commands at the bottom of the screen. For example, to exit, you hold in the "control" button & press "x".

-Now, check the permissions of the file & make sure everyone can read it.
$ ls -l /etc/udev/rules.d/

-You should see something like this:
$ -rw-r--r--. 1 root root 639 Feb 5 14:08 51-android.rules



NOTE: The 1st line indicates whether it's a directory or not. The next 3 lines indicate Read, Write, & eXecute permissions for the user. The next 3 lines indicate Read, Write, & eXecute permissions for the group. The last 3 lines indicate Read, Write, & eXecute permissions for others. The 1st "root" means that root is the user. Root owns that file. The 2nd "root" means that the file belongs to the group root.

-If for some reason you don't see the "r" letters (meaning that it's readable) to the left of the file name, then just change the permissions. Add "read" permissions for all.
$ sudo chmod a+r /etc/udev/rules.d/51-android.rules

-Finally, if you didn't do it earlier, now's a good time to do this. Make sure the ADB folders are in your global PATH. This is so that you can use the ADB commands anywhere in the system, no matter what folder you're currently in.

-Return to your home folder.
$ cd

NOTE: In the linux command line, simply typing "cd" & pressing enter will bring you right back to your Home folder.

-There's a hidden file called ".bash_profile" in your home folder. You can see it if you LIST ALL:
$ ls -a

-Your global PATH is defined in there. Let's edit it to add the ADB folders.
$ nano .bash_profile

-You'll see that there's already one line in there with 2 entries that look like this:
PATH=$PATH:$HOME/.local/bin:$HOME/bin

You can use that as your example as to what the format should look like. The line begins with
PATH=$PATH:
Then there are 2 entries, with each entry separated by a colon. Each entry must be separated by a colon and NO space.
$HOME/.local/bin
is one entry, &
$HOME/bin
is the other entry. Now, we want to add our 2 ADB folders to the list. You can either add each path to your folder separated by a colon & no space, like the example, or you can start your own line. I always like to start my own line underneath that one. So, for example, here's what my new line looks like:
PATH=$PATH:$HOME/Android-Development/sdk/platform-tools:$HOME/Android-Development/sdk/tools



-Everyone likes to use different folder names. Remember to use the proper path of where you put your folders in.

-Save & exit the file. That's it. Now, reboot your computer, plug in your android device, & test it out. You should be able to type "adb devices" from any folder, & the computer should be able to see it now.

 
See less See more
11
#2 · (Edited by Moderator)
INITIALIZING YOUR BUILD ENVIRONMENT
-For me, this was the hardest part of the whole process, as there wasn't a lot of help on how to do this for Fedora with KDE. Whatever few guides for Fedora I found out there were usually missing something here & there. My goal is to change that & help everyone. I've gone through this multiple times now, including multiple reinstalls of Fedora 18 from scratch.

-You'll need to install lots of drivers & libraries.

NOTE: Use Apper, the software management program, to look up drivers & libs. Apper will show you many different files that have the name that you typed in, whereas yum won't. Personally, I like to look things up with Apper so I can get lots of hits, & then actually download them by typing them in manually with yum. Yum shows you what it's actually doing behind the scenes while it's downloading things, whereas Apper doesn't. If yum gets stuck & hangs, you can actually see what's going on, whereas Apper won't show you anything & will just leave you wondering what's going on.

NOTE: I have found it to be a good idea to always look for the development (-devel) version of anything that you have to install. Not everything has a development version, but some do. For example, if you look up "flex" in Apper, you'll see that there's also a "flex-devel". Be sure to download them both.



-Here is what I went by:
http://fedoraproject...oid_Development
http://source.androi...itializing.html
http://wiki.cyanogen...org/w/Main_Page
http://wiki.cyanogen...uild_for_maguro

-I used the lists on the fedora page, & I also used the lists of required packages for Ubuntu 10.04 & 12.04. I chose to try a build for Samsung Galaxy Nexus, since that's what I have. While going through the Ubuntu lists, you must keep in mind that some of these packages don't exist for Fedora, & many others do exist with slightly different names. It is best to spend some time & look them up 1 at a time using Apper. For example, typing "libxml2-utils" into Apper shows nothing, but typing in "libxml2" shows results. Finally, whatever you still can't find, you must google search it. For example, google search = "fedora libxml2-utils" You'll get clues & answers from what other people have already found about them. I mainly used the Ubuntu lists of necessary libs to download. So, without further ado, here's everything that I did that works for me...

$ sudo yum install git gnupg gnupg2 flex flex-devel bison bison-devel gperf gcc gcc-c++ make automake kernel-devel zip curl zlib zlib-devel glibc glibc-devel ncurses ncurses-devel xulrunner xulrunner-devel libX11 libX11-common libX11-devel xorg-x11-proto-devel readline readline-devel mesa-libGL mesa-libGL-devel mesa-libGLU
NOTE: You won't need mingw32 & tofrodos.
$ sudo yum install python-markdown libxml2 libxml2-devel libxslt libxslt-devel perl perl-devel perl-Switch SDL SDL-devel wxGTK wxGTK-devel squashfs-tools pngcrush schedtool

NOTE: If you installed Fedora with the options for development programs, than some of these will be installed already. This list may be a slight bit of overkill, but I purposely wrote down everything anyway, so that way nobody misses anything. I went through hell when figuring this out, so it's better to be safe than sorry.

NOTE: If you've been doing everything logged in as superuser, be sure to exit su when you're not installing things anymore. If you create directories as root user, you won't have permissions to access them under your own name, unless you manually change the permissions. Other permissions issues can arise too.

-After all this, it's just a matter of installing the directories & repo, & following the remaining directions on the CyanogenMod Wiki build guide page. I wanted to sync up with the Jellybean branch, so as an example, I set my directories up like this:
mkdir Android-Development/Builds/bin
mkdir Android-Development/Builds/CM10.1_Jellybean



-Whenever I download the repo command, I do it like this:
curl https://dl-ssl.googl...e/git-repo/repo > ~/Android-Development/Builds/bin/repo

-You'll need to add this to your global PATH as well, so be sure to do that, then log out & back in again, or reboot to make it active. Do that, & then continue.

-Then, I go inside the CM10.1_Jellybean folder to do the repo init. (Get ready for repo sync. That takes hours!!!)

-That's pretty much it. : ) Be sure to read through the sites & all their instructions & guides to help you understand everything.

!!!WARNING!!! Here is what I mentioned all the way at the beginning. Please don't forget the most important thing of all: those damn hidden ".directory" files. Any time you change the folder views in Dolphin File Manager, it places a hidden ".directory" file in that folder. THESE HIDDEN FILES WILL DESTROY YOUR BUILD!!! I went through hell with this, trying to figure out what was going on. I always set up the Android folders to show in "details" view mode, so that they're easier to see. Every time I tried to build, it would build for 5 or 10 minutes, & then fail, citing errors in java. I eventually realized that the ".directory" files were the cause of all the problems.



If you change the folder views, you need to get rid of those hidden ".directory" files. You'll have to do it in terminal. A good way to do it is by using the "find" command to find them all, & then pipe the output of that into the "rm" command to remove (delete) them all. ("find --help", "man find", google "linux commands find")

The "find" command can find whatever you're looking for in the current directory, & in all of its sub-directories as well. With the "rm" command, you can also use the "v" option. "V" stands for "verbose". It will show you everything that is being done, as it's being done. As an example, here's how I do it on my computer:
$ cd ~/Android-Development/Builds/CM10.1_Jellybean
$ find -name .directory -exec rm -v '{}' \;



That will find all of the ".directory" files & delete them all. It works pretty fast too. With the "v" option, it will show you what's going, while it's happening, as well. So, if you're like me & think that it's much easier to see huge lists of folders in "details" view mode, feel free to set it for the current directory & all sub-directories as well. However, DON'T FORGET TO DELETE all of the ".directory" files before you start building, or your build WILL FAIL!!!

Well, as you can see, you can customize some things to your liking. There's plenty of learning involved, so be ready to spend lots of time with everything. Good luck, & have fun!!!
 
#3 ·
Now, I'd like to add a personal note. When I last left off here, I was wanting to port CyanogenMod onto the Ainol tab, even though it's been done, because I wanted to learn how to do it. Specifically, my main goal was to build a properly working ClockworkMod recovery for it, & seeing as how building CyanogenMod from source also builds ClockworkMod recovery from source, that's what I chose to do. Unfortunately, the build never worked. I soon discovered that I had to build a device tree from scratch. That came as a nasty surprise to me, as the CM Wiki doesn't really make much mention of that. I started looking around for others, & I tried digging into a lot of code myself, & I soon found myself completely lost in a sea of xml & java that I didn't understand at all. That's when I realized how much I don't know. It's also when I quickly realized the good advice of cyanogen himself...

http://forum.xda-dev...ad.php?t=667298

"... Here's my advice for those looking to make their own Android ROMs.. Stop. Write an app or two first, learn how the system works from a developer standpoint. Learn some Java. ..."

His advice is dead on accurate. Now I know why he says the things he said. I have no previous experience with java, or any other programming language. In trying to do these things, I found myself completely lost in code that I didn't understand at all. How can I possibly mess around with entire ROMs when I don't even know what's going on under the hood???

Since then, I've been concentrating all of my spare time learning java. It's a bit overwhelming to say the least, but I am getting it now. Recently, I took a peek back at all the code that confused me before, & I'm actually starting to understand it all now. I'm no longer lost. Studying java (& xml) is actually working, & quite well too. I can personally confirm cyanogen's advice to be spot on, & well worth listening to.

So, in conclusion, if you're wanting to get into messing around with ROMs & stuff, but you have no programming experience, I think it would be best to take cyanogen's advice & start at the higher levels first. Learn java (& xml), & learn to build a simple app or two for Android. You'll better learn how the system works that way. That's what I'm doing now, & it's really working for me. It's also great for me because I also want to make games, & this is exactly what I need. So doing this should help you out with ROMs, & app develpment too. Well, I hope this is helpful to everybody looking to get into all this stuff. Good luck, & have fun!!!
 
#4 ·
"... Here's my advice for those looking to make their own Android ROMs.. Stop. Write an app or two first, learn how the system works from a developer standpoint. Learn some Java. ..."

His advice is dead on accurate. Now I know why he says the things he said. I have no previous experience with java, or any other programming language. In trying to do these things, I found myself completely lost in code that I didn't understand at all. How can I possibly mess around with entire ROMs when I don't even know what's going on under the hood???

Since then, I've been concentrating all of my spare time learning java.

Good luck, & have fun!!!
Wise words my friend... one "bad thing" is that when you really get into the programming you may easily find
lot of more interesting things that you can develop instead of that rom of yours...
 
#5 ·
Great guide, I feel like this should be in the FW Development section so it doesn't get lost in the main section or pinned here as an alternative.
 
#8 ·
I don't know, I guess if it was me I would re-post it in that section and delete this thread if that is possible to do yourself. If it's not then I'd message the mods and let them know that the thread was moved to the relevant section and request that they delete this one in the main thread. Or if you don't want to go through all that you could just leave it here
 
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top