I have a project setup with 4 modules that flows like this
Module1 -> Module2 -> Module3
Module4
Module1 and Module4 are both entry points in to the app and need to have their own launch icons
Before I split the app in to modules this worked fine but when I split this into modules Modules 1 and 4 are are treated independent and I can either launch one or the other.
This is fine while developing the app but what I want at the end is to generate one APK that contains all modules and create 2 launcher icons when installed, but this isn't happening because it seems to generate 2 APKs
How do I need to organise this to generate one APK?
I figured it out.
It needs a bit more than just setting the intent filter so I thought I would explain it here in case anyone else is trying this.
Module1 is the application module, Module4 needs to be a library with just the bare definition for an activity.
Then in Module1 manifest you need to create an activity alias to Module4
The process is decribed well here..
http://blog.danlew.net/2014/01/16/preserve-your-launchers-use-activity-alias/
Also because of this Module1 now has a dependency on Module4 too
In your Manifest file write this code at both entry point . it will generate two instance . for ex like this
<activity
android:name=".Activity.Your_module1_entry_activity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and for your second module
<activity
android:name=".Activity.your_module2_entry_activity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Related
So, I'm practicing some reverse engineering and now I chose an Android Trojan in order to inspect (Marcher overlay Android trojan from Contagio Mobile malware samples). I've decompiled it using the Apktool and It generated the smali files and everything. The problem is I can't locate the starting point of the application. In the manifest it says:
...
<activity android:label="#string/app_name" android:name="com.paranbijuv.aijuy.bkqbjl.huitou" android:noHistory="true" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
... <!-- no other main/launcher in the xml, only these -->
But there is no "com.paranbijuv.aijuy.bkqbjl.huitou" inside the decompiled sources. Actually there is no "paranbijuv" package at all. To make sure Apktool didn't generate wrong sources I've run a strings command directly into the classes.dex file and also no reference to these classes. My question is how can I reach to the starting point of the app in this case?
Edit: Or, if it is the case of some obfuscation, then the app would have to have a entry point anyway... what sort of obfuscation could cause the entrypoint class to be missing from the classes.dex, if possible?
Search that name in public.xml file and then find it's id and search that in the project.
I have 2 project (A and B) A is the sdk and the other is an application that uses sdk.
I want to join A to B with gradle and i don't know how.
Thanks
you need to show a new MainActivity instance you need to declare an intent-filter in your project B manifest:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="your.package.here.MainActivity" />
<category android:name="android.intent.category.DEFAULT" />
To my Android app project, I added a module which contains an activity named "SampleDataMenuActivity". There is nothing special to this activity - it's added using the "New Module" -> "Android Library" dialog in Android Studio and includes the "Hello World" code generated by Android Studio.
The AndroidManifest.xml of the app includes (from the module):
<activity
android:name="com.sample.sampledata.SampleDataMenuActivity" >
<intent-filter>
<action android:name="android.intent.action.SampleDataMenuActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
In the build.gradle of the app:
dependencies {
(...)
compile project(':sampledata')
}
In the settings.gradle of the project:
include ':sampledata', ':app'
In the main activity of my app, I want to navigate to an activity in the module using:
startActivity(new Intent("com.sample.sampledata.SampleDataMenuActivity"));
The project builds just fine, but when I tap the button that should take me to the activity in the module it fails, reporting:
android.content.ActivityNoFoundException: No Activity found to handle Intent ( act=com.sample.sampledata.SampleDataMenuActivity )
What did I miss?
I found the mistake, and perhaps I should remove the question. But as it was upvoted, somone else might be interested in this answer:
The manifest should state:
<activity
android:name="com.sample.sampledata.SampleDataMenuActivity" >
<intent-filter>
<action android:name="com.sample.sampledata.SampleDataMenuActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I have
Single main project which defines <action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />
Multiple library projects, with some of them defines <action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />
While I'm using Eclipse to build & run single main project with multiple library projects, only 1 app will be installed.
However, if I migrate to Android Studio to build & run single main project with multiple library projects, multiple apps will be installed,
depending on how many projects (regardless main project or library projects) define <action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />
I was wondering, is there any configuration I had done wrong in Android Studio, which causes multiple app to be installed, when I build & run the projects?
Currently, my only workaround is to remove those lines (<action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />) from all library projects' AndroidManifest.xml. Is that common & correct way, to import project libraries in Android Studio? As in Eclipse, those lines don't install extra apps into my device.
This is how my Project Structure looks like
As you can see the first folder icon, looks different than rest of the folder icons. I guess that indicate, the first folder icon is main project, the others are library projects.
If there is only 1 main project, how come there can be multiple apps being installed?
In Eclipse only the AndroidManifest.xml from main app project is used. In Android Studio (and Gradle build system) all the manifests are merged together.
The following lines inside an <activity> element in your manifest indicate that that activity should be shown in the launcher menu. If you do not wish this, remove those lines.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
All of this is intended behavior.
There's another hackish way.
Look up at your merged AndroidManifest.xml. It should be located at:
<your_project>/build/intermediates/manifests/full/<debugOrRelease>/AndroidManifest.xml
Search for the LAUNCHER <activity> tag. In your case you should have more than 1 LAUNCHER <activity> tags. My case looks like this:
<activity
android:name="com.stockhut.SplashScreenActivity"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" >
</action>
<category android:name="android.intent.category.LAUNCHER" >
</category>
</intent-filter>
</activity>
...
<activity
android:name="com.todddavies.components.progressbar.main"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In my case, com.todddavies.components.progressbar.main is a library project with a sample project that has been declared as LAUNCHER. The correct LAUNCHER should be com.stockhut.SplashScreenActivity.
Open AndroidManifest.xml in your main project, add the following:
<activity
android:name="com.todddavies.components.progressbar.main"
android:label="#string/app_name" tools:node="remove" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Take note on the Marker tools:node="remove". According to Android Manifest Merger Documentation:
A marker is a special attribute, in the tools namespace, used to express a specific decision for how to resolve conflicts.
Therefore an <activity> tag with the marker tools:node="remove" will tell Gradle to remove itself when there's a conflict. In other words, we are somehow "forcing a conflict". It is a little hackish, but it works.
You can always verify your merged AndroidManifest.xml in the abovementioned path.
In Android studio their can be only one project at a time that can be added.
If you have library with project then you have to either add whole code inside you project or
you can create jar for your library project and add them into your project.
There is another option of gradle in Android studio.
If we want to use any library in project we can add their dependency in "build.gradle" file of Project.
I am attaching a screen shot of "build.gradle" file please refer to it.
Now , As far as Library Projects are concerned , (if it is not contributing to your project) The Best Approach is that in Android manifest you should set only your defined activity as a launcher activity ,As In Most cases libraries AndroidManifest.xml Often contain some sample Activity (which should be removed), or Activity which you need to subclass , There should be minimal defined things in the library project (negligible) most of the things should be in your Manifest including all permission.
Also it is define on android developer site
"a filter with "android.intent.action.MAIN" and
"android.intent.category.LAUNCHER" settings advertises an activity as
one that initiates an application — that is, as one that should be
displayed in the application launcher. The icon and label set in the
filter are therefore the ones displayed in the launcher."
you can refer the link also...
http://developer.android.com/guide/topics/manifest/manifest-intro.html
How can I update the project name in Eclipse?
I have changed the project name by using "refactor" and "rename", but when I install the .apk in my device, it still shows the old project name.
How can I fix it and what is the problem?
Project name got nothing to application name. And there's no really anything like one application name on Android, but the label of Activity (one or more) user can access from his launcher. This is declared in AndroidManifest with android:label for every Activity with proper intent-filter.
<activity
android:name=".StartActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
See docs.