Issue with white labelling the F-Droid client
- Device OS and version: Android 6.0
- Device model/manufacturer: Huawei P8
- F-Droid version (in the About screen): Fork from master (1.0-alpha3-31-g3dd54ac)
- F-Droid privileged extension version (if installed): n/a
What did you do? (clear steps if possible)
We have a proof of concept project on F-Droid to manage our own repository and support a client that may wish to white-label the F-Droid app. So we followed the steps from the Whitelabel Builds documentation.
We added a "productFlavors" section to the app/build.xml and after that it was not possible to view the About Screen (see exception below).
See: https://github.com/jembi/fdroidclient/pull/1
Steps to reproduce:
- Add productFlavors to app/build.xml (see documentation or snippet below)
- Uninstall any existing version of the F-Droid app on your device/emulator
- Launch the app
- Go to settings
- Click "About F-Droid"
What did you expect to see?
The default F-Droid About Screen should be displayed
What did you see instead?
The app crashed. We saw the following exception:
10-02 11:14:03.103 28846-28846/org.jembi.appstore E/ACRA: ACRA caught a ActivityNotFoundException for org.jembi.appstore
android.content.ActivityNotFoundException: Unable to find explicit activity class {org.fdroid.fdroid/org.fdroid.fdroid.AboutActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
at android.app.Activity.startActivityForResult(Activity.java:4030)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
at android.app.Activity.startActivityForResult(Activity.java:3984)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
at android.app.Activity.startActivity(Activity.java:4314)
at android.app.Activity.startActivity(Activity.java:4282)
at android.preference.Preference.performClick(Preference.java:1012)
at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:227)
at android.widget.AdapterView.performItemClick(AdapterView.java:314)
at android.widget.AbsListView.performItemClick(AbsListView.java:1162)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3075)
at android.widget.AbsListView$3.run(AbsListView.java:3940)
at android.os.Handler.handleCallback(Handler.java:743)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Workarounds
If we set the applicationId to 'org.fdroid.fdroid', then then it is possible to show the F-Droid About screen. However, I believe this will limit the opportunity to add classes in our own package.
Another option is to create an empty class extending AboutActivity (and InstalledAppsActivity) classes, but I'd like to avoid that option because empty classes is a waste.
Probably the best option is to leave applicationId (as specified in the documentation) but to change preferences.xml to reference 'com.mycompany.appstore' as the targetPackage.
See:
<PreferenceScreen android:title="@string/about_title">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.mycompany.appstore"
android:targetClass="org.fdroid.fdroid.AboutActivity" />
</PreferenceScreen>
<PreferenceCategory android:title="@string/preference_category__my_apps">
<PreferenceScreen android:title="@string/preference_manage_installed_apps">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.mycompany.appstore"
android:targetClass="org.fdroid.fdroid.views.installed.InstalledAppsActivity" />
</PreferenceScreen>
</PreferenceCategory>
Please can you advise on the best solution and also update the documentation on https://f-droid.org/docs/Whitelabel_Builds/?