I have 4.4.4 (19) Android and I can't use instant run with new version (2.3) of Android Studio:
Why did they do it? It worked on the version before this one.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
...
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId ***
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary true
renderscriptTargetApi 25
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
***
}
(emphasis mine)
In Android Studio 2.3 and higher, Instant Run significantly reduces the time it takes to update your app with code and resource changes. After deploying your app to a target device running Android 5.0 (API level 21) or higher, you can click Apply Changes to push certain code and resource changes to your running app without building a new APKāand, in some cases, without even restarting the current activity
Android | Instant Run
Note You can still set the targetSdkVersion and compileSdk version to the latest API levels without affecting the majority of your code. (minus any deprecated methods)
If you still not find solution then just go one way.Probably it work for you.
Update your sdk with Platform tools whatever Device you want to run.
Instant need platform tools.
Like nougat need 24.
Thanks hope this will help you.
Related
This is my gradle file where I make the changes but anything I do with SDK 28 doesn't help me but when I change it to 27. It works. Please help me to make it work with SDK 28. Thank you.
//This is my app gradle(Module:base)
apply plugin: 'com.android.feature'
android {
compileSdkVersion 28 //Change is made here
baseFeature true
defaultConfig {
minSdkVersion 16
targetSdkVersion 28 //Change is made here
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api 'com.android.support:appcompat-v7:28.0.0-beta01'//Change is made here
api 'com.android.support.constraint:constraint-layout:1.1.2'
application project(':app')
feature project(':project')
}
//If I change the SDK version to 27, it works. I really want to find out how to make it work in SDK version 28
//Thank you for helping
Click Tools > SDK Manager.
In the SDK Platforms tab, select Android P Preview.
In the SDK Tools tab, select Android SDK Build-Tools 28-rc2 (or higher).
Click OK to begin install.
Make sure you have Android Studio 3.1 or higher.
Here's my build.gradle file. After updgrading to AS 1.5.1 and attempting to compile/sync, I got error on last line, but program executes fine:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.dslomer64.wordyhelperton"
minSdkVersion 19
targetSdkVersion 19
versionCode 16
versionName "3.02"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.1'
}
The error is on the last line above (compile 'com.android....-v4:22.2.1).
It says:
This support library should not use a different version (22) than the
compileSdkVersion (19).
So I changed compileSdkVersion to 22 and also changed minSdkVersion and targetSdkVersion to 22 since the first change alone still gave warnings, but NO ERRORS.
The warnings are on every line from 'defaultConfig' down.
The warning is:
defaultConfig cannot be applied to groovy.lang.Closure ... assignment with incompatible types
What should I do? App compiles and runs fine. Is ignoring these warnings are OK?
Yes, messages like ...cannot be applied to groovy.lang.Closure can be ignored, but if you want to fix them here are a few answers that will help you:
Quick fix - just a small change in settings.
Proper and lengthy fix - creating a top level build.gradle.
Missed this earlier but thanks to Gabriele for pointing it out in the comment below:
The warning about the api to be used to compile the project, should
not be ignored. You have to compile with the same version of the maior
release (in this case 22) otherwise you can have issue. For example
using the appcompat v22 you would have errors using api 19
Those warnings can be ignored, I have them throughout my projects as well.
I have a top level gradle.build file and reference some parameters from it in lower level gradle.build files. I think that is where the error comes from in my case. Gradle can't tell what argument type it is.
As it turns out, I guess because of upgrade, the folder previously containing Gradle wasn't found. I changed it to C:\Program Files\Android\Android Studio\gradle\gradle-2.8 and all was well except for two warnings, both suggesting using latest version of Android, so I made the suggested changes (new Gradle.build file below) and have no warnings:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.dslomer64.wordyhelperton"
minSdkVersion 19
targetSdkVersion 23
versionCode 16
versionName "3.022"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.1.1'
}
I also changed Build, Execution, Deployment to have Gradle use the default Gradle wrapper instead of the local specific folder (2.8 as reported above) as discussed here.
I imported the CardView Sample app using Android Studio with Import Sample option from GitHub. No issues.
However, When I tried to run this sample app on my Android device running Android 4.2, I am getting error as per below screenshot:
I Google the issue and found this link: Installation error: INSTALL_FAILED_OLDER_SDK
As per the answers in that link, I need to make targetSdkVersion to match my device OS version So, I tried to change the targetSdkVersion as below (Android 4.2 = API Level 17)
<uses-sdk android:minSdkVersion="7"
android:targetSdkVersion="17" />
But even after this change I am unable to run this app on my android device.
Any hint on how to fix this?
Update these lines in your build.gradle to stick with the latest stable release (Android 4.2, API 17):
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "17.1.0"
defaultConfig {
applicationId "com.example.daroath.actionbar"
minSdkVersion 14
targetSdkVersion 17
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
SOLUTION
In build.gradle file, I set both minSdkVersion and targetSdkVersion to 19 (my Android device's API level).
Also, compileSdkVersion's value must be less than your device's level API.
Issue was:
I cannot install my app I developed in Android Studio, in my Android device (LG G3).
When I try to install my app, this window comes.
When I click OK, the log outputs this.
This was my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "*AppID*"
minSdkVersion 15
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
What I've tried to do:
1. Modify build.gradle to (Changed compileSdkVersion's value to 15):
apply plugin: 'com.android.application'
android {
compileSdkVersion 15
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "*AppID*"
minSdkVersion 15
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
2. Clean the project: i.imgur.com/lbdeXGe.png.
Take a look at Failure [INSTALL_FAILED_OLDER_SDK] Android-L
Recently there was a post here regarding the L SDK's incompatibility with prior versions of Android. I've been digging in
AOSP repositories for quite a few hours now, and determined that the
tools behave this way because they are designed to treat preview
platforms differently. If you compile against a preview SDK
(android-L), the build tools will lock minSdkVersion and
targetSdkVersion to that same API level. This results in the produced
application being unable to be installed on devices running older
releases of Android, even if your application isn't doing anything
specific to L. To make matters worse, the new support libs (CardView,
RecyclerView, Palette, etc.) are also locked into the L API level,
even though--according to their repository names--they should work on
API level 7 just fine (and they do!).
The error means your device has an Android version that is less than your specified minSdkVersion. Set the minSdkVersion to the device's version. If that's not possible, there's really nothing you can do other than using a newer device.
Edit:
Now seeing userM1433372's answer ... That should be the actual issue. Thought you already tried a different SDK version, but you only changed compileSdkVersion to 15 without changing targetSdkVersion! I would suggest setting both targetSdkVersion and compileSdkVersion to 19 (which is the latest non-preview-version).
I am trying to get a basic hello world program running on my phone, however Android Studio keeps on reverting to minSDK level 20, when I specified 14. Here is the process I am using:
-Start Android Studio 0.8.2
-Select New Project
-Select Minimum SDK as API 14: Android 4.0
-Select Blank Activity
-The new project is now open. My android device, running 4.4.2 API 19 is plugged in.
-Select "Run app"
-The "Choose Device" dialog opens, shows my android device, but shows compatibility as No, minSdk(API 20, L preview)!= deviceSdk(API19)
The following is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.victor.myapplications"
minSdkVersion 14
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Changing 'compileSdkVersion' to 14 results in an error, "failed to find target android-14".
Any ideas? Thanks!
The "L" Developer Preview is a special snowflake that breaks all the normal rules for version management. :-(
Unless you are an experienced Android developer specifically testing on "L", change compileSdkVersion to something like 19 (note: may require you to download the SDK Platform for API Level 19 from the SDK Manager) and change targetSdkVersion to 19.
Changing 'compileSdkVersion' to 14 results in an error, "failed to find target android-14".
You need to download the API Level 14 "SDK Platform" in the SDK Manager.
try this:
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.victor.myapplications"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
If the target keep giving to you this problem try putting a lower version like CommonsWare said !