I need to include 2 Android projects extending Application class as library project in my project. Android manifest allows to make only 1 android:name= in manifest file.
Please advice me the best practice to get it done.
Looking forward for tips & Suggestions.
rohit
So finally I got it work. What I did is let the android:name= as it is in Application of AndroidManifest.xml and in the other application, i used getApplication() of Activity
http://developer.android.com/reference/android/app/Activity.html#getApplication()
Related
Good afternoon, I'm new to app development and I would like to see if there is someone who can give me like a tip or advice on this particular problem.
Basically this apk is going to use features from another apk and I think I understand how it's integrated inside the code, for example:
<application
android:theme="#ref/0x7f14024a"
android:label="#ref/0x7f13003b"
android:icon="#ref/0x7f0f0000"
android:name="com.example.appname.BaseApplication"
<activity
android:name="com.example.appname.activities.SplashActivity"
android:exported="true">
but my question is how do I include the actual app or anything necessary to use the features of this other app inside mine since it seems I have not included the app in the libraries or the project, but how do you achieve that? and "#ref/0x7f13003b" the part 0x7f13003b refers to a file in the libraries?
Thank you in advance.
I have a simple calculator app. It's a complete application all by itself.
I also have a more advanced calculator app that's based on the first app, but has more features. Its main Activity extends the first app's main Activity. The advanced app references quite a lot of resources and methods from the simpler app.
Getting the advanced app to build under Android Studio has been a nightmare. I've been googling and trying things blindly in the build.gradle files, but not making much progress. At first, the problem was dependent features configured but no package id was set (whatever that means, Google turned up no documentation.)
I got past that by tweaking the build.gradle files, and now I'm getting Manifest merger failed with multiple errors, see logs, but I can't find the relevant logs. It looks like the build failed because Android Studio tried to merge the AndroidManifest.xml files from the simple app and the advanced app, but I just wanted to use the manifest from the advanced app.
This is all very frustrating because I made it all work under Eclipse but now I have to move to Android Studio.
I guess my first question is: How can I tell Android Studio to just use the Android Manifest from the current project and not try to merge from the other project.
In general: can an application project serve as a library for another project, and if so how? Are there any examples?
Third question: where can I find good documentation on build.gradle?
I could attach my current build.gradle files and AndroidManifest.xml files if people need to see them, but I'm really hoping to learn enough that I can help myself.
Confirm the problem first:
Switch the same model in Library / application
Application ID androidmanifest conflict problem
if this is the problem, the official documents can see the channel packaging
https://developer.android.google.cn/studio/build
And I wrote you a little demo
https://github.com/yuanweiwork/lytools
I hope it can help you
I have a project with a product flavor that uses a different activity than the main code. I had to define that new activity in a second Manifest file, but I still want to use the original main Manifest as well. But with 2 Manifests with 2
application tags, I get 2 instances of the app installed on the device. Is there a way I can make this work, or will I just have to copy/paste the whole original Manifest and take out the link to it?
I would refactor to an Android library, where all common stuff is located inclusively the manifest. And an app that includes this library as dependency with its own manifest. When building the app the manifest merger should pick up the manifest from the library and merge it with the manifest of the app.
The library could also implement both flavors.
I am new to android...and i am trying to build an application that doesn't have AndroidManifest.xml but does contains files like .sh,.bat,.exe,etc. Along with folders ant-lib and lib containing .jar files...
Please help me as to how should i build such an android project from scratch
Please help
Obvious question: Why do you want to create an app without an AndroidManifest.xml? It's like creating a Java application without a main-method.
Maybe it helps if you give more details on what you're trying to do. For example, why do you want to include .bat and .exe files in your application? Remember that Android is based on a Linux plattform so I'm not really sure what you're trying to do here..
If you're new to Android do the following:
Read the application fundamentals: http://developer.android.com/guide/topics/fundamentals.html
Create a Hello World app: http://developer.android.com/guide/tutorials/hello-world.html
Browse the API Demos application and learn from the code: http://developer.android.com/resources/samples/ApiDemos/index.html
Having an Android app without a manifest.xml file is totally nonsense. This is how Android works. It needs the manifest to be able to understand what kind of permission your app has, what kind of Activities (UI) it provides etc... You basically cannot have an application without an manifest file.
What you want is a library not an application. As all application in android must have manifest.xml but libraries dont. The DataExtractionOSM in that project is a library just like any java library.
Check out the following Create library for Android development?
I want to have a normal class file in my android package that is not a component but will be used by an activity. Is this allowed? How do I add this in the manifest if required?
Right now it is not part of my manifest and I am getting an 'INSTALL_PARSE_FAILED_MANIFEST_MALFORMED' error in my Android project and don't know if it's because of this generic class file.
Thanks
Is this allowed?
Yes.
How do I add this in the manifest if required?
You don't put it in the manifest.
It's not needed to add to the manifest. You can have as many "normal classes" as you wish (by normal i suppose that are classes that do not extend activity).
Take a lot at LogCat during install to check what the problem is.