Develop app specifically for my custom android ROM - android

I have a custom ROM with some modified classes and a few new ones, and I need to develop an app which uses this modified version of the android API. How can i achieve that? In other words, how can i import new classes (and use new methods in the old classes) from the custom ROM in my app development environment (eclipse and android sdk)?

If you're using eclipse, you can achieve that by creating a jar of all the android framework classes, including your new classes, than add it as a library in your project.
The ADT plugin will automatically add it to the "Android Dependencies" which is exported with your APK. But you propbably don't want to include it in your final APK.
So, in your project's properties window, go into "Java Build Path", then select the tab "Order and Export", then uncheck the "Android Dependencies", and check all libraries that you may be using in your app that was in the group and you want exported.

I found 2 options to do this:
-> Find out the jar to substitute in the sdk platform in use, instead of making the jar file myself:
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes.jar
(Did not tested this one, the first worked fine for me)
-> Do the following steps to build the sdk:
1. Use repo init -g all ; repo sync to get some dependencies in the aosp root directory;
2. source build/envsetup.sh;
3. lunch sdk-eng;
4. make sdk A directory will be created somewhere inside "out" directory, with a name like "android-sdk_eng.USERNAME_linux-x86";
5. In Eclipse: Preferences > Android, select SDK Location and point to the new directory created;
You can copy the directory to somewhere else before point eclipse to it.
Some links to the source of that information: here and here

Related

Create STANDALONE Android Studio (1.5) library project

I need to create an Android Library and deliver the final .jar file to the clients.
I am new to Android development (three days). I've been developing iOS for the last 4 years. I went through Google's official documentation and tutorials to get a feel for the platform (I don't want it to be obvious that an iOS guy was writing the library).
I don't have any problems with Java, but I do with Android. I decided to go with Android Studio since it is the official IDE. I am using version 1.5.
PROBLEM:
So as I said, I need to create an Android Library and deliver the .jar file to the clients. I would like this Android Studio project to be a standalone library project with its own unit tests. I don't want to create an unnecessary App project, and then add an Android Library module to it. I want to create a separate App project which will include this .jar file, so I can test it in the way it will reach our clients.
I've seen a lot of options online for how to accomplish this, but all of them seem a bit "hacky" (e.g. rename this folder, change that app-project-setting and make it a library project). Is there no way to create a Library project from a new project wizard in Android Studio?
What are your suggestions on how I should proceed with this? Is there some elegant solution to this without these tricks to re-configure the App project?
EDIT
Here is what the new project wizard looks like:
I select "Add no activity" here
This may not feel comfortable for a person from other platform/IDE/world, but this is The Way. Personally i'm getting annoyed with Xcode every time i use it in the exact same way you're annoyed with AndroidStudio now. But lets get down to business:
Create an empty project and select "Create no activity".
When everything is set, go to "File\New\New Module" and select "Android Library"
Give a name for created library and click "Finish".
(Optional) go to "Run\Edit Configurations" and set everything like below:
Now open the librarie's 'build.gradle' file. Make sure to open the file from exact same folder which is named with your library name, because there are a couple of 'build.gradle' files all over the place. Remove support-library entry from the file:
Write some code and when you're ready to deploy the library set everything like this:
Go to "Build" menu at the top and select "Build APK".
And about unit tests:
**Edit 1: **
If you really want to remove the 'app' folder, than follow instructions on a picture below:
You can create Library Project instead of Normal Project,then your output product will be a jar or aar as you configured.If your library has resources then build it as aar,or it will be jar.
When you created a project as yo are doing,click File->new Module,then will like this:
If your library project have resources or will use API of Android,then choose Android Library,else choose Java Library,Android Library will build aar as product whild Java Library build jar product.

add flurry to android app using Android studio

This is Not a duplicate
I've read each post, and at the flurry site as well...
I have read:
Add the FlurryAnalytics_x.y.z.jar to your classpath
If you're using Eclipse, modify your Java Build Path, and choose Add External JAR.
If you're using the SDK tools directly, drop it into your libs folder and the ant task will pick it up.
I am not using eclipse.
I am not using SDK tools (as best i know).
I AM using android studio...
I am not new to this, but i cant seem to get past the particularities of android studio .. so.
I already have the code added, so i dont need that.
What i need is a step by step on adding the jar file(s), and what "config/build" files that need to be modified....
BWT
if i have a TOP folder MyTestProject, and under that is MyTest, and under that there are build, and source, where Exactly do i put the libs dir ??
In newer versions of Android Studio, the projects it creates will pick up jars that are placed in the "libs" directory in the module. If you want to add it manually, do so through Project Structure > Modules > Dependencies.

Configure eclipse to use my own Android SDK (framework.jar)

I made a custom framework.jar for my device. This new framework include a new API which I'd like to use in my apps. Unfortunately, besides I included my own framework.jar in java build path, eclipse didn't see my new API and throw compiling time errors.
How can I configure eclipse to use my custom framework.jar instead of the jar within android SDK?
[EDIT]
Based in #Yuri 's answer and some other insights, I created a tool (actually it is a shell script) to create a new platform in android SDK and merge jar files into it. It's available in XDA forums to download as well the instructions to use: http://forum.xda-developers.com/showthread.php?t=2619775
To build SDK you should run the following commands:
make update-api
make sdk
Since the API of Android has been modified the command make update-api adds new API. The command make sdk creates SDK in out folder.
Then to start develop your applications in Eclipse using new SDK you should add this new SDK. There are 2 possibilities to do this. The first one is from the book "Embedded Android". I'll just copy it here:
Assuming you had already configured Eclipse for Android development
using the in‐ structions at http://developer.android.com, you’ll need
to carry out two additional steps to use your newly-built SDK. First,
you’ll need to tell Eclipse the location of the new SDK. To do so, go
to Window→Preferences→Android, enter the path to the new SDK in the
”SDK Location” box, and click OK. Also, for reasons that aren’t
entirely clear to the author at the time of this writing, you also
need to go to Window→“Android SDK Man‐ ager”, deselect all the items
that might be selected except the first two under “Tools” and click on
“Install 2 packages...” Once that is done, you’ll be able to create
new projects using the new SDK and access any new APIs you expose in
it. If you don’t do that second step, you’ll be able to create new
Android projects, but none of them will resolve Java libraries
properly and will, therefore, never build.
As for the second here it is:
Find you new build sdk zip (for Linux it cab be found here
out/host/linux-x86/sdk/)
Unzip this pack into a folder
Inside this folder you can find the directory which is called
platforms/android-2.3.3
Rename folder android-2.3.3 to <your_name>
Copy this folder into the following location of the installation of
your SDK Manager: android-sdk-linux/platforms
Find inside this folder file build.prop and assign to the property
ro.build.version.sdk any negative number:
ro.build.version.sdk=-10
Now run SDK Manager and you'll notice that you new sdk is added.
Simply create new Eclipse project and select this sdk as a target.
Try this:
create new floder in your project put floder name="libs"
and include the library here.
And Run the app
I hope it's working
This is a good question! Your tip would be useful for Android Studio users as well, I guess.
Just FYI, for IntelliJ users, you can also do this:
Project Settings > Modules > click Dependencies tab > click "+" button > select "JARs or Directories"
Find the .jar and choose it
Move the .jar on top of the list of Dependencies (even before the SDK)
Change the scope to 'Provided' (not 'Compile')
By step 4, you can avoid making a huge .dex. (Your apk will not include the framework.jar.)

NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager

Platform: MonoDroid v4.2.4
IDE: Visual Studio 2012
Minimum SDK version: API 12
I'm having runtime issues when trying to utilize the LocalBroadcastManager class included in the Android.Support.v4.Content namespace. In my IDE, I've explicitly added the reference and can scope the namespace/class fine, and, after writing some code, compiles as expected. However, upon application deployment and launch, I'm prompted with the error: "NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager"
Here's the code that prompts the runtime error (DSC_Discconected_From_Device is a class that inherits from BroadcastReceiver). It stops execution at the last line.
IntentFilter filter = new IntentFilter(UsbManager.ActionUsbDeviceDetached);
DSC_Disconnected_From_Device Receiver = new DSC_Disconnected_From_Device();
LocalBroadcastManager.GetInstance(this).RegisterReceiver(Receiver, filter);
Under the SDK manager, all the API packages are installed, as well as the "Support Library" package under extras.
Where is it looking for the definition of the class? I've presumably copied the source, LocalBroadcastManager.java, to paths in the android-sdk framework where it "might" be looking. For example: ..\android-sdk\extras\android\support\v4\src\honeycomb\android\support\v4\content\LocalBroadcastManager.java
Ideas?
Edit: Forgot to mention that my project already references the support library, android-support-v4, in the folder "libs", located in the root of my project. I had to create the directory and add it through Visual Studio.
This problem was hounding me for almost six months now and no solution was helping me but today I have managed to find the correct solution on my own.
When you select your project target version to be greater than or equal to Android 4.0, Android SDK includes "android-support-v4.jar" file in your projects "libs" folder. This jar contains all the classes and methods related Android 4.0 or later.
Android is trying to find the class definition which is in "android-support-v4.jar" so that means you have not configured the build path to the "android-support-v4.jar" file. To do this, follow these steps:
Open your project properties
Select "Java Build Path" from left side menu
Select "Libraries" tab
Press "Add External Jar"
(Most important step) Select "android-support-v4" jar file of "libs" folder from your CURRENT PROJECT LOCATION (path should be on your project folder and not the android sdk).
Select "Order and Export" tab and "TICK" the checkbox of "android-support-v4.jar"
That's it, you're done!
I had this error with android facebook integration.The reason was I had android-support-v4.jar library added to my project. Facebook sdk has already support library. So delete support library both from libs and from java build path If you are using a library already has support library in it.
in Android Studio 0.8.2
Press the green "+" in tab Dependencies of Project-Structure, then the keyboard key "1" (for libs) and choose the v4+ lib
If you have proguard enabled, try adding
# Local Broadcast Manager
-keep public class android.support.v4.content.LocalBroadcastManager
This fixed it for me.
You need to add the support library .jar file to the /libs directory in your IDE if it is Eclipse so that when the apk is made the Android packager will include that in your apk.
The problem seems to be related to the "properties" of the android-support-v4.jar library.
By default, the "Build Action" listed in the Advanced Properties in Visual Studio had a value of Content. I switched the value to AndroidJavaLibrary and the runtime error has disappeared.
However, the BroadcastReceiver isn't receiving the USB disconnect intent, hmm... Will update this answer accordingly.
Edit: I could never get a LocalBroadcastReceiver to work, so I had to use a regular one.
Just replace the android-support-v4.jar of your project that is in>libs folder with android-support-v4.jar present in FacebookSDK>libs folder

How to create new android project in eclipse and share in local git repository?

I use the wizard to create a new Android project in Eclipse Juno with Android SDK Tools revision 20.0.3 at build SDK 15 and minimum required SDK 15. The files are generated with sample code for activity, manifest, etc. I have tried different templates (like MasterDetail or BlankActivity with Tabs) in this process and there are sometimes issues such as AndroidManifest.xml or activity_main.xml with repeated XML elements. So I fix these issues manually (which I think is a bug with the wizard).
Now, I want to "team share" the project via EGIT. So I right-click the project and "Team->Share Project->git". At this point, it wants me to choose a repository. I have created a new one outside Eclipse workspace (and re-used it once created). (I also tried creating one in the parent directory (i.e. in workspace despite an Eclipse warning not to do so).
Either way, when the share operation completes, the buildpath for Libraries "Android Dependencies" does not have the "android-support-v4.jar" in the location specified which was in the workspace. It seems that after the egit operation, the project directory appears to have been moved to the repository, but the .classpath file has not changed.
Is this how egit should work (move project workspace inside git repo and tell Eclipse that the project directory is in a new location)? Is the only workaround to fix the buildpath manually?
Is there a different approach to create new android project in Eclipse and then put the relevant files (i.e. exclude generated java files) into a local git repository such that Eclipse EGIT works?
I am answering my own question after some trial and error.
Here are the steps.
Create the android project via the wizard.
Fix any XML errors (as necessary) to get a buildable project.
Right-click project and Team->Share Project->Git
Select the Git Repository (and create if necessary).
At this point, the Android Dependencies (a dynamic classpath container) in the Java Build Path will be wrong because Git has moved the files to the repository.
Close the project (Project->Close Project)
Re-open project (Project->Open Project)
Now, the Android Dependencies are correct because it is dynamic. I don't know the exact mechanism used by Eclipse for dynamic classpath container, but if you read the Android Tools website it will explain the rules used to to populate this container.
Clean the project. (Project->Clean...)
The important thing is not to try to fix these Android Dependencies yourself (like deleting it), because then your Android project may have issues when you start to build the APK.

Categories

Resources