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.
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
I wrote a script that allows you to read and write to a json file. As long as I tried the script in unity editor, I didn't have any problems. But when I switched to installing the application on an Android device, I can't find my json file.
The json file is called "playerData.json" and has been placed in a folder called "playerData.json".
This is the code for the path of the json file (working on unity but not working on android)
path = Application.streamingAssetsPath + "/playerData.json";
I tried using this string of code to get the code to work on android as well, but there is no way to get it to work.
path = System.IO.Path.Combine(Application.streamingAssetsPath, "/playerData.json");
I only wrote the line concerning the path as my android device cannot find the JSON file. Thanks everyone for the help!
Application.streamingAssetsPath does not work on Android and WebGL
It is not possible to access the StreamingAssets folder on WebGL and Android platforms. No file access is available on WebGL. Android uses a compressed .apk file. These platforms return a URL. Use the UnityWebRequest class to access the Assets.
There is a workaround though as mentioned using UnityWebRequest, can find an example in this Unity Answer
I need to extract the application icon in a APK file.
I'm using aapt to know the icon location inside the APK file.
I'm running aapt dump badging com.example.app.apk:
this command returns me:
(...)
application-icon-120:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-160:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-240:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-320:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-480:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-640:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-65534:'res/drawable-anydpi-v26/ic_launcher.xml'
(...)
but as you can see it returns me the location of an XML file which in some way is encrypted. I know this XML file has the real path for the PNG file icon, but I don't know how can I get that real path (or how can I decrypt the XML and then parse it).
Is there any way to get the real path for an application icon inside a APK file with a XML pointing to other location?
Thanks!
Check out this project,
https://github.com/iBotPeaches/Apktool
It can be used to unarchive an APK, including the assets.
apktool d <your>.apk
try extract your apk file with 7-zip and you will get res foulder
How can I access a text file in my directory 'src/test/resources'
I can't seem to get it to pickup during my JUnit test
mobile/build.gradle:
sourceSets {
test {
java {
srcDirs = [ 'src/test/java' ]
}
resources {
srcDirs = [ 'src/test/resources' ]
}
}
}
Test method:
#Test
public void test_file() {
URL resource = getClass().getResource("file_four_lines.txt");
File file = new File(resource.getFile()); // Get NullPointerException here
...
}
Prefix the file path with /.
Basically, you'd do something like this:
File helloBleprintJson = new File(
getClass().getResource("/helloBlueprint.json").getPath());
Above snippet is taken from here.
I think this link will help. In your case why not hard code strings for testing? Why not use String.xml instead of "file_four_lines.txt". Internationalization requires a directory structure for each resource file having different language, screen size, orientation, flavor, night/day vision version. For this reason resources are compiled and accessed from the R file. You are trying to bypass this convention by using .txt instead of .xml and accessing the resource directly, it just feels wrong. I don't think testing is you problem as much as not following convention.
Forgive me for posting twice, I do have an answer from the official documentation" Arbitrary files to save in their raw form. To open these resources with a raw InputStream, call Resources.openRawResource() with the resource ID, which is R.raw.filename.
However, if you need access to original file names and file hierarchy, you might consider saving some resources in the assets/ directory (instead of res/raw/). Files in assets/ are not given a resource ID, so you can read them only using AssetManager." Json and txt are non-standard(unsupported) so you have to provide your own implementation/parcer to read this type file. Thanks for this post. I knew something about resources but thanks to your prodding now I know even more. To recap The Android resource system keeps track of all non-code assets associated with an application. The Android SDK tools compile your application's resources into the application binary at build time. To use a resource, you must install it correctly in the source tree (inside your project's res/ directory) and build your application. As part of the build process, the SDK tools generate symbols for each resource, which you can use in your application code to access the resources and of course the symbols referred to are in the generated R file
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