I am using the android's sdkmanager commandline tool to update the SDK and I want to add an update site for addons. How can I do that only from commandline. I cannot use UX tool as I am accessing the host via ssh.
You will need to create this a file named repositories.cfg under your ~/.android/ folder.
Paste the following content into the file and modify it as needed.
### User Sources for Android Repository
#Tue Dec 12 15:45:09 PST 2017
disp02=Url1
disp01=Url2
disp00=Url3
count=3
enabled02=true
enabled01=true
enabled00=true
src02=http\://somewhere.com/some-extras-2/SomeArtifact2/some-extra-artifact.xml
src01=http\://somewhere.com/some-extras-1/SomeArtifact1/some-extra-artifact.xml
src00=http\://somewhere.com/some-extras-0/SomeArtifact0/some-extra-artifact.xml
Looks like still nothing better than writing a custom script to achieve these steps:
Download addon.xml
Parse it to get the location of a package archive[1]
Download package and extract to $ANDROID_SDK_HOME/add-ons
Convert addon.xml to package.xml and place it in addon directory in Android SDK
Here is my script to do this https://gist.github.com/CAMOBAP795/b5664b05ce2130de8192516fd4c4b9b0
Prerequisites:
- wget
- libxml2-utils
- xsltproc
[1] During development I observed that there are several XSD schemes, so my script doesn' cover all cases
Related
I'm restoring my Linux partition from backups (mostly non compressed tarballs). I'm facing a problem while extracting a tarball which is backup of synced android repo. I tared my existing repo by simple tar -cf command and i'm extracting it using tar -xf blah.tar. I'm getting the following error.
http://pastebin.com/rkyu9qvD
Dump of tar -tvf blah.tar
http://pastebin.com/WyrwU3v2 (truncated)
I think the problem is symlinks. For example consider failed extraction of
.repo/projects/packages/providers/DownloadProvider.git/info/exclude
If the files are extracted serially as show by -t (correct me if i'm wrong) then first it should extract .repo/projects/packages/providers/DownloadProvider.git/info because it is symlink (Look at dump
lrwxrwxrwx bootmgr/bootmgr 0 2014-03-23 11:02 .repo/projects/packages/providers/DownloadProvider.git/info -> ../../../../project-objects/platform/packages/providers/DownloadProvider.git/info
) I thinks that is why it is getting error while extracting it.
Many other files are extracted wrongly in this way for ex, first it'll create a/b/c.x path to extract c.x but later founds that b is symlink to another directory and then throws error like file already exist
So any ideas how i should extract it or it is impossible.
If it is impossible then any other better way to backup existing Android repo so that i can move it to other HDD.
From the tar documentation:
Normally, when tar archives a symbolic link, it writes a block to the archive naming the target of the link. In that way, the tar archive is a faithful record of the file system contents. When--dereference' (-h') is used with--create' (-c'), tar archives the files symbolic links point to, instead of the links themselves.
So try to archive with tar -chf ... and I guess your issues will be solved.
I'm trying to create an application that combines Osmdroid with Graphhoper to achieve offline routing on a city area. I exported osm file from Open Street Maps and converted that file to pbf. The problem is that an application fails to load the pbf file because Graphhoper trying to parse the pbf file using java.xml.stream which is not available on Android devices. Here is the function that I'm using to load the pbf file.
public void setRouting(){
File dir = new File(Environment.getExternalStorageDirectory(),"osmdroid");
File osmFile=new File(dir,"offline-map.osm.pbf");
if(!osmFile.exists()){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("File doesn't exist").setTitle("Error");
AlertDialog dialog = builder.create();
dialog.show();
return;
}
GraphHopper hopper = new GraphHopper().forMobile();
hopper.setEncodingManager(encodingManager);
hopper.setGraphHopperLocation(getApplicationContext().getFilesDir().getPath());
hopper.setOSMFile(osmFile.getAbsolutePath());
hopper.setCHShortcuts("fastest");
hopper.importOrLoad();
}
I know that it is possible to convert osm to ghz (which works in my case):
https://github.com/graphhopper/graphhopper/blob/0.3/docs/android/index.md
but I can't execute this:
./graphhopper.sh import <your-osm-file>
on windows OS.
I'm not using Maven to include Graphhopper. I inserted jar into libs folder.
How can I import a osm file into my project to achieve offline routing?
I finally managed to resolve this.
This is how I did it:
Download Apache maven
Scroll down to Install instruction - Windows section and follow maven installation steps
Set Enviroment User Variable MAVEN_HOME ie: C:\Program Files\Apache Software Foundation\apache-maven-3.2.1. (important use same value as for M2_HOME)
Clone Graphopper git to your local machine git or download repository as zip and extract it somewhere on your local disk
Download and install Cygwin
Run Cygwin
$ cd /cygdrive/
You are now positioned on root type "ls" to see all drives on computer
Position your self into Graphhopper git root.
ie for c:\git\graphopper:
$ cd c
$ cd git
$ cd graphhoper
see linux navigation tips for how to navigate
10. Copy your filename.osm file to Graphhoper git root
11. $ ./graphhopper.sh import filename.osm
12. You shud have folder filename-gh in your Graphopper git root folder which have all you need.
13. Copy that folder to your mobile device
14. You can now use something like this:
`
File dir = new File(Environment.getExternalStorageDirectory(),"map-parent-folder-name");
File ghDir=new File(dir.getAbsolutePath(),"filename-gh");
hopper = new GraphHopper().forMobile();
hopper.setCHShortcuts("fastest");
hopper.load(ghDir.getAbsolutePath());
to init graphopper
Two more tips. If you don't have Graphopper jar (graphhopper-0.3-SNAPSHOT.jar) you can create one with:
$ ./graphhopper.sh build filename.osm
new jar is located in core/target/ folder
You will need trove-3.0.3.jar which you may download here. Just add trove-3.0.3.jar from the zip into the libs folder of your project
I hope that I didn't forget anything :)
You cannot import the xml/pbf on Android (yet). As you are on windows have a look at the docs how to execute the import via cygwin.
Config Details:
Windows 8 Pro 32bit
adt-bundle-windows-x86-20130717
jdk-6u26-windows-i586 32bit
Directories:
For Java - C:\Program Files\Java\jdk1.6.0_26
For Android Root - Z:\Program Files\Android
For Android SDK - Z:\Program Files\Android\sdk
Environmental Variables:
var_name: JAVA_HOME
var_value: C:\Program Files\Java\jdk1.6.0_26\
var_name: JDK_HOME
var_value: C:\Program Files\Java\jdk1.6.0_26\
var_name: Path
var_value: C:\Program Files\Java\jdk1.6.0_26\bin
Modification:
1)
set java_exe=
"%JAVA_HOME%\bin\java.exe"
if not defined java_exe goto :EOF
2)
for /f %%a in ('"%~dps0\find_java.exe" -s') do set java_exe=%%a
3)
for /f %%a in ('"%~dps0\find_java.exe" -s -w') do set javaw_exe=%%a
First i downloaded adt-bundle then extracted into Android Root directory (i installed java far earlier) then i installed ADT Plugins from https://dl-ssl.google.com/android/eclipse/ and successfully connected Eclipse IDE with Android SDK. Now i am trying to Android SDK Components but when i clicked on Window-> Android SDK Manager in Eclipse a dialogue box opened said SDK Manager will open in a while but it didn't. Whenever i try to open SDK Manager everytime a cmd prompt for a second then disappear and nothing happened while AVD Manager open properly.
Then i went through some solution in several forums and modified some line of code (as of modification 1 in tools\android.bat ; 2 and 3 in tools\lib\find_java.bat)
Now in command line
Z:\Program Files\Android\sdk\tools>android
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
Z:\Program Files\Android\sdk\tools>
As you can see that my attempts are successful and android.bat is executing but the problem is when i try to open SDK Manager directly or via IDE again nothing happened but executing in cmd. I cannot understand what happening actually and i am unable to found anything related with this in any forum. Please Help. Thanks in advance.
In your PATH environmental variable, move *C:\Program Files\Java\jdk1.6.0_26\bin* to the beginning of the collection, and see if that addresses the issue.
Most likely the directory structure of your sdk installation changed. Try running android.bat from the sdk directory
Z:\Program Files\Android\sdk>tools\android.bat
If the sdk Manager opens (close it) and set the work_dir in android.bat to the sdk directory. In android.bat change line
set work_dir="%cd%"
to
set work_dir="Z:\Program Files\Android\sdk"
or to
set work_dir="%~dp0.."
If the above does not work try to get more information what is wrong in calling java, output the java call to the console. In android.bat change line
call %java_exe% .....
to
echo call %java_exe% .....
Good luck
android.bat seems to have a problem running from a samba share mounted on my windows system. This fixes the problem for me.
V:\>android
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
[snip]
V:\>c:
C:\Users\me>android
I had this same problem and I found that none of the "set" commands in beginning of the batch file worked correctly.
prog is set to ~f0.
work_dir is empty
cd /d ~dp0 results in an error "The filename, directory name, or volume label syntax is incorrect."
Android.bat requires command extensions enabled in order to run correctly.
Restore the original batch file and edit this line
from...
setlocal
to...
setlocal enableExtensions
This should set all the environment variables correctly so that they don't need to be hard coded.
You can also enable command extensions in the registry. Reboot after making this change.
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions = 1
I am working off of Jackie Gleason's presentation about getting objective-c to compile on Android as well as Michael f1337's blog post on the same subject (with the addition of working on Mac OS X, which I am). The major difference between their posts and mine is that I am working to use the latest NDK (r8b). I have followed these steps:
1) Download the latest NDK here: http://developer.android.com/tools/sdk/ndk/index.html
2) Create a directory called NDK, and unpack the download here.
3) In the NDK directory, create the folder toolchain-src. cd to this directory.
4) Download the toolchain:
git clone https://android.googlesource.com/toolchain/build.git
git clone https://android.googlesource.com/toolchain/gmp.git
git clone https://android.googlesource.com/toolchain/gdb.git
git clone https://android.googlesource.com/toolchain/mpc.git
git clone https://android.googlesource.com/toolchain/mpfr.git
5) Create the directory binutils. cd to this directory.
6) Download the latest binutils tar ball here: http://ftp.gnu.org/gnu/binutils/
7) Unpack file to current directory.
8) back in the toolchain-src directory, create the directory gcc.
9) Download a gcc that supports objective c (tested with gcc-4.6.1) http://ftp.gnu.org/gnu/gcc/
10) Unpack this file into the gcc folder, then navigate back to the toolchain-src directory
11) cd to the build directory, and edit the Makefile.in file, changing the line:
--with-gnu-as --with-gnu-ld --enable-languages=c,c++
to
--with-gnu-as --with-gnu-ld --enable-languages=c,c++,objc
12) From the gcc directory, Download and install the gcc patch:
curl http://gcc.gnu.org/bugzilla/attachment.cgi?id=24879 > gcc.patch
cd gcc-4.6.1
patch -p1 < ../gcc-4.6.1.patch
13) find this file in the ndk: build/tools/build-mingw64-toolchain.sh. In this file, change the line:
var_append GCC_CONFIGURE_OPTIONS "--enable-languages=c,c++"
to
var_append GCC_CONFIGURE_OPTIONS "--enable-languages=c,c++,objc"
14) Next, find this file in the ndk: build/tools/build-host-gcc.sh. Here, change the line:
ARGS=$ARGS" --enable-languages=c,c++"
to
ARGS=$ARGS" --enable-languages=c,c++,objc"
15) Enter the bash terminal (by typing bash), and enter these lines (replacing <...> with actual paths:
LOC="<path to NDK folder>/android-ndk-r8b/build/tools/build-gcc.sh"
SRC="<path to NDK folder>/toolchain-src"
NDK="<path to NDK folder>/android-ndk-r8b"
TOOL="arm-linux-androideabi-4.6.1"
sh $LOC --gmp-version=4.2.4 --mpfr-version=2.4.1 --mpc-version=0.8.1 --binutils-version=2.23 --try-64 $SRC $NDK $TOOL
This begins to work, but fails with the following message (found in the output config.log file):
build-gcc.sh:1771: error: cannot find install-sh, install.sh, or shtool in "<path to NDK>/android-ndk-r8b/build/tools" "<path to NDK>/android-ndk-r8b/build/tools/.." "<path to NDK>/android-ndk-r8b/build/tools/../.."
Looking at the build-gcc.sh file, it has far less lines than 1771. Further investigation has brought me to believe that this error is occurring in the /toolchain-src/gcc/gcc-4.6.1/configure file, but I do not know what to fix.
Does anyone know how I can fix this? I am not looking for external links, or prebuilt solutions (such as CrystaX' custom ndk-r7), as I have already read and tried a lot.
Strangely, I had to delete my existing NDK and re-unarchive it. After that it worked. I had originally installed the NDK as the first step, however it should be moved to before step 15.
I put in reference this:
http://developer.android.com/guide/google/gcm/demo.html
in Using App Engine for Java number 4
I am supposed to run this on a cmd inside the samples/gcm-demo-appengine directory :ant -Dsdk.dir=/opt/google/appengine-java-sdk runserver -Dserver.host=192.168.1.10
I replace the "192.168.1.10" with "127.0.0.1" which is my locolhost.
after executing this command I got:
BUILD FAILED
C:\Program Files (x86)\Android\android-sdk\extras\google\gcm\samples\gcm-demo-ap
pengine\build.xml:27: Cannot find C:\opt\google\appengine-java-sdk\config\user\a
nt-macros.xml imported from C:\Program Files (x86)\Android\android-sdk\extras\go
ogle\gcm\samples\gcm-demo-appengine\build.xml
can you tell me what the problem?
Go to the following link:
[https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Java]
And download appengine-java-sdk-1.9.3.zip
So than extract it where you want and use the following path for example:
C:\programs\appengine-java-sdk-1.9.3
so you will use :
ant -Dsdk.dir=C:\programs\appengine-java-sdk-1.9.3 runserver -Dserver.host=1.1.1.1
where you have to replace 1.1.1.1 with your server's ip