Android split ActionBar not working - android

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.

Related

ActionBar is not being displayed anymore after migration from Eclipse to Android Studio

I recently tried to edit my 4 year old android application in the recently appeared Android Studio 2.3.1.
After importing the code I can launch it on my mobile phone. However the action bar seems to have disappeared. What has gone wrong?
How can I tell android to display the action bar?
I have implemented the action bar activity like this:
public class MainActivity extends ActionBarActivity
My build.gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "de.my.app"
minSdkVersion 8
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
}
I also tried to replace the compile command with something newer one:
compile 'com.android.support:appcompat-v7:25.3.1'
but already the syncing in android studio fails like this, throwing the following error:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library [com.android.support:appcompat-v7:25.3.1] /home/user/.android/build-cache/815cafa5312f1d889eb1134b2184a62b3f88d8a3/output/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
I haven't done much android coding in the last 4 years so I assume the ActionBar stuff has changed profoundly but shouldn't there be a way to compile the old code as it is using android studio?
Edit:
This is the manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.myApp.myAppDemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/icon_app"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="de.myApp.myAppDemo.Splash"
android:label="#string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="de.myApp.myAppDemo.MainActivity"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#style/Theme.AppCompat.Light">
<intent-filter>
<action android:name="de.myApp.myAppDemo.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="de.myApp.myAppDemo.PropertiesAssign"
android:label="#string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="de.myApp.myAppDemo.PROPERTIESASSIGN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="de.myApp.myAppDemo.PropertiesView"
android:label="#string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="de.myApp.myAppDemo.PROPERTIESVIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Meanwhile I got at least the ActionBar to be displayed. However I had to increase the MinSDK and targetSdkVersion / compileSdkVersion bigly: From 8,17 to 15,23. Moreover I had to look in the SDK-Manager to see which exact version of Android Support Library was installed on my system (23.2.0) and adapt the corresponding line in build.gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23 //->modified
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "de.Geo.geodraw"
minSdkVersion 15 //->modified
targetSdkVersion 23 //->modified
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile "com.android.support:appcompat-v7:23.2.0" //->modified
}
Not sure whether it was relevant or necessary but following this page I also added
allprojects {
repositories {
jcenter()
maven { //->modified
url "https://maven.google.com" //->modified
} //->modified
}
}
in another build.gradle file.
If there is another solution without drastically changing minSdk and targetSdk I will accept that answer.

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 app showing incompatible after publishing

I have just tried to publish my first app but when it finally went through it was shown as being incompatible to multiple devices, I have been searching and every fix that I have come across has done nothing for me. Any suggestions?
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.customledsupply.ledaudit" >
<uses-feature
android:name="android.hardware.camera2"
android:required="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/cls"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainPage"
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:name=".OldLocation"
android:label="#string/title_activity_old_location" >
</activity>
<activity
android:name=".NewLocation"
android:label="#string/title_activity_new_location" >
</activity>
<activity
android:name=".RoomDescription"
android:label="#string/title_activity_room_description" >
</activity>
<activity
android:name=".FixtureDescription"
android:label="#string/title_activity_fixture_description" >
</activity>
<activity
android:name=".RoomList"
android:label="#string/title_activity_room_list" >
</activity>
<activity
android:name=".Summary"
android:label="#string/title_activity_summary" >
</activity>
</application>
</manifest>
Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.customledsupply.ledaudit"
minSdkVersion 19
targetSdkVersion 22
versionCode 2
versionName "2.0"
}
signingConfigs {
release {
storeFile file("myreleasekey.keystore")
storePassword "CLS"
keyAlias "Custom LED Supply"
keyPassword "CLS"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'io.realm:realm-android:0.82.0'
}
Most probably, the potential cause is the following:
<uses-feature
android:name="android.hardware.camera2"
android:required="true" />
If any device doesn't have this feature, it wont even show it on the play store for them and will be in your list of incompatible devices. If you want to make it optional, use android:required="false" instead. By doing thing, you might be able to get around the issue.
Otherwise if you give examples of the incompatible devices, we might be able to narrow down the issue more. Hope it helps.
In your AppManifest.xml, you added a feature that is not be supported by all devices which is android:name="android.hardware.camera2". It only supports API 21+. However, you can set the required attribute to false, but that will cause issues for your app.
Reference Link: https://developer.android.com/reference/android/hardware/camera2/package-summary.html

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

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" />

How to unimport a project from android studio

I downloaded a library from github and imported it. I don't think it was done right. How to unimport it. I deleted the project from windows file explorer. Now when I build I get Task 'compileDebugSource' not found in project:BackgroundMailLibrary.
I just found that that lib is deprecated and want to use the new one. Please help.
.
I removed the library by clicking on it and selecting edit configuration and clicking the - mark. But am still getting the cross mark
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "com.prematixsofs.taxiapp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
//compile files('libs/mail.jar')
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-library android:name="com.google.android.maps" />
<service
android:name=".KioskService"
android:exported="false" />
<uses-permission android:name="android.permission.GET_TASKS" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppFullScreenTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".RegisterActivity"
android:label="#string/title_activity_register"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".BaseActivity"
android:label="#string/title_activity_base" >
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login"
android:windowSoftInputMode="stateHidden" >
</activity>
<activity
android:name=".BlankActivity"
android:label="#string/title_activity_blank" >
</activity>
<activity
android:name=".DateVehiclePicker"
android:label="#string/title_activity_date_vehicle_picker" >
</activity>
<activity
android:name=".MailImage"
android:label="#string/title_activity_mail_image" >
</activity>
<activity
android:name=".EditUserDetails"
android:label="#string/title_activity_edit_user_details" >
</activity>
<activity
android:name=".DynamicTextViewActivity"
android:label="#string/title_activity_dynamic_text_view" >
</activity>
<activity
android:name=".SplashScreenActivity"
android:label="SplashScreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".KioskService"
android:exported="false" />
<activity
android:name=".DisplayBookingHistory"
android:label="#string/title_activity_display_booking_history" >
</activity>
</application>
If it is a library dependence
go to file-->project structure-->on the right side tab select dependency and remove that
you can also remove it from you build.gradle file
if it is imported as a module
go to file-->project structure-->on top left corner click the (-) mark
In Android studio window,
Remove from File > Project Structure > Dependencies > - button. Then if it is still there you can remove the module by going to the settings.gradle file and removing it from the include line.
If you have disable run button than follow
Click Run on the menu and then Edit Configurations then click on Android Application on the left and click the + button. Choose Android Application from the pop-up menu. Then pick the module (its normally app or something like that). Then click apply and ok.
If you have more errors after that, try to re-import the project in Android Studio.

Categories

Resources