I need to have some files in android assets folder, how can I add them using QtCreator/QMake?
Assuming you have the following structure in your source directory:
foo.pro
extra_data/file1
extra_data/file2
…
Adding the following to foo.pro should deploy the extra_data folder to assets://extra_data (exact path might differ, cannot verify right now) in the APK:
folder_01.source = extra_data
folder_01.target = extra_data
DEPLOYMENTFOLDERS += folder_01
If you are developing the application, then simply copy/paste the files in assets folder.
But if your application is already built and available as .apk file then you cannot modify any of its content.
Copying files to /5.2.0/android_armv7/src/android/java/assets did the trick
Related
I am making an app which use the following java line:
Net dnnNet = Dnn.readNetFromONNX("path\to\file");
As you can see, readNetFromONNX requires path to onnx file.
So I put my onnx file under assest folder, so I can use it at run time.
The problem is I you can only read assets foler with AssestManager and inputstream... the readNetFromONNX needs path...
How do I overcome this probelm? Is there a way to get the path of the file at run time? Maybe other folder?
Thanks from advance
Is it possible to get the config.xml file that is generated by Cordova based applications using Adroguard?
I cannot find it under the /res folder and it is not listed in the output of get_files() method.
apktool, on the other hand, is able to get the config.xml from the apk that is use it on.
Since it is under res folder, You need to get it by unzipping the file to a temporary directory and then parse it using Axml parser. In get_files(), you must see "resources.arsc" file. The res files are part of that. You can do something like :
config_xml_path = os.path.join(<your apk unzipped path>, 'res', 'xml', 'config.xml')
with io.open(config_xml_path, 'rb') as axml_file:
parsed_axml_file = AXMLPrinter(axml_file.read())
axml_content = parsed_axml_file.get_buff().decode('utf-8)
parsed_axml = minidom.parseString(axml_content.encode('utf-8'))
You might get some errors if the config.xml is badly formatted but I am not including the solution to handle those case. I hope you will get an idea with the above example.
I need to work with a file,that should be at data\data\app_name\files\ . That is now an SQL Database, so solution with SQLiteOpenHelper isn't ok for me. Also, I copyied that file to app_name\app\assets in my profect folder - that didn't work.
How to add that file to installation .apk, to put it in data\data\app_name\files during the installation?
Save your file in \res\raw within your project.
Then, you can access that file using:
InputStream databaseInputStream = getResources().openRawResource(R.raw.yourfile);
Make sure that the resource files are included correctly when generating the apk.
I got this in my folders :
But on my android device, i have a file not found error because it looks for andoid_assets instead...
Where can i set my folder path ?
fixed,
do not put underscores as prefix for folder name..
Need to access the asset files from your main root(projectname->www) only on android device need to set the path like file:///android_asset/www/yourfilepath
E.g., file:///android_asset/www/images/xyz.png
Need to use a shared lib for android from 3rd party, the lib's soname and file name are same, in format libxx.so.1.2.3, which is common on linux. I rename the lib file to libxx.so, and link libxx.so in libmyjni.so using ndk-build. In my java code, before calling the functions in libmyjni.so, I load them like this:
System.load("/data/local/tmp/libxx.so.1.2.3");
System.loadLibrary("myjni");
I have to manually copy libxx.so.1.2.3 to /data/local/tmp/. It works well in this way, after above loading, I can call functions in libmyjni.so.
In code "System.loadLibrary("myjni");", system always trying to get libxx.so.1.2.3 from somewhere. I want to know, in the real world, how could I copy libxx.so.1.2.3 to a specific location on android device during installation? so that I can System.load() it.
Or android has official way to install self made lib to /system/lib/?
If libxx.so.1.2.3 is in format libxx.so then I can use System.loadLibrary("xx") to load it.
Here is finally what I did, keep the libxx.so.1.2.3 untouched and do all stuff in Java:
Put libxx.so.1.2.3 in android assets.
In MainApp.OnCreate(), copy the file to private file folder and load it from there:
AssetManager am = applicationContext.getAssets();
in = am.open(OPENSSL_SO_LIB_NAME); // source instream
File privateStorageDir = applicationContext.getFilesDir();
String libPath = privateStorageDir.getAbsolutePath(); // copy the lib to here ...
System.load(libPath + "/" + SO_LIB_NAME);