I am going to develop Android on my company.
I downloaded Android Studio 3.1 and created a new blank project I get an error.
Gradle download will cause an unconditional error.
I referenced a lot of Google stuff, but I could not solve it.
Build gradle :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.fouad.kurd"
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
gradle.wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
:(
Error Screen shot
Please Help me
You won't be able to use constraintLayout with target sdk version 28
So the main culprit is
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
So please remove the constraint layout or reduce the target sdk version to 27.
check if you have disabled offline mode of Android Studio.
Use implementation 'com.android.support:appcompat-v7:28.0.0-beta01' instead of 28.+
Related
I am new to Android. Here I am trying to add data binding to my android app for that I enabled data binding to true in-app level gradle file but the problem is it's not syncing it gives some error like this.
Gradle DSL method not found: 'dataBinding()'
Possible causes:
The project 'TriviaApp' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.4.1 and sync project
The project 'TriviaApp' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin.
Apply Gradle plugin
this is My app level gradle file code
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.triviaapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding(
enabled: true
)
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Can anyone please help me to figure out what am I doing wrong and help me to fix this.
You should use
dataBinding {
enabled = true
}
Make sure, your build.gradle is
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
allprojects {
repositories {
jcenter()
}
}
I'm currently trying to implement OSMDroid in to my project, but doing it has shown in the OSMDroid tutorial (http://osmdroid.github.io/osmdroid/index.html) does not seem to be working.
When I try to sync the Gradle project I get the following message:
Failed to resolve: osmdroid-android
And I have here the full build.gradle(Module: app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.massas.emergency_numbers_pi"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'org.osmdroid:osmdroid-android:6.0.0-SNAPSHOT'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Am I doing something wrong or is the dependencie just outdated? Should I insert the dependencies in the project build.gradle?
I'm new to android dev, so please bear with me! Thanks
1) Make sure you have added the repository. You need maven central for stable releases and sonatype for snapshot. Instructions for that are included in the documentation but for the sake of this response:
Current stable:
repositories {
mavenCentral()
}
dependencies {
implementation 'org.osmdroid:osmdroid-android:6.0.1'
}
Current snapshot:
repositories {
mavenCentral()
maven{
url 'https://oss.sonatype.org/content/repositories/snapshots/'
name 'OSS-Sonatype'
}
}
dependencies {
implementation 'org.osmdroid:osmdroid-android:6.0.2-SNAPSHOT'
}
Note: you can also add repositories to your root gradle file to the allprojects section.
2) You should use the stable version (6.0.1 at the time of writing) uless you have a specific reason to use snapshot.
Unable to resolve dependency for ':app#release/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-rc01
I know solution but I want know what is the main issue in latest android studio and why???
just changing the dependencies problem is fix as shown in below: Friends my question is why and what is the issue in latest android studio any another solution for this issue ...please help me out
Build : Gradle project
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Build : Gradle Module
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.myXYZ.MyApp"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
By your version of gradle plugin I assume you are using not the latest Android studio, but 3.1.x.
Try to use 3.2.5 beta from Canary (Beta) channel. It might help
I am getting this error while sync gradle project.
Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve com.android.support:design:26.1.0
can anyone help me?
apply plugin: 'com.android.application' android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.phaniteja.sample1"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
} } dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' }
Unable to resolve dependency for :app#debugAndroidTest/compileClasspath': Could not resolve com.android.support:design:26.1.0 This issue usually happens when the Android Studio is not able to download that dependency.That can be due to many reasons like this Or like in my case where the Maven2 and jcenter repositories are blocked in Company. So what can you do is like check this folder
Android-sdk\extras\android\m2repository\com\android\support\appcompat-v7
and check which all versions are available to you in the SDK, use either one of those versions ,So instead of downloading from repository studio will take that lib from SDK.
Try to add your Google maven repo. it works for me.##
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
I have install android studio on macbook pro and I am sure I have install all the required SDK for it to work but yet still I am having issues with errors. below is the error messages
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.0.0-beta1.
Could not resolve com.android.support:appcompat-v7:26.0.0-beta1.
Required by: project :app
No cached version of com.android.support:appcompat-v7:26.0.0-beta1 available for offline mode.
here is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.air.my1st"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.0.0-beta1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}
Thanks all in advance.
add this code in build.gradle:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Try to change the targetSdkVersion 27
Dependencies to latest:
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'