what files to share android app sourcecode - android

What is the best way to share android app with friend like i send him the whole project files or should i delete some files like cache or gen folder or something.
i just started in android development and i want the right way to share app without having problems on the other side.
also i sow some files in the project like android private library and bin folder should i share them to or is there files i need to delete before that ?

To share the app just for running - share the apk file.
To share the app for development purposes ( sharing the source code ), share the folders
src
res
lib ( If you've added some external dependencies )
assets ( If you've added something extra there )
And following files
AndroidManifest.xml
project.properties
You can safely ignore following
bin
gen
and others, as these are automatically generated.

You can delete the gen and bin directorys, when we complie or build the project, files in the two directory will recreate.

You can upload code you wanted to share in www.github.com, it also provides private mode, where you can choose members who have access to your repository
If your don't want to share the code, then you can share only .apk file of bin folder

Related

Android how to extract *.so file during execution

I have one android myLibrary.jar file. But myLibrary.jar file will load the native 3 different so file. I have a.so, b.so and c.so.
When i using in my own application, it just simply put the jar file to the Android Dependencies and all 3 so files put in the libs/armeabi of the main application package.
When deploy and install on the device, these so file will be in the data/data/my-appname/lib/*.so.
Now i need to provide the sdk solution. The user side doesn't want the main application. They just want the myLibrary.jar. So i am considering about packing all 3 *.so files to the jar. I searched for the how to add to the so files to myLibrary.jar. But i still don't understand.
In this following post:
[Ant]How to add .so file into a jar and use it within jar(set the java.library.path)?
It mentioned about adding the so file to the jar and extract at runtime. But i still don't understand how to achieve that.
After trying that mentioned in the following post:
Creating a product SDK: How do I add a native lib (.so) and a jar with the SDK I am creating?
After my sample application reference the the compiled jar that included the .so file. After installing to the device, the libs/armeabi/xxx is not unpacked on the install. So i would like to know how to extract them dynamically and save them to data/data/my-appname/lib/ so that i can use with System.loadlibary(.so).
Thanks a lot.

No "libs" directory found after reversing the android app using apktool?

I reversed an app (my own dummy app) using apktool.
>apktool d testing.apk
The last line of output in the terminal says "I: Copying assets and libs..." but there is no "libs" directory in the generated folder.
Am I missing something here ?
I want to know which 3rd party libraries are being used. This can be found from "libs" directory but I am not getting this directory. Any help is highly appreciated. Thank you.
You don't need apktool to get the libs. An APK is just a ZIP. Just unzip testing.apk and look for a lib/ directory.
If it's not there, it may not use shared libraries. Or, they may be downloaded at runtime. To check, install and run the app such that you're sure it's used functions from the shared library. Then, pull the files off the device with:
adb pull /data/data/<package name>/lib

Android - Secure place to store sensitive files inside the same project

Let's say I have an Android Project set up and a git repository for it. Where can I put my keystore (and other sensitive files) inside my project so I can be guaranteed that it will not end up inside the .apk when I export the app (but will be inside the git repository)?
For instance, I can't put sensitive files inside the assets folder because that will end up inside the .apk.
Is there a place to store these kind of files in the Android file hierarchy I am missing?
Don't put your keystore anywhere in your source control or project folder even if you have .gitignored it. It is a personal document, to be treated as you would your SSH keys.
It is better to keep it in an external location, such as your documents folder or personal keystore folder, which you manage yourself. As you have mentioned, these don't need to end up in the APK so they are purely supporting documents and files.
Is there a place to store these kind of files in the Android file hierarchy I am missing?
Put them in the project root. The only file from the project root that is incorporated directly into the APK is AndroidManifest.xml, and even that is moving with the new build system and project directory structure.
Or, create some other directory that does not collide with any existing directories and will not be used by Android, like _stuff/.
Or, have your project itself be in a subdirectory, putting other related files in a peer directory.
Also, make sure you set up your .gitignore properly such that files only go into the Git repo that you actually want in the Git repo.

how to reference an asset in a library project

In a class belonging to a Library project I call:
webview.loadUrl("file:///android_asset/info.html", null);
Unfortunately, this only works if I duplicate the file info.html into the Application's project asset folder as well.
Is there a way to tell an Android library code: "look for this file in the library's assets folder, not in the application's assets folder" ?
This answer is out of date, the gradle build system and AAR files support assets.
From the Android Docs:
Library projects cannot include raw assets
The tools do not support the use of raw asset files (saved in the assets/ directory) in a library project. Any asset resources used by an application must be stored in the assets/ directory of the application project itself. However, resource files saved in the res/ directory are supported.
If you want to include files from a Library project, you'll need to put it in the resources instead of the assets. If you're trying to load HTML files from your library project into a WebView, this means that you'll have to go a more roundabout method than the usual asset URL. Instead you'll have to read the resource data and use something like loadData.
This is now possible using the Gradle build system.
Testing with Android Studio 0.5.0 and v0.9 of the Android Gradle plugin, I've found that files such as
MyLibProject/src/main/assets/test.html
are correctly packaged in the final application and can be accessed at runtime via the expected URL:
file:///android_asset/test.html
You can achieve this by creating a symbolic link in the project's asset folder that points to the directory in the library project.
Then you can access as below:
webview.loadUrl("file:///android_asset/folder_in_a_libary_project/info.html", null);
Okay. Ive been stressing out and losing sleep about this for a while. Im the type of person that loves API creation, and HATES complicated integration.
There arent many solutions around on the internet, so im quite proud of what Ive discovered with a bit of Eclipse Hackery.
It turns out that when you put a file in the Android Lib's /assets folder. The target apk will capture this and place it on the root of the APK archive. Thus, making general access fail.
This can be resolved by simply creating a Raw Java Library, and placing all assets in there, ie (JAVALIB)/assets/fileX.txt.
You can in turn then include this as a Java Build Path Folder Source in
Project > Properties > Java Build Path > Source > Link Source.
Link Source
Click on Variables. and Add New Variable, ie VAR_NAME_X. location : ../../(relative_path_to_assets_project)
Click Ok
Now, when you build and run your app, the assets folder in the APK will contain your (GLOBAL Library) files as you intended.
No need to reconfigure android internals or nothing. Its all capable within a few clicks of Eclipse.
I confirm that Daniel Grant's approach works for at least the following situation: target project does NOT have an asset folder (or the folder is empty, so you can safely delete it).
I did not setup any variable.
Simply setup a LinkSource as follows (just an example)
Linked folder location: /home/matthew/workspace_moonblink/assetsForAdvocacy/assets
Folder name : assets
The "assetsForAdvocacy" is a Java project, (created with New- Project - Java Project) with empty src folder, and a new folder named "assets", which now provides the entire assets folder for the target project.
This is a fairly straightforward way within Eclipse to provide assets re-use across many different projects IF they do not already have assets, good enough to get going with. I would probably want to enhance it to become a content provider in the long run, but that is a lot more development.
My project accesses the assets with the following code:
String advocacyFolderInAssets = "no_smoking/"; //a folder underneath assets/
String fn =advocacyFolderInAssets+imageFilename;
Bitmap pristineBitmapForAdvocacy = getBitmapFromAsset(context, fn);
I use Motodev Studio 3.1.0 on Ubuntu. It would not let me 'merge' a new assets folder in the new assets-only project onto an existing assets folder in the target project.
If you want to use a setup where multiple derivate products are created from one library you might consider using svn:externals or similar solution in your SCM system. This will also do the trick that static assets like online help may be versioned seperately from the android source code.
I found this older question, it might help you, too.
This is the official way Google uses to archive this (from the above post): Link

Accessing a resource in Android project for a Titanium Module

I am developing an application for Titanium, and therefore building a module from an Android application. But a module for Titanium generates a project in Android which has no autogenerated R file.
I need to load a bitmap image but as I dont have the R file so I cant access to my resources by the id. I have thought about accessing to this bitmap by path..But also struggling to do that, as I have read about something like in the Android .apk doesnt have folders...Dont really understand it to be honest.
Can I have a folder in my Android project and access to files on it with some path like #folder/resource/item.png? Then store it in an InputStream for example.
Thanks a lot.
David.
We just recently added support in git (our master branch) for bundling a "res" folder with your Titanium module. If you grab a new build, you should be able to put your "res" folder under "platform" in your module, and it everything there will be automatically bundled in your app.
To access the resources under Res (since the R.java is generated for the app and not the module), we have a helper class called TiRHelper that gives you access to any resource in your module like so:
int xyz = TiRHelper.getApplicationResource("id.xyz")

Categories

Resources