android - How to launch application with Theme.Material on older devices -
how can run app on pre-v21
devices?
compilesdkversion 'android-l' minsdkversion 14 targetsdkversion 'l'
i'm using theme.material
on v21
. i'm not using v20
support library, i'm using com.android.support:support-v4:19.+
when running application android studio says device in not compatible:
{compatible=no, reason=minsdk(api 20, l preview) != devicesdk(api 16)}
from taking minsdk 20
?
edit:
the reason happening (if verified)
if compile against preview sdk (android-l), build tools lock minsdkversion , targetsdkversion same api level. results in produced application being unable installed on devices running older releases of android, if application isn't doing specific l.
source: reddit
if compile against preview sdk (android-l), build tools lock minsdkversion
, targetsdkversion
same api level. results in produced application being unable installed on devices running older releases of android, if application isn't doing specific l.
version 0.11 of android gradle plugin turned on new manifest merger default, , allows nifty stuff. have add yo androidmanifest.xml
file uses-sdk node specifies tools:node
attribute.
specific configuration tells manifest processor replace attributes uses-sdk
nodes in lower-priority manifests (such library manifests) attributes in uses-sdk
node tools:node="replace"
attribute. since gradle inserts minsdkversion
, targetsdkversion
build.gradle
uses-sdk
node, that's need add.
so androidmanifest.xml
file should somehing this:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="net.eringle.android.ldemo"> <uses-sdk tools:node="replace" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".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>
now should able run application on device supported minsdkversion, while taking advantage of neat new views , utilities in support lib!
next, i've modified android l platform hide fact it's preview platform build tools. can download either of these 2 mirrors: mirror #1, mirror #2.
extract archive platforms directory have android sdk installed. you'll notice i've named android-21
, set api level 21
well. instead of referencing l
or android-l
in build.gradle
, use 21
:
android { compilesdkversion 21 buildtoolsversion '20.0.0' defaultconfig { applicationid 'net.eringle.android.ldemo' minsdkversion 15 targetsdkversion 21 versioncode 1 versionname '1.0' } ... }
now when build , try run application, should able send older-platform devices without issues. have fun playing l while retaining backwards-compatibility!
obviously, workarounds provided above hacks @ best. please star issue, seems closest heart of problem (if android team deems problem @ all).
all credits go eddieringle
Comments
Post a Comment