How to configure searchable activity when applicationId differs from package id? - android

I've changed applicationId and after that search functionality in my application stopped working. I initiate search via:
activity.onSearchRequested();
Essential part of AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androzic" >
<application
android:name=".Androzic"
android:icon="#drawable/icon"
android:label="#string/app_name" >
<activity
android:name=".SearchableActivity"
android:exported="true"
android:label="#string/search_name"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
</application>
</manifest>
Essential part of build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.androzic.v2"
minSdkVersion 8
targetSdkVersion 21
}
}
How do I properly configure search if my applicationId is not the same as package id?

If you specified applicationId with other value than package attribute, it's safe to set full qualified class name as android:value of meta-data element, like below.
<activity
android:name="com.androzic.SearchableActivity"
.../>
or
<meta-data
android:name="android.app.default_searchable"
android:value="com.androzic.SearchableActivity" />

Write this before </application>
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchableActivity" />

Related

Execution failed for task ':app:processReleaseMainManifest' even after having android:exported defined before all <intent-filters>

Execution failed for task ':app:processReleaseMainManifest'
Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Hello. I'm fairly new to Flutter and trying to target SDK 31. I explicitly put android:exported="true" or "false" before every in the AndroidManifest.xml file, yet it keeps throwing this error and does not generate an appbundle. I'm using VSCode.
Below is the AndroidManifest.xml file.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="****">
<uses-permission android:name="android.permission.INTERNET"
android:exported="true" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="***"
android:icon="#mipmap/ic_launcher">
<meta-data android:name="com.google.android"
android:value="****"/>
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:exported="false" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="portrait"
android:launchMode="singleInstance"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"/>
</application>
</manifest>
And here is part of my build.gradle file.
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "****"
minSdkVersion 21
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
Please help, I have looked through potential solutions on stackoverflow, but to no avail as most of them are related to Android Studio.

My App not working on Marshmallow but works on Nougat?

I m new to Android development. I have developed an app using the android studio. The problem is that after generating the signed APK, when I m trying to install the app on an android device with MARSHMALLOW on it, it's not getting installed showing error message "APP CANNOT BE INSTALLED" message, but it gets installed on an android device with NOUGAT on it instead I have set minSDKVersion to 19.
Here's my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.adityakumarsingh.arduinobot"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".WelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Splash"
android:screenOrientation="portrait"
android:theme="#style/SpalshTheme">
</activity>
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"></activity>
<activity
android:name=".Accelerometer"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".BluetoothConnection"
android:screenOrientation="portrait"
android:theme="#style/AppTheme" />
<activity
android:name=".GameMode"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".About"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".Voicerecog"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
</application>
</manifest>
And here's my build file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.adityakumarsingh.arduinobot"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-
layout:1.0.2'
compile 'io.github.controlwear:virtualjoystick:1.8.0'
compile 'com.github.markushi:circlebutton:1.1'
compile 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:design:26.1.0'
}
What to do? Any help would be appreciated.Thanks
Ok it mostly is the signature Which is causing issues. Try having a v2 plus v1 signature while signing the apk instead of just any one. I've seen this error when i was just using the v2 method. Adding the v1 signature will help.
V2 signatures sign the module and work for nougat and more. It'll not work on older versions of android so you'll have to use the v1 for full apk signature as well. This will let older versions install it with verification using v1 and nougat and above should still use v2. Use both. Details on this can be found at their site:
https://source.android.com/security/apksigning/v2
Also make sure that there isn't any already installed apk with the same version number as the one you are trying to install. It'll fail if it's already installed and the version number is the same.

how to change android packagename only?

I have a small android application with this manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.eliran.myapplication" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.eliran.myapplication.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I want alter the package name for testing integration with another andorid app.
However when I change to
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myTest.driver" >
I get an error that R class is not found
Error:(37, 25) error: package R does not exist
how can i fix this, with minimal effort and without changing the package name of each class?
Step #1: Return your package attribute to its original value
Step #2: Add applicationId to defaultConfig in your module's build.gradle file to your revised application ID
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
applicationId "com.commonsware.android.espresso"
}
}
This gives your app a separate application ID (the unique identifier for installation purposes) but keeps the package name the same (for R generation, etc.).
You need to change the applicationID in your build.gradle file

Application not Installed in Android

I developed an application, this application has 2 versions. when Install new version Application on old version.it shows Application Not Installed.
my manifest :
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/smsbox_2_logo"
android:label="#string/app_name"
android:largeHeap="true"
android:screenOrientation="portrait"
android:theme="#style/AppTheme">
<activity
android:name=".activities.Main_Page"
android:label="#string/app_name"
android:screenOrientation="portrait"></activity>
<activity
android:name=".activities.addSMS_Page"
android:label="#string/title_activity_new_sms"
android:screenOrientation="portrait" />
<activity
android:name=".activities.ShowSMS_Page"
android:label="#string/title_activity_show_sms__page"
android:screenOrientation="portrait" />
<activity
android:name=".activities.MySMS_Page"
android:label="#string/title_activity_my_sms__page"
android:screenOrientation="portrait" />
<activity
android:name=".activities.Fav_Page"
android:label="#string/title_activity_fav__page"
android:screenOrientation="portrait" />
<activity
android:name=".activities.login_Page"
android:label="#string/title_activity_login__page"
android:screenOrientation="portrait"></activity>
<activity
android:name=".activities.register_Page"
android:label="#string/title_activity_register__page"></activity>
<activity
android:name=".activities.category_Page"
android:label="#string/title_activity_register__page"></activity>
<activity
android:name=".activities.category_select_Page"
android:label="#string/title_activity_register__page"></activity>
<activity
android:name=".activities.about_Page"
android:label="#string/title_activity_about__page"></activity>
<activity
android:name=".activities.setting_Page"
android:label="#string/title_activity_setting__page"></activity>
<activity
android:name="com.tellfa.smsbox.activities.splash_Page"
android:label="#string/title_activity_splash__page">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.connectus_Page"
android:label="#string/title_activity_connectus__page"></activity>
</application>
</manifest>
Build.Gradle code :
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.tellfa.smsbox"
minSdkVersion 14
targetSdkVersion 22
versionCode 10
versionName "2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
how to fix it ?
Just uninstall old Application and then install new version
you probably used a different keystore file, you need to uninstall the app and re-install it
Set minimum and target Sdk versions in mainfest
the keystore should be same for two versions. in this case you have to un-install previous version and reinstall new version will fix the issue. or use the same keystore

Android split ActionBar not working

I'm new with android ... i want to have a simple activity with a bottom action Bar in all tutorials it's mentionned that there is a way with
android:uiOptions=”splitActionBarWhenNarrow”
but it does not work on tablet or smal device even when i added
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
</activity>
this is my manifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name=".launchActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:uiOptions="splitActionBarWhenNarrow"
android:name=".MainActivity"
>
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
</activity>
<activity
android:name=".DisplayMessageActivity"
android:label="#string/title_activity_display_message" >
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
build file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "xxxxxxx"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Android 5.0's default theme (Theme.Material) does not support the split action bar. Neither does the appcompat-v7 action bar backport anymore, though it used to.
Your options are either to switch to theme based off of Theme.Holo, put your own bar at the bottom of the screen (e.g., a Toolbar), or simply redesign your UI to avoid the split action bar.
I'm fully agree with #CommonsWare answer.
I just add a note.
If you build your app only for Lolipop(5.0) or higher(for now) the action bar may be represented by any Toolbar widget within the application layout. You can align components(also split them) inside since you are want.

Categories

Resources