Interface files missing from downloaded SDK source code - android

I try to step in the sdk source as depth as possible.
Let's say I step into my sdk source, ~/Android/Sdk/sources/android-24/android/app/ApplicationPackageManager.java:
import android.content.pm.IPackageManager;
But no such file IPackageManager.java inside pm directory:
[xiaobai#localhost pm]$ pwd
/home/xiaobai/Android/Sdk/sources/android-24/android/content/pm
[xiaobai#localhost pm]$ ls I*
InstrumentationInfo.java IntentFilterVerificationInfo.java
[xiaobai#localhost pm]$
Why is it not there? Am I misunderstanding something?

IPackageManager is an aidl file. It appears aidl files are not included when you download the source code package via the SDK tools.
You can browse the online repository to find it though: IPackageManager.aidl.
You can view the file content in a browser.

Related

How to add android "SDK Update Site" via command line

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

how do I change directory in ruboto running on android

I'm using ruboto (ruby) on an android tablet. I'd like my source to be in a subdirectory of the usual default source directory. Is there a way to do this?
You have not stated your motivation for placing the Ruby source in a subdirectory, so I'll speculate that it is for tidiness in a polyglot environment. Also, I'll assume you want all the Ruby source in the same directory, including source for Activity classes.
Adding your path to both the Ruby $LOAD_PATH and the Android component search path has been combined into one method in org.ruboto.JRubyAdapter.addLoadPath. In JRubyAdapter.setUpJRuby, you can find a call to addLoadPath around line 289: https://github.com/ruboto/ruboto/blob/1.4.0/assets/src/org/ruboto/JRubyAdapter.java#L289
You can add your own call below the existing one:
addLoadPath("file:" + apkName + "!/<your_path_here>")
That will add the path to the Ruby load path and the Android component search path.
If you have a clear use case, I would submit it to the Ruboto tracker at https://github.com/ruboto/ruboto/issues . It sounds like something more Ruboto developers could use.

QPython - Reading a file

I have installed QPython in my Android mobile.
I written a statement in the QEdit to read a text file from the below path
/storage/emulated/0/com.hipipal.qpyplus/script3/File1.txt
I used the below statement
fob=open('/storage/emulated/0/com.hipipal.qpyplus/script3/File1.txt','r')
fob.read()
If I run the statement, it is throwing error as:
IOError:[Errno 2] No such file or directory: '/storage/emulated/0/com.hipipal.qpyplus/script3/File1.txt'
1|uo_a116#cancro:/ $
Is the above statement correct?
fob=open('File1.txt','r')
Is not working in version 1.0.4.
fout=open('File2.txt','w')
Was working on version 0.9.6, but is not working in 1.0.4.
The "error" is Read only file system.
It looks like restrictions in the (new 1.0.4) file system library. I post a mail to the editor, but no answer at this time.
For testing, try to write absolute path to your files pointing, for example, to sdcard (/sdcard/out.txt).
I had problems on this versions (>=1.0.4) because launch process of script changes and execution directory is not the same as script directory.
I had to change my scripts to point to absolute paths.
It was tested with qpython developer.
Check this link:
https://github.com/qpython-android/qpython.org/issues/48
You can also try as simple as:
fob=open('File1.txt','r')
fob.read()
Just if the script is in the same folder of the file.
You can change the current working directory to path with script before read file:
import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))

Graphhopper on Android offline routing pbf file error

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.

Compiling Android NDK with Objective-C-enabled gcc errors

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.

Categories

Resources