I have an Android 4.x app with Holo style. Now I want add support for Material style and I'd like have Material style both on Android 5 and Android 4.x (I have read this is possible with AppCompat v21). I have read this post about "migration" from Holo to Material: http://android-developers.blogspot.sg/2014/10/appcompat-v21-material-design-for-pre.html
So I have change my old "build.grandle" file from this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 18
versionName "1.3.1"
}
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:4.4.52'
compile 'com.github.fernandodev.easyratingdialog:easyratingdialog:+'
}
to this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
versionCode 19
versionName "2.0.0"
}
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.github.fernandodev.easyratingdialog:easyratingdialog:+'
compile 'com.anjlab.android.iab.v3:library:1.0.+@aar'
}
I have change JDK6 to JDK7 (because SDK21 need it), select API21 as "compile sdk version" and create a new XML file "values/themes.xml":
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- Set AppCompat’s actionBarStyle -->
<!-- Set AppCompat’s color theming attrs -->
<item name="colorPrimary">#8bc34a</item>
<item name="colorPrimaryDark">#259b24</item>
<!-- The rest of your attributes -->
</style>
</resources>
Now when I try to run my app on my device (with Android 4.4, at this moment I don't have a device with Android 5), Android Studio before try install it, then ask me to remove the old version (but there is not a old version. I have remove it and delete all folder). When I confirm I get a error:
Uploading file
local path: C:\MYAPP\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.myname.myapp
Installing com.martinzone.topotafmobile
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.myname.myapp"
pkg: /data/local/tmp/com.myname.myapp
Failure [INSTALL_FAILED_DEXOPT]
I have also tried to "clear" my project but in this case I get this error:
Uploading file
local path: C:\MYAPP\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.myname.myapp
Installing com.myname.myapp
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.myname.myapp"
pkg: /data/local/tmp/com.myname.myapp
Failure [INSTALL_FAILED_UID_CHANGED]
Any idea? How can I solve it? How can I add Material Style support working on Android 4 and Android 5?