Android Internal API with Android Studio - Android Software/Hacking General [Developers Only]

Hi everyone!
I'm looking for help how to get Android Studio working with Androids Internal API.
There is a very good tutorial HERE that shows how to set everything up in Eclipse,
but since Eclipse is now deprecated and Google will be dropping support for ADT plugin
the logical move is to set everything up with Android Studio.
The things I did are pulling the boot.oat file from stock Nexus 5X, and use the standard procedure to get framework.jar and framework-classes2.jar.
After getting the internal packages out of the framework, I modified the android.jar file by adding all the missing packages.
The problem is even though all references, classes, interfaces and resources are there and the code doesn't give errors or warnings
that classes could not be found, the build still fails with messages like these:
Code:
error: package com.android.internal.R does not exist
com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
...
cannot find symbol
mLocales = LocalePicker.constructAdapter(this);
...
Basicly, anything related to the internal API gives an error only when compiling.
My next idea is to build all the internal classes as a library and add it to the project where I need it,
but I wanted to ask does anyone else have any better ideas or suggestions?
I've done my googling but I haven't found anything recent and related to AS, only Eclipse.

Related

Recompile and overwrite applications in system/app

As an experiment I am trying to rebuild some standard android applications and replace them in system/app on the G1. I have been through all the steps to get the source code and build for the dream platform and have built the various .apk files of interest (e.g. AlarmClock.apk, Browser.apk etc)
To put the files on the device I delete the old .apk and .odex files and copy my newly built .apk file on to the device. However when I try to run the application it crashes with the following message.
The application Alarm Clock (process com.android.alarmclock) has stopped unexpectedly. Please try again.
I know that replacing the applications like this is possible, because the AutoRotating Browser build works fine when copies over in this manner.
I'm using JF1.31 (RC8)
My initial reaction was that I was not signing the applications properly but having read some posts I think the default built .apk should have the right key already in it.
Another theory I have is that perhaps the applications from the head of the source tree are not compatible with the RC8 (or RC30) Android OS releases. Can anyone tell me how to get the source tree which corresponds to this baseline, I've done some reading around but cannot figure it out. I presume I need to do a repo init -u git://android.git.kernel.org/platofrm/manifest.git -b BASELINE but I can't figure out what BASELINE should be.
Many thanks in advance for any help you can give me!!!
There are some branches in android sources:
master
cupcake
release-1.0
Apps from the first two will not run on default G1, you need to reinstall a whole system. I think by default, following google docs you'll get master. So you need to download a release-1.0 sources.
I may be wrong, but that is what I'm see from my experience.
Thanks for that, I'll get the 1.0 branch downloaded and have a go with that.
Cheers for your help!
I was also trying to recompile some of the built-in apps, specifically the browser, but I can't even get it to build. I get a bunch of import errors, stating that it can't find some of the android libraries, such as android.net.http.AndroidHttpClient, android.os.AsyncTask, etc. I've got the android.jar from the SDK in my build path, and it finds some of them, such as android.webkit.URLUtil.
Can anyone shed some light on what I need to do to get it to see the missing libraries? Thanks.
UndeadCretin said:
Thanks for that, I'll get the 1.0 branch downloaded and have a go with that.
Cheers for your help!
Click to expand...
Click to collapse
There are around a dozen build breaks in release-1.0... all of them are due to missing header #includes in various .c and .h files. So, when it doesn't work, don't give up. Fix the breaks and everything will build properly.
Are you resigning the .apk files? Cuz you have to do that for them to work correctly.
Koush said:
There are around a dozen build breaks in release-1.0... all of them are due to missing header #includes in various .c and .h files. So, when it doesn't work, don't give up. Fix the breaks and everything will build properly.
Click to expand...
Click to collapse
Yep I fixed these problems but I have now hit upon the following problem:
(unknown): error 17: Field android.hardware.SensorManager.LIGHT_NO_MOON has changed value from 0.0010f to 0.001f
******************************
You have tried to change the API from what has been previously released in
an SDK. Please fix the errors listed above.
******************************
I've been in and modified SensorManager back to 0.0010f and that let me build get further but I hit the same error again later in the build.
Given that release-1.0 should be a stable branch is it normal to get all these build issues?
Managed to fix the java issue by modifying public_api.xml. Then hit several more C++ problems which I fixed and finally I can build the lot!
Just tried building the AlarmClock application and running on the G1 and it works fine. Thanks everyone for your help!
>Managed to fix the java issue by modifying public_api.xml. Then hit several more C++ problems which I fixed and finally I can build the lot!
Can you write, what did you fix?
^ Agreed, let us know which files need modifying and what needs doing, i've been trying to get my release-1.0 build root working too!
Alternatively, UndeadCretin, could you build the firmware (release-1.0) with a modified framework-res i can send you?
Ok, I managed to compile it without any editing of xml.
Just added stdlib, string, vector headers to dozen of cpp/h.
worry said:
>Managed to fix the java issue by modifying public_api.xml. Then hit several more C++ problems which I fixed and finally I can build the lot!
Can you write, what did you fix?
Click to expand...
Click to collapse
To fix the java issue, I modified frameworks/base/core/java/android/hardware/SensorManager to change the LIGHT_NO_MOON value to 0.0010f (from 0.001f) and in out/target/common/obj/PACKAGING I modified the <field name="LIGHT_NO_MOON" to have value-"0.0010f">
After this there were several other c++ files which were missing relevant includes. I'm afraid I didn't keep a note of these so cannot provide much detail but mostly they were missing one of the following
#include "stdlib.h"
#include "string.h"
#include "stdio.h"
I think one file needed the following include
#include <string>
and there were a couple of other files that needed other includes. The best way to find these is to google for the function name that isn't building and you should be able to find the appropriate include (that's how I did it).
Hope that helps a bit!
were you able to repo sync after adding the local_manifest.xml?
ximonx said:
were you able to repo sync after adding the local_manifest.xml?
Click to expand...
Click to collapse
I did try that previously but it didn't work. I don't think the relevant files for the dream build are available in the release-1.0 branch. This wasn't a problem for me since I'm only interested in building the applications which work fine with the generic build.
I would like to do the same for the mms application. Could you give me the steps or a link how to do it? I mean do I need the whole sources from android platform to do it? How can I just compile one application?
Phlogiston said:
I would like to do the same for the mms application. Could you give me the steps or a link how to do it? I mean do I need the whole sources from android platform to do it? How can I just compile one application?
Click to expand...
Click to collapse
I downloaded the whole Android source (the release-1.0 branch) and compiled the lot. It may be possible to just build the individual application but I do not know how. It is not vital to build for the dream platform if you only care about the applications since they will work fine with the generic build.
So the basic steps to start are:
Get yourself a Linux or Mac OS platform (I use Ubuntu running in VMWare on my XP box).
Follow the instructions here: http://source.android.com/download but when you come to repo init add the flag -b release-1.0
Fix various build problems
When recompiling individual apps to replace system apps is there a way of just building a single application or does the entire thing need making?
ximonx said:
When recompiling individual apps to replace system apps is there a way of just building a single application or does the entire thing need making?
Click to expand...
Click to collapse
My experience is that you have to do the whole thing if you are building from source. There is one way I know of to get around this, which is to use baksmali and smali.
Just to be clear, making the entire thing = build from source root?
ximonx said:
Just to be clear, making the entire thing = build from source root?
Click to expand...
Click to collapse
If you are asking me--yes, that's what I mean. Make sure to build for dream-open as the target (it's generic by default).

Question about building Android 1.5 source for emulator

I just had a quick question, haven't been able to find any answers elsewhere. Figured I'd ask it here. I Was wondering if it's possible to build the Android source so that the resulting Android Emulator disk images contains all of the apps of a normal Android 1.5 system?
I've tried building the source twice now but, the disk images are just the normal emulator disk images (missing most of the default apps & some of the graphical improvements of the 1.5 update). I feel like it must be some sort of setting in the makefile to say what platform to build for.
Any help would be greatly appreciated.
Do I need to follow the instructions listed here? Will this enable the build process to build the emulator disk images so that they mimic the G1 completely (including all default Android apps, etc) ?
http://source.android.com/documentation/building-for-dream
Those apps you are referring to are closed source and no matter how you build it, they won't show up in the emulator. You could possibly install them after the fact, but that is truely hit or miss.

Android Native Linux compiling

I'm not sure if this is the right forum, but XDA is really the only place I can figure to ask.
I've been looking for a way to compile linux applications to run on the command line, for instance nano or lynx. I've found the "agcc hello.c -o hello
" method, but the builds I'm trying for are defendant on ./configure.
I've got a working toolchain, and can even compile android itself, and I've got agcc working. I just can't figure out how to get them all working together.
Any help?
In the ./configure, you need to point it to your compiler (i.e. "agcc").
Try "./configure --help" to see the options it is looking for to make this configuration.
I think you have to set up an arm-eabi cross compiler.
You can try the android native development kit:
http://developer.android.com/sdk/ndk/1.5_r1/index.html
I think this is designed to make native components for the normal dalvik android apps, but it may have useful information.
maxisma said:
I think you have to set up an arm-eabi cross compiler.
Click to expand...
Click to collapse
He did.... agcc is a script that runs it.
RoboPhred said:
You can try the android native development kit:
http://developer.android.com/sdk/ndk/1.5_r1/index.html
I think this is designed to make native components for the normal dalvik android apps, but it may have useful information.
Click to expand...
Click to collapse
NDK creates libraries that can be called from within native apps (i.e. shared objects). It does not create native executables.
This should help?
http://forum.xda-developers.com/showthread.php?t=431329
I've made a wee bit of progress.
My current set up is this:
Step 1: Download this
Step 2: Push it to /system/sd/usr
Step 3: Remount system AND root partitions, then symlink /system/sd/usr to /usr. Then, mkdir /tmp.
Step 4: Push sources to /system/sd. Change working directory to your extracted source file, then run ./configure --host=armv6l-unknown-linux-gnueabi --with-build-cc=/bin/gcc
Step 5: ????
Step 6: Profit
I'm still working out the bugs here, and I'll report back when I've got something working. Currently, I'm trying to compile GNU Make for Android.
check the apps section i think i rememeber somone already compiling nano for android...
i wanted to compile sshfs but then again there is a lot of things i wanna do... LOL

[Q] modifying AOSP Calendar issue

Hi, so I'm a student learning Android app development and trying to modify the AOSP calendar to fit my needs so I downloaded the source code from git and made a project with 2.2 FroYo as the basis through Eclipse with ADT and all but I ran into a problem. So I run into:
android.provider.Calendar cannot be resolved into a variable
I did some research and found that the SDK apparently does not have the calendar code nor the database which is why I am running into these issues. So I learned from here jimblackler[dot]net/blog/?p=151 all that. He does have a solution except I have no idea what he is saying. He posted a bunch of code but I have no idea where that code is supposed to go in and I dont understand what he is trying to do with "content://calendar/calendars"
So I just decided to ignore the errors and obviously I couldn't compile it through eclipse so I made an unsigned apk and tried to install it unto the Emulator via ADB but as an unsigned apk it would not let me install it I tried to sign it by going through google's developer site but I am at lost again. I'm a noob to these things unfortunately..
I was wondering if anybody could help me out and point me in a good direction, I would be eternally grateful. Thanks.
P.S. sorry if I was being vague about the google's developer site and source code site but as a newbie I can't post links properly

Build Android 11 from source

Hi, I'm trying to build Android 11. When I run the command
repo sync
I obtai the error
fatal: remove-project element specifies non-existent project: platform/prebuilts/gcc/darwin-x86/mips/mips64el-linux-android-4.9
What it means? How can I resolve it?
Many thanks
Check this report from GitHub. It doesn't look like a big deal. Maybe missing resources/files that you probably don't need if you are building an OS for a phone.
I see they simple removed a line from local_manifests/untracked.xml of which contains the error.
Hi, many thanks for your reply. I have removed more than 10 lines from the xml files.
Is it a normal behaviour? Why the files are not correct?
denisgottardello said:
Hi, many thanks for your reply. I have removed more than 10 lines from the xml files.
Is it a normal behaviour? Why the files are not correct?
Click to expand...
Click to collapse
I didn't find a direct answer. But I've searched the errors, and found that your error on the OP has a darwin-x86 on it.
So I did Google that, and found that it is an Operating System that has something to do with Mac OS, released in 2000, still active.
So as the errors of other builders. I noticed that they're building an OS for mobile phones, which does not include, for an example, darwin-x86. So I asked myself .. What's the point of including an arch that you won't need?
I think when you're building the OS, you do export the arch you're targeting, right? So did it include darwin-x86?

Categories

Resources