Objective:
I have an android application (main) from which I want to download (jar, apk, or any sort of package) and load the package dynamically and start the main activity of my loaded package from my main application.
The solutions I have tried:
I have followed this blog post and try to load the app using DexClassLoader https://medium.com/#kalpeshchandora12/dynamic-code-loading-in-android-dea83ba3bc85#:~:text=DCL(Dynamic%20code%20loading)%20allows,location%20and%20executed%20at%20runtime. I am able to follow all the step and able to load the class from the downloaded apk, now I don't know how to call the main activity of the loaded apk.
I have followed this plugin(https://github.com/DroidPluginTeam/DroidPlugin), which is telling me that I can dynamically load the apk from the server, and then I can install it in the background and then can run it by any communication method (broadcasting, AIDL, etc.) but while following the plugin, I have encountered an error (sort of I/O error while opening APK), it's not able to open my apk for installation.
I don't know if whatever I tried is correct or not and I am not an android guy, instead, I am a unity guy and trying to run my games (I have almost 50) within android applications. There is no choice of loading the game statically in the android project because it severely increases the size.
Please recommend me an approach to achieve this task or if anyone can guide me on how to solve the problems that I am facing.
It sounds like you need look at Feature Delivery.
Related
I've been pulling my hair out all day. I'm converting my WPF app to Xamarin.Forms (UWP, IOS and Android). I'm currently focused on UWP and Android (don't have an apple devices yet) and I got a lot of the program running but I ran into a huge snag with reading files that are not in my sandbox directory. Currently, my app allows you to choose a folder with images and you can move through them. To test out the reading functionality, I've placed the images into the "LocalState" directory and bingo, my code is working beautifully. Now the program doesn't have a default folder and when I originally created it in WPF, the user would have a pop up and they would choose their own folder but I cannot for the life of me get a similar function for Xamarin. Every time I try something, I get an "access denied". I've seen Android apps allow you to pick a folder for emulators and I'm 100% sure that you can setup UWP to do permissions with StorageApplicationPermissions but I just cannot get this to work for Xamarin.Forms. Please help me!
OK, Android first it is easier. You need to setup in the manifest permissions to read and write SD-card. On Marshmallow and later you need to ask for the permission at the runtime (you need to do that from the native project).
On UWP the easiest thing to do would be to set the broadfileaccess in the manifest. Other than that you pointed out to the proper APIs, just you need to run them natively.
In general native code is called by using dependency injection. If it gets too complicated you may consider to create Xamarin.Forms project as a shared project where you can use conditional compiling instead of dependency injection which is quite simpler.
I'm using WebDriver.io to create tests.
In the Docs getSource doesn't support native apps.
Get source code of the page. This command won’t work in mobile
environments for native apps. If you are running hybrid tests make
sure that you are in the webview before calling this command.
For now, I use "client.source()" link which return the XML but can take up to 20 sec.
How can I get the layout XML from webDriver.io?
You are doing it the right way. Alternatively you can try the WD.js client and check if performance will be better with than the other one, or simply open an issue report on the WebdriverIO Github page.
The reason of why it may take so long:
UI of the app is constantly updating => Appium is hanging for a bit to retrieve it;
Lots of elements on your app page => leads to a big .xml file.
I am trying to write an app in Android that when requested will download a specific file from DropBox if the file is available.
I have gone through all of the tutorials in the developer section on the DropBox site but I don't think they are really detailed enough as each of the tutorials seem to have bits missing and I haven't been able to get any of them to fully work.
I have tried examples of both uploading/downloading files from the tutorials but each time I get to this part of my code I get Exception errors. This leads me to believe that I have missed something out so I was wondering whether there was a decent tutorial anywhere that properly explains the process of downloading a specific file (rather than bringing up DropBox for the user to select the file) from dropBox so that I can follow it through and hopefully will help me to understand where I am currently going wrong.
I know there are lots of questions similar to this but most of them state that they can get part of the process to work and need help on a particular part but I don't seem to be able to get anything to work other than the actual linking to my DropBox account (I have created a DropBox app and have added the keys etc. to my software).
If anyone can help point me in the direction of a decent tutorial that properly explains this process I would be grateful.
Thanks...
I thought I should expand on my issue which hopefully will help to identify the problem that I am having.
The main tutorial I am using at the moment is: https://www.dropbox.com/developers/core/start/android
I have created an app in the App Console which allows file sharing; this has also given my key and secret code.
I have downloaded and installed the mentioned SDK and have added it to my project; I know this works as without the SDK installed most of the code produces errors.
I have added the beginning part of this tutorial which sets up the authorization to DropBox from my app; this works as when I test it I am taken to a page on my device that requests that I select the correct DropBox account. Up to this part I have no issues with and it all seems to work.
The next part of the tutorial mentions uploading/downloading files and reading the directory structure. I have tested all of these separately but for each one I get an Exception error; the errors seem to mention something called "json" and a class not being found. The tutorial does not mention needing to install another SDK or any other library files so I am unsure whether it is assuming that something has already been done which I have not known about so hasn't been done.
I hope this makes sense and would appreciate any help you can give me...
It looks like the error is related with JSON library you used to connect with Dropbox server. here is the libraries list I used for my application, it works well and can download the file to cache.
dropbox-android-sdk-1.6.1.jar
dropbox-core-sdk-1.7.7.jar
jackson-annotations-2.2.3.jar
jackson-core-2.2.4.jar
jackson-databind-2.2.4.jar
The library jars in the dropbox-java-sdk-1.7.7 package are not enough.
I'm tired to see a lot of Stackoverflow questions about this, even in Google forums or Google official support site, publishing "solutions" that lead to uninstall package through ADB, to do something with the phone rooted, to delete cache of Google Play Services, etc ...
https://code.google.com/p/android/issues/detail?id=64514
https://support.google.com/googleplay/answer/3300875?hl=en
http://gizmostorm.com/how-to-fix-package-file-is-invalid-error-on-google-play-store/
https://www.google.com/search?sourceid=chrome-psyapi2&ion=1&espv=2&ie=UTF-8&q=android%20upgrade%20download%20invalid%20package ...
etc ...
Is there any solution from the package side ?
I mean, I have an app with hundreds of thousands of installs, and unfortunately many users are complaining about this error when upgrading from store my new version.
Obviously, I can not go one by one telling they have to do this or that, because they are not developers, they just want to upgrade and run an app !
Some users are telling me (complaining) this happened since the last "upgrade attempt" of my app, and they are not experiencing this "package file is invalid" with any other app in their phones.
So, I guess it's something I can fix with another upgrade.
Is there ANY SOLUTION that I can do in the next APK compilation, uploading to Google Play Store and fix this without "bothering" my users ?
Thank you in advance
I have also faced same issue in my project as well. I was adding many more features with new jar, git open source library code for Nice UI.
For searching for solution I found play store has issue in one of its updates
http://www.androidcentral.com/google-investigating-package-file-invalid-errors-google-play
But this is totally not relevant to my problem
Again searching I found this
http://birbit.com/how-to-solve-linearalloc-problem/
So the solution looks to be loading a few jar files dynamically using DexClassLoader.
http://android-developers.blogspot.in/2011/07/custom-class-loading-in-dalvik.html
Prepare Interface of the jar file (list of all classes and methods) and have the interface in the app - Need to see how to do this. - We can just have those classes which we need in our app and ignore the rest of the classes. This way we can implement for few existing jars and any new jars that we have to add to make sure we don’t run into this issue again.
Keep the jar in assets folder
Load every class from the jar (based on the list of jars we have in the interface). (The classes will be loaded just once on first launch)
But Based on this, this looks to be involving lot of coding changes and a time consuming things.
Moreover I found that facebook also faced same issue in their initial android app
https://www.facebook.com/notes/facebook-engineering/under-the-hood-dalvik-patch-for-facebook-for-android/10151345597798920
Final Approach I took was removing additional code from jar/git library project which is not require for my application. after that my app got install on 2.3.X with no error.
Hello I am trying to build an app which will hold "other app's"
For example MY app will hold different apps of different ClIENTS.
Now i want to make it so that 1 client has the option to only download his part, BUT he still has to use MY main app. (in other words i don't want to reference to another APK, cause then he can start his app without using mine(i think))
And the download option should be at runtime, cause else he has to download everything in one go.
I have thought about using jar files as library files, but what i found so far is that you have to add them in Eclipse (else they are not found)
I also thought about building the app with the jar files in it, and then leave them out when i compile the app. Then my client can download those files afterwards. But i am guessing that will cause reference errors?
So the questions are;
Is it possible?
How to go about?
The main idea is that i don't want to make one HUGE app where as my client will only use his part of it.
Thanks in advance
It can be achieved in android, and some big platform apps could let the 3rd party developers to develop plugins for them. The main idea is try to create your own DexClassLoader to replace the default one, the custom DexClassLoader could load classes from apkfile.
Try to look through this article for details.
Same with this question.
It seems this is a difficult topic. I can only give you some point.
Since you don't want to make a huge app, then you have to build CLIENTs as separate APKs. But if you don't define CLIENT's activity as MAIN and DEFAULT in manifest, after install CLIENT app, user could not find CLIENT app from system menu (launcher). You can define a private intent name for CLIENT app's activity, this way, only your main app could start CLIENT app's activity.