I'm stucked on a weird problem.
I have a xml config file in my project to which I added two values. This XML file is stored in .\assets\internal\ which refers to data\data\<Application ID>\files . This file is, as all my other project's files, stated as "Always Replaced" (seen from Project, Deployment).
The thing is when I upgrade a previous version of the app not containing these two new values to the new app, the XML file is not upgraded to the one in the new APK, and leads to bugs in my app.
I've seen some other people with this problem but I get other errors.
Android Asset file not upgraded on app upgrade
I get File not found error by trying to open SharedActivityContext()->getAssets()->open('config.xml'); though the file is stored in .\assets\internal\... (accessed by IOUtils::TPath::GetDocumentsPath() + PathDelim + "config.xml" in my code).
I get all the same errors by storing the file in .\assets\, which stores it in the external storage + I don't find a way to get a path from TPath to this external storage so I have to write the path in my code.
That said, I have no errors when I fresh install my app by deleting the previous version, but I can't do that to all my devices.
How can I upgrade an asset file (EDIT : with c++ Builder) ? Or should I store it in res\raw to get it upgraded at every app upgrade ?
Related
I have a JSON file db_seed.json that I want to use as a seed to pre-populate local database in my Android application. This JSON file is dynamically generated from another data source and quite big in size, so I don't want to include this in version control.
However, each time I build the application, I want to make sure that the build process check the existence of this file in the assets folder and shout a build error if it's not (to make sure that I don't publish an incomplete APK). Is it possible to configure Gradle in Android Studio to do this?
try this
if (!file('./app/assets/db_seed.json').exists()) {
logger.log(LogLevel.ERROR, "file not foun")
throw new GradleException("file not found")
}
I am trying to link to an external file from a shared repository between my iOS and Android apps. This does not present a problem for iOS, but it does for Android. My current solution is to create a copy of the file from the external repository and place it in my projects Assets folder. This solution works, but is not much of a good one in my opinion and involves too many extra steps.
Using Eclipse, I am able to link to a resource. It's as simple as copying a file into my Assets folder and being prompted to either copy the file or link to the resource. If I link to the resource and try to run my app, I get a FileNotFoundException. If I copy the file instead, the app file is found just fine.
Ideally, I'd like to link to the file so that when I pull a new update from git then I don't need to copy the file over every single time. I'd prefer to link to the file.
I don't know what Eclipse uses "under the covers" for "Link here" drag-and-drop stuff. However, it is an Eclipse-ism. Android's build tools are fairly isolated from Eclipse proper, and so they won't know about those links.
Using a hardlink, or perhaps a symlink, at the OS X filesystem level should work, as both Eclipse and Android's build tools should treat it like a local file.
After creating a new application with android studio.
I see a manifest file in MyApplication/app/src/main/AndroidManifest.xml.
I changed the version code and version name in this file and tried to display them dynamically. However they were still displaying 1, and 1.0.
I looked into the hardisk and Saw a folder in the path:
C:...\MyApplication\app\build\intermediates\manifests\debug\AndroidManifest.xml
using an external editor I changed the values in this file However still getting version 1 on my logs.
Where can I find this Manifest folder/file through android studio?
The version code and version name are generally set in your application module's build.gradle file. If there are values there, they override what's in your manifest file.
The file you found in an "intermediates" folder is part of the build process, and if you modify it directly, your changes will quickly be lost when that file is rebuilt.
I am building an android app using FlashBuilder and is using a sqlite database, and the initial database shall be packaged into the apk (Android package). When the app runs firstly, the packaged database should be copied to "applicationDirectory".
However, problem comes.
I can use File.applicationStorageDirectory.resolvePath("xx.db") for the destination when using File.copyTo() function. However, how about the file to be copied (from the apk package)?
Can you be more specific about the problem. Is it that you are getting an IOError when you try to copy a file(db) from the application directory to the app-storage directory? Have you checked the contents of the packaged apk? Why dont you consider creating the db in the app-storage directory when the application starts because that application directory is quite protective of its content.
What are you trying to achieve really?
P.S. Keep in mind that the Application directory is read only. So your code cannot write files that reside on that directory.
is it possible to add to my apk file some XML file storing program version, update path and other useful data (note: I don't mean Android XML file). All I want to is this file to be unpacked somewhere to local data folder and I will use it for comparing version info installed locally and on the server in case of updates.
I am asking - is it possible to add to apk some other file?
Thanks
The assets/ folder in apk is intended to store any extra user files in any formats. They will be included to apk automatically on compilation stage and can be accessed from the app using getAssets() function. For example:
final InputStream is = getResources().getAssets().open("some_file.xml")
It is even unnecessary to copy them to some local folder to read them.
If you only want to know the version info of the app then there is a much easier way to identify it. You can use
getPackageManager().getPackageInfo(getPackageName(),PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionCode
to get the version code and
getPackageManager().getPackageInfo(getPackageName(),PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionName
to get app's version name