How to download google source code for android - android

As you know, there is a list of several hundred projects in https://android.googlesource.com/. I'd like to download them all in windows machine. According to Google's document,
To install, initialize, and configure Repo:
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
To clone the entire platform, install repo, and run:
mkdir mydroid
cd mydroid
repo init -u https://android.googlesource.com/platform/manifest
repo sync
In my machine, however, I cannot "repo init" in Git Bash because it says it does not have python. I have python installed but git bash does not recognize it. Note that I set the python directory to the system path too. If anybody can give a tip, I would appreciate it. Thanks
UPDATE: I believe it's problem with new version of Git Bash for Windows. System path is not applied to Git Bash at all - I could easily test if system path worked with command prompt. Anyway, I tried this instead and it actually ran with error of course.
/c/python27/python.exe ../bin/repo init -u https://android.googlesource.com/platform/manifest
The error message is
$ /c/python27/python.exe ../bin/repo init -u https://android.googlesource.com/platform/manifest
Traceback (most recent call last):
File "../bin/repo", line 91, in <module>
import readline
ImportError: No module named readline
OK. I passed this error by installing pyreadline in windows:
easy_install pyreadline
If you got an error, you must install setuptools from
http://pypi.python.org/pypi/setuptools#files
And finally ran the command again to get this:
$ repo init -u https://android.googlesource.com/platform/manifest
fatal: unable to start d:\mywork\dev\GoogleAndroid\working_dir\.repo\repo/main.py
fatal: [Errno 8] Exec format error

With one click, download the latest code as .tar.gz file, from here
https://android.googlesource.com/platform/frameworks/base/+archive/master.tar.gz, the android could be found under core folder
Edit
Alternative here:
http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/
Just select the version then a download options within.

If you consider, as an example, this other program "sympy" which also needs git bash and python, it is only a matter to add python to your PATH prior to launching the git bash session.
Install Python from:
http://python.org/download/
by downloading the "Python 2.7 Windows installer" (or Python 2.6 or 2.5) and running it.
Add python directory to your system environment path variable
(My Computer -> Advanced -> Environment Variables -> Path -> Edit).
Note that the repo script itself must be in the path, as mentioned in the Version Control page of android:
Repo is a repository management tool that we built on top of Git. Repo unifies the many Git repositories when necessary, does the uploads to our revision control system, and automates parts of the Android development workflow.
Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android.
The repo command is an executable Python script that you can put anywhere in your path.

This answer explains how to fix this error:
fatal: unable to start c:\path\.repo\repo/main.py
fatal: [Errno 8] Exec format error
Summary: I finally used the python packaged by Cygwin.
Details: Below is the full story.
The tip from the repo bug tracking is to add '/c/app/Python27/python ':
line 136 in v1.20
REPO_MAIN = '/c/app/Python27/python ' + S_repo + '/main.py'
line 735 in v1.20 (beginning of function main)
wrapper_path = '/c/app/Python27/python ' + os.path.abspath(__file__)
But we get the error TypeError: coercing to Unicode: need string or buffer, NoneType found
Therefore I reverted these changes above and performed the other changes below (on version 1.20):
line 136, replaced single slash by double back-slash:
REPO_MAIN = S_repo + '\\main.py'
line 766, added python absolute path as first element of me:
me = ['C:\\app\\Python27\\python.exe', repo_main,
'--repo-dir=%s' % rel_repo_dir,
'--wrapper-version=%s' % ver_str,
'--wrapper-path=%s' % wrapper_path,
'--']
line 776, replaced os.execv(repo_main, me) by
os.execv('C:\\app\\Python27\\python.exe', me)
However we get still an error:
$ Traceback (most recent call last):
File "c:\path\.repo\repo\main.py", line 39, in <module>
from subcmds.version import Version
File "c:\path\.repo\repo\subcmds\__init__.py", line 36, in <module>
['%s' % name])
File "c:\path\.repo\repo\subcmds\forall.py", line 17, in <module>
import fcntl
ImportError: No module named fcntl
The Python v2.7 fcntl documentation says fcntl is available for platform Unix only.
I finally reverted again all changes in repo script and installed Cygwin including its python and git packages: it succeeded as a charm.
But, as the symlinks simulated by Cygwin are not recognized by the MSysGit, we have to use the Cygwin git. And GUIs on top of git are not fully compliant with Cygwin git...
(see also my other post)
Edit:
Cygwin can use native NTFS symlinks (just set CYGWIN=winsymlinks:native and be Admin). Therefore MSysGit can be used and any other GUI based on it :-)

Related

Repo with non android projects

I am working on a project where I am trying to unite several modules into one solution. The modules are each in their own folder and are git repositories. These are all stored in C:\sourcecode\Modules Eventually they will be on GitHub. After deep reviews of different methods of using a Solutions made up of Module stored in git repositories, I decided to try Google's Repo that was built for AOSP.
I installed all the tools based on the Repo requirements here https://source.android.com/setup/develop and created a folder C:\sourcecode\Repotest in that folder I created a file called default.xml. The contents of that folder are very simple:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="origin"
fetch="/c/sourcecode/Modules" />
<default revision="master"/>
<project path="AnalystQualification" name="AnalystQualification" />
</manifest>
I launch git-bash as administrator and run:
$ cd /c/sourcecode/Repotest/
$ repo init -u default.xml
I get the output:
$ repo init -u default.xml
Downloading manifest from default.xml
Traceback (most recent call last):
File "C:\sourcecode\Repotest\.repo\repo\main.py", line 630, in <module>
_Main(sys.argv[1:])
File "C:\sourcecode\Repotest\.repo\repo\main.py", line 604, in _Main
result = run()
File "C:\sourcecode\Repotest\.repo\repo\main.py", line 597, in <lambda>
run = lambda: repo._Run(name, gopts, argv) or 0
File "C:\sourcecode\Repotest\.repo\repo\main.py", line 266, in _Run
result = cmd.Execute(copts, cargs)
File "C:\sourcecode\Repotest\.repo\repo\subcmds\init.py", line 531, in Execute
self._SyncManifest(opt)
File "C:\sourcecode\Repotest\.repo\repo\subcmds\init.py", line 232, in _SyncManifest
default_branch = m.ResolveRemoteHead()
File "C:\sourcecode\Repotest\.repo\repo\project.py", line 1926, in ResolveRemoteHead
output = self.bare_git.ls_remote('-q', '--symref', '--exit-code', name, 'HEAD')
File "C:\sourcecode\Repotest\.repo\repo\project.py", line 3040, in runner
raise GitError('%s %s: %s' %
error.GitError: manifests ls-remote: fatal: invalid gitfile format: default.xml
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Downloading Repo source from https://gerrit.googlesource.com/git-repo
I think this error is telling me that setup in default.xml cant see the .git folder in the modules/analystqualification directory but I can see it if I ls -l
$ ls -l /C/sourcecode/Modules/AnalystQualification
total 4
drwxr-xr-x 1 adam.wheeler 1049089 0 Jan 12 10:01 Setup_AQ/
Any help is appreciated here. Thanks!
Adam
repo init -u url_to_manifest_repo -m foo.xml -b manifest_repo_branch
url_to_manifest_repo should be a git repository that tracks foo.xml. It can be either in the local disk or in a remote hosting server. In your case, it's /c/sourcecode/Repotest. Make sure that /c/sourcecode/Repotest is a git repository and default.xml has been trakced.
foo.xml is the manifest file's path relative to url_to_manifest_repo root. -m foo.xml can be omitted. If so, -m default.xml is used by default.
manifest_repo_branch is the branch that holds the specific version of foo.xml. If -b manifest_repo_branch is omitted, it defaults to -b master.
So in your case the command would be:
repo init -u /c/sourcecode/Repotest -m default.xml -b master
or simply:
repo init -u /c/sourcecode/Repotest
For a local repository, it could also be -u file:///c/sourcecode/Repotest.

Cannot Find entry file index.ios.js in any of the project roots ["/Users/neo/newProjects/F2"]

Actual Behavior
Instead of launching, I get a red screen and this error message when launching a react native projects from scratch: Cannot Find entry file index.ios.js in any of the project roots ["/Users/neo/newProjects/F2"]
Expected behavior
Launch of a clean app starter
What I am trying to do
I'm trying to init and run a react-native project from scratch in the android and ios simulator, but I'm getting the following error.
What I have tried
I've tried doing the following:
Install via documentation
Moving through the install steps outlined here several times:
https://facebook.github.io/react-native/docs/getting-started.html
NPM Install
Performing NPM Install from within the project folder
Editing .profiles ( android )
editing the ~.profiles file, to set the android home variable.. this is what it looks like now:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" $
export ANDROID_HOME=${HOME}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools`
Npm start
Running npm start and checking activity on the port, ( was the package manager running )
checking the port for activity
( forget how, verified its available )
Code that worked for someone...
I have also tried running this code in the terminal
react-native bundle \
--entry-file=index.ios.js \
--platform=ios \
--dev=false \
--assets-dest=./production/ios \
--bundle-output=./production/ios/ios.jsbundle
After reviewing this article https://github.com/facebook/react-native/issues/8664
And got this error message:
ENOENT: no such file or directory, open './production/ios/ios.jsbundle'
I noticed this suggestion
rerunning npm install and rnpm link
I tried running rnpm link, but got "no such command found"
after reading this article
Entry file error in react native from packager
In the same article I saw this:
"Figured out that after updating to RN 0.28 my app is spitting this issue due to incompatible dependencies. This is how I solved this problem"
rm -rf node_modules
npm cache clean
Then open package.json except react-native change all package versions to *
Then run
npm update --save
npm update --save-dev
Check package if package.json is updated with version numbers, if not verify from npmjs and update manually
Delete app from the device and try to run again
But I cannot discern what the advisor is doing here... and the logic behind it... if it seems relevant, can someone comment on this?
Terminal Output
I am getting this in the terminal:
Loading dependency graph, done.
error: bundling: Error
at DependencyGraph._getAbsolutePath
(/Users/neo/newProjects/F2/node_modules/react-native/packager/src/node-haste/index.js:272:11)
at DependencyGraph.getDependencies (/Users/neo/newProjects/F2/node_modules/react-native/packager/src/node-haste/index.js:216:26)
at Resolver.getDependencies (/Users/neo/newProjects/F2/node_modules/react-native/packager/src/Resolver/index.js:106:27)
at _resolverPromise.then.resolver (/Users/neo/newProjects/F2/node_modules/react-native/packager/src/Bundler/index.js:561:62)
at process._tickCallback (internal/process/next_tick.js:109:7)
Bundling `index.ios.js` 0.0% (0/1), failed.
Versions
Node v7.9.0
react-native-cli: 2.0.1
react-native: 0.44.0
Homebrew 1.2.0
Just updated xcode
OSX 10.11.6 (15G1004)
What I notice
I notice that it seems to be looking in this file.. ["/Users/neo/newProjects/F2"] whereas in some locations on my machine the files are organized Users/Neo/... ( capital username ) ... and I sense that has something to do with this.
also, on project build it does throw this warning... not sure what it means...
"react-native#0.44.0" has unmet peer dependency "react#16.0.0-alpha.6"
Any suggestions or ideas?
update
tried changing directories out of the users folder and initializing
here is what I got in the stacktrace
2017-05-02 09:25:21.478 xcodebuild[52491:5334564] Error saving log: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory" UserInfo={NSFilePath=/code/F4/ios/build/Logs/Build/B9E13558-CCE5-4451-AC21-7E643189BF7B.xcactivitylog, NSLocalizedDescription=No such file or directory} | User info: {
NSFilePath = "/code/F4/ios/build/Logs/Build/B9E13558-CCE5-4451-AC21-7E643189BF7B.xcactivitylog";
NSLocalizedDescription = "No such file or directory";
}
Installing build/Build/Products/Debug-iphonesimulator/F4.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/F4.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Also, tried installing expo and running from there...
Heres what the terminal shows
Error sourcing shell startup scripts: /Users/neo/.bash_profile: line 2: rbenv: command not found
/Users/neo/.bash_profile: line 4: rbenv: command not found
/Users/neo/.bash_profile: line 5: rbenv: command not found
/Users/neo/.bash_profile: line 7: rbenv: command not found
/Users/neo/.bash_profile: line 9: rbenv: command not found
/bin/bash: shell_session_update: command not found
.
Please run npm install -g exp && exp path``
10:25:22 AM
Starting React Native packager...
10:25:31 AM
Scanning 656 folders for symlinks in /code/my-new-project/node_modules (11ms)
10:25:32 AM
Loading dependency graph.
10:25:32 AM
Running packager on port 19001.
10:25:32 AM
10:25:37 AM
Dependency graph loaded.
10:25:51 AM
Project opened! You can now use the "Send Link" or "Device" buttons to view your project.
10:36:58 AM
Couldn't start project on Android: could not install *smartsocket* listener: Address already in use
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
`

Building webrtc library

I am trying to build webrtc android demo application. I was following README applied by the project. First thing was mentioned about gclient but when i tried to run it "no external or internal command". Then i got this link according to the this link i cloned the depot_tool repository but when at the step when i try to run gclient i got this
So after hours of trying i am not able to run it. if any one has experience with this WebRTC library please provide some help. Any guidance? Any Hlep will be appreciated
I heard few things were changed from svn to GIT. We tried building webRTC to windows7 using visual studio. See if you can use any parts on this.
Get depot_tools software and extract to a location (set this path in environment variable).
cd to depot_tools directory and hit 'gclient' (this should take sometime)
Install python 2.7 and put it path.
create a folder of your choice for webRTC and open command prompt there.
Now hit, gclient config http://webrtc.googlecode.com/svn/trunk
then, gclient sync.
Then set GYP_GENERATORS=msvs environment variable (use ninja if you want that).
Also set msvs_version=2012 (depending on your visual studio version)
now run, gclient runhooks --force
This should generate solutions files for your folder. fireup the libjingle/webrtc.sln files and start building it. I'm not sure if it builds as is. But we had hicupps with that.
See this link on WebRTC native development if you haven't already. From my personal experience building this tricky job initially.
Also note that links might be deprecated as they moved to git, don't know if they are still maintaining it.
How to compile WEBRTC On ubuntu
download script and run:
https://cs.chromium.org/chromium/src/build/install-build-deps.sh
./build/install-build-deps.sh --no-chromeos-fonts
Now download depot tools
$ git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
Put it in Path
$ export PATH=`pwd`/depot_tools:"$PATH"
Define your settings:
export GYP_DEFINES="target_arch=x64 host_arch=x64 build_with_chromium=0 use_openssl=0 use_gtk=0 use_x11=0 include_examples=0 include_tests=1 fastbuild=1 remove_webcore_debug_symbols=1 include_pulse_audio=0 include_internal_video_render=0 clang=1 "
make file to download the source
mkdir webrtc-checkout
cd webrtc-checkout
I chose branch 50 you can change it
gclient config https://chromium.googlesource.com/external/webrtc.git#branch-heads/50 --name=src
gclient sync --force --with_branch_heads
gclient sync --force --with_branch_heads --nohooks
cd src
git checkout branch-heads/50
gclient runhooks
ninja -C ./out/Release
Collect your LIB & Include file to use it in your project
mkdir ../lib/
find ./ -name "*.o" -and -not -name do_not_use -and -not -name protoc -and -not -name genperf -exec ar crs ../lib/libwebrtc.a {} +
mkdir ../include
find ./ -name *.h -exec cp --parents '{}' ../include ';'

repo sync results in "fatal: Not a git repository: 'working_dir/.repo/projects/external/ipsec-tools.git'"

I am trying to download the Android source code and am following the procedure described in https://source.android.com/source/downloading.html, which consists of installing the repo script and then running
$ repo init -u https://android.googlesource.com/platform/manifest
$ repo sync
to get the main branch. I have also tried using the -f -j1 flags to go through errors and use only one core, as was suggested somewhere online. At this point, I think I am very close to getting the entire thing downloaded but it will invariably stop towards the end when working on ipsec-tools. It always gives the following output:
Fetching project platform/external/ipsec-tools
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1 100 1 0 0 3 0 --:--:-- --:--:-- --:--:-- 3
100 1690k 100 1690k 0 0 2307k 0 --:--:-- --:--:-- --:--:-- 2307k
fatal: Not a git repository: '/home/sebastian/WORKING_DIR/.repo/projects/external/ipsec-tools.git'
fatal: Not a git repository: '/home/sebastian/WORKING_DIR/.repo/projects/external/ipsec-tools.git'
fatal: Not a git repository: '/home/sebastian/WORKING_DIR/.repo/projects/external/ipsec-tools.git'
Traceback (most recent call last):
File "/home/sebastian/WORKING_DIR/.repo/repo/main.py", line 500, in <module>
_Main(sys.argv[1:])
File "/home/sebastian/WORKING_DIR/.repo/repo/main.py", line 476, in _Main
result = repo._Run(argv) or 0
File "/home/sebastian/WORKING_DIR/.repo/repo/main.py", line 155, in _Run
result = cmd.Execute(copts, cargs)
File "/home/sebastian/WORKING_DIR/.repo/repo/subcmds/sync.py", line 635, in Execute
fetched = self._Fetch(to_fetch, opt)
File "/home/sebastian/WORKING_DIR/.repo/repo/subcmds/sync.py", line 339, in _Fetch
self._FetchProjectList(**kwargs)
File "/home/sebastian/WORKING_DIR/.repo/repo/subcmds/sync.py", line 234, in _FetchProjectList
success = self._FetchHelper(opt, project, *args, **kwargs)
File "/home/sebastian/WORKING_DIR/.repo/repo/subcmds/sync.py", line 275, in _FetchHelper
no_tags=opt.no_tags, archive=self.manifest.IsArchive)
File "/home/sebastian/WORKING_DIR/.repo/repo/project.py", line 1110, in Sync_NetworkHalf
no_tags=no_tags)):
File "/home/sebastian/WORKING_DIR/.repo/repo/project.py", line 1845, in _RemoteFetch
self.bare_git.pack_refs('--all', '--prune')
File "/home/sebastian/WORKING_DIR/.repo/repo/project.py", line 2483, in runner
p.stderr))
error.GitError: platform/external/ipsec-tools pack-refs: fatal: Not a git repository: '/home/sebastian/WORKING_DIR/.repo/projects/external/ipsec-tools.git'
Since it says it is not a git repository, I just went on a hunch and ran git init on the directory it indicated, which didn't work. I also tried deleting the entire ipsec-tools.git directory and running repo sync again so that it would start from scratch but it always gives the same error.
Any ideas?
Its not necessary to start sync from scratch. Android is a huge repository to download from scratch and in interest of saving time and internet one can remove specific git repository (generally I have seen only 1 git directory being corrupt) and re-run the sync.
repo stores projects in
.repo/projects
but these are only soft links to actual git data, which is stored in
.repo/project-objects
follow the links in 'projects' and remove both the repositories and run sync again.
It worked for me.
Sample for platform/frameworks/support:
rm -fr .repo/projects/frameworks/support.git/ .repo/project-objects/platform/frameworks/support.git/
Sync only this project:
repo sync -j4 platform/frameworks/support
[I wanted to add this as comment, but its not allowing me - so added as answer]
I had a similar problem, where the repo command would exit with the same error.
I made a temporary folder, did a
repo init
then did
repo sync -j4 [PROJECT NAME]
where PROJECT NAME was the git which was getting corrupted. I then copied the .git directory from .repo/projects folder to the main directories' .repo/projects and again ran repo sync to finish it.
Shorter answer: Remove the offending repositories/data:
rm -Rf platform/external/ipsec-tools # from current path
rm -Rf .repo/projects/platform/external/ipsec-tools.git # soft links
rm -Rf .repo/project-objects/platform/external/ipsec-tools.git # actual git data
Better sync only the offending one:
repo sync platform/external/ipsec-tools
That worked for me for lineageos.

Invalid syntax zipfile(apkAbsPath) in line 202 ninjadroid.py

I cloned ninjadroid from https://github.com/rovellipaolo/NinjaDroid recently and followed the instructions for decompiling apk files. As instructed I have installed android sdk and python, but when I tried running the command in my command prompt (python ninjadroid.py -t myPackage.apk), it throws the below error
File "ninjadroid.py", line 202
with ZipFile(apkAbsPath) as z:
Mmm... that's strange.
Is 'myPackage.apk' an existing file (in your computer)? Is it a real APK package? From the error, I would say you are trying to reverse a non-APK file.
Unfortunately the "is-APK" check in the current, available version is a lazy check - done pretty badly. I completely reimplemented it in the new version I am working on.
UPDATE
With the newest NinjaDroid version (i.e. 2.0):
$ python ninjadroid.py this_is_a_non_existing_file
>> NinjaDroid: [ERROR] The target file (i.e. 'this_is_a_non_existing_file') must be an existing, readable file!
$ touch this_is_an_existing_file_but_not_an_apk_package.txt
$ python ninjadroid.py this_is_an_existing_file_but_not_an_apk_package.txt
>> NinjaDroid: [ERROR] The target file (i.e. 'this_is_an_existing_file_but_not_an_apk_package.txt') must be an APK package!
$ python ninjadroid.py test/data/Example.apk
{
"app_name": "Example",
...
}

Categories

Resources