I just install from zero Android Studio 3 and clone my project which doesn't use Android Studio 3 before. I tried to compile but gradle couldn't sync correctly.
I'm using gradle 4.3 because I search my problem on other post, but couldn't find how to fix. This is my gradle file :
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath "io.realm:realm-gradle-plugin:2.1.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And app/gradle file :
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
lintOptions {
disable 'InnerclassSeparator'
}
defaultConfig {
applicationId "fr.laway.dev.laway"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(path: ':laway_data', configuration: 'default')
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.github.clans:fab:1.6.4'
compile 'com.aurelhubert:ahbottomnavigation:1.5.1'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.android.support:multidex:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.27.0'
compile 'com.google.android.gms:play-services-auth:11.4.2'
compile 'com.google.gms:google-services:3.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Finally, my errors :
Is something missing in my gradle file?
I don't know why it's related but I just update my realm library :
classpath "io.realm:realm-gradle-plugin:4.1.1"
This was enough for finish to compile and remove all errors. Gradle still is very mysterious for me x)
From the error, gradle complaining this:
android-apt plugin is incompatible with the Android plugin. Please use
'annotationProcessor' configuration instead.
From the documentation:
Use the annotation processor dependency configuration
In previous versions of the plugin, dependencies on the compile classpath were automatically added to the processor classpath. That is, you could add an annotation processor to the compile classpath and it would work as expected. However, this causes a significant impact to performance by adding a large number of unnecessary dependencies to the processor.
When using the Android plugin 3.0.0, you must add annotation processors to the processor classpath using the annotationProcessor dependency configuration, as shown below:
dependencies {
...
annotationProcessor 'com.google.dagger:dagger-compiler:<version-number>'
}
You need to using annotationProcessor in your laway_data module build.gradle.
Related
i know the title of this error may seem familiar , but beilive me I have done every thing to solve the problem , but I failed every time! so please help me!
i dowloaded a code for and online shop app , i tried to run it in android studio but following error has occurred:
Error:Failed to find Build Tools revision 26.0.2
"install.build.tools">Install Build Tools 26.0.2 and sync project
now here is what i did :
at first i was using android studio v 2.3
i checked sdk manager and every thing was installed ,
to resolve the problem i tried updating it to latest version (v 3.0.1)
and I manually instaled sdk 26 and tools_26.0.2
but error wouldnt go away!! :((
here is the code for my build.gradle for a closer look :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "ir.tameshki.zanbil"
minSdkVersion 14
targetSdkVersion 26
versionCode 2
versionName "1.1.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
// library for user interface
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:cardview-v7:26.0.2'
compile 'com.android.support:recyclerview-v7:26.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:support-v4:26.0.2'
compile 'com.balysv:material-ripple:1.0.2'
// library for api
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.google.code.gson:gson:2.4'
// glide image loader
compile 'com.github.bumptech.glide:glide:3.7.0'
// firebase notification library
compile 'com.google.firebase:firebase-messaging:9.2.1'
// firebase ads library
compile 'com.google.firebase:firebase-ads:9.2.1'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
}
apply plugin: 'com.google.gms.google-services'
and my other gradle file :
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I am having an error compiling the application.
Android Studio
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.1.0'
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 23
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "app.app"
minSdkVersion 16
targetSdkVersion 23
versionCode 12
versionName "2.0.5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-ads:11.8.0'
compile 'com.google.firebase:firebase-crash:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'it.sephiroth.android.library.bottomnavigation:bottom-navigation:2.0.1-rc1' //1.0.7
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
apt 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.afollestad.material-dialogs:commons:0.9.6.0'
compile 'com.dmitrymalkovich.android:material-design-dimens:1.4'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
I am using Android Studio 3.0.1 and gradle version is 4.1
The third party android-apt plugin is no longer supported. You should switch to the built-in annotation processor support, which has been improved to handle resolving dependencies lazily.
When using the Android plugin 3.0.0, you must add annotation processors to the processor classpath using the annotationProcessor dependency configuration, as shown below:
dependencies {
...
annotationProcessor 'com.google.dagger:dagger-compiler:<version-number>'
}
I always get this error in my android studio, and i dont have any idea about this, i've tried to find the solution on the Internet but i still cant find it.
This is my Gradle Image :
this is the Error Image :
In your project the errors comes like you have not add project level google classpath and not apply google plugin in app level gradle so,
Add in project level gradle
classpath 'com.google.gms:google-services:3.1.1'
Add in APP level gradle and google plugin
dependencies {
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.android.gms:play-services:11.6.0'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
NOTE-: If you want to add more Google gradle for your requirements then add with same version.
For More https://firebase.google.com/docs/android/setup
https://developers.google.com/android/guides/setup
If you are using Google Services your Gradles should look something like this:
App level build.gradle should look like
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-crash'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.xxxxxx"
minSdkVersion 15
targetSdkVersion 26
versionCode 11
versionName "1.10"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
signingConfig signingConfigs.config
resValue("string", "PORT_NUMBER", "8081")
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
debugCompile project(':debug-db')
compile project(':tracker')
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:multidex:1.0.2'
compile 'com.google.android.gms:play-services-location:11.6.0'
compile 'com.google.android.gms:play-services-places:11.6.0'
compile 'com.google.android.gms:play-services-maps:11.6.0'
/* compile 'com.google.android.gms:play-services:11.6.0'*/
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-crash:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.squareup.okhttp3:okhttp:3.8.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:recyclerview-v7:26.1.0'
testCompile 'junit:junit:4.12'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
As you could see, no use for build, but it completely depends on your use /* compile 'com.google.android.gms:play-services:11.4.0'*/
And root level gradle.build is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.1'
classpath 'com.google.firebase:firebase-plugins:1.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
jcenter()
mavenCentral()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Make sure your Gradle distribution in gradle-wrapper.properties is
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip
my project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
classpath 'com.google.dagger:dagger-compiler:2.2'
classpath 'com.google.guava:guava:19.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
my module build.gradle
android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
applicationId "com.aber.app.acgtalk"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
ext {
supportLibVersion = '24.0.0'
}
dependencies {
compile 'com.google.dagger:dagger:2.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.2'
debugAnnotationProcessor 'com.google.dagger:dagger-compiler:2.2'
provided 'javax.annotation:jsr250-api:1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:${supportLibVersion}";
compile "com.android.support:recyclerview-v7:${supportLibVersion}";
compile "com.android.support:design:${supportLibVersion}";
compile "com.android.support:support-v13:${supportLibVersion}";
compile "com.android.support:support-annotations:${supportLibVersion}";
compile "com.android.support:gridlayout-v7:${supportLibVersion}";
compile "com.android.support:cardview-v7:${supportLibVersion}";
compile "com.android.support:preference-v14:${supportLibVersion}";
compile 'com.squareup.okhttp3:okhttp:3.2.0';
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
}
what's wrong with this,how to using the annotationProcessor function within the Android studio 2.2 ,how to conifg the dagger2 annotation processor correctly?
new Jack annotations processors
Yes, with android gradle plugin 2.2.0 release, the android-apt plugin is no longer needed for annotation processing. The apt function was included in the latest android gradle plugin. It's called annotationProcessor now which was what you had in your build script. However, there were a few misconfigured stuff in the script.
First of all, the dagger compiler should not be added to classpath. So remove this line: classpath 'com.google.dagger:dagger-compiler:2.2'.
And you are using android gradle plugin version alpha3. Try to use the latest version, so change to classpath 'com.android.tools.build:gradle:2.2.2'.
The dependency declaration block looks legit. So try to make the above changes to see if it would work.
You're incorretly insert plugin classpath. Remove the following line in your project build:
classpath 'com.google.dagger:dagger-compiler:2.2'
and insert:
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
Then in your module build.gradle, add the following code after apply plugin android application:
// add after applying plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
Add the following line to your dependencies:
// apt command comes from the android-apt plugin
apt 'com.google.dagger:dagger-compiler:2.2'
compile 'com.google.dagger:dagger:2.2'
provided 'javax.annotation:jsr250-api:1.0'
For more information read here:
https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2
and for sample project, visit here:
https://github.com/spirosoik/AndroidArchitecturePadawans
I need to install the plugin Butter Knife. Where can I download it? I downloaded a .jar plugin (but not if the file is the one I need), I have installed but when I click on the option "generate" not the option to use butterknife appears. following a video tutorial I modified files Gradle build: I have them now as follows:
apply plugin: 'android-apt'
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "calcursoedxleccion0.cal"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:design:$rootProject.ext.supportLibraryVersion"
// compile "com.jakewharton:butterknife:$rootProject.ext.butterKnifeVersion"
compile "com.jakewharton:butterknife:$rootProject.ext.butterKnifeVersion"
apt "com.jakewharton:butterknife-compiler:8.0.1"
}
and
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext{
minSdkVersion = 16
targetSdkVersion = 23
compileSdkVersion = 23
buildToolsVersion = '23.0.3'
supportLibraryVersion = '23.3.0'
butterKnifeVersion = '8.0.1'
}
Gradle to synchronize I get this error:
"The android android-library or plugin must be applied to the project"
error (1.0)
What am I doing wrong?
The easiest way to use ButterKnife library is to add this single line to your module-level build.gradle dependencies list:
dependencies {
implementation 'com.jakewharton:butterknife:7.0.1'
}
You can then synchronize your project!
UPDATE 1
I just noticed Jake the Wharton has updated the library since the last time I used it! Now, it appears you have to add to two separate places:
In your project-level build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
And lastly, in your module-level build.gradle file:
apply plugin: 'android-apt'
android {
...
}
dependencies {
implementation 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
It is important that you add apply plugin: 'android-apt' to top of the module-level build.gradle file; most likely below the first line like this:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
I have just tested this and works for me. Good luck!
UPDATE 2
Jake Wharton just released an update to the library and here is what you need to do in order to use it:
So, inside your build.gradle (app-level), add the following to your dependencies!
dependencies {
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
I hope this helps you!
UPDATE 3:
Here is versions released till now in case you have conflict with other libraries and want it to work on older API levels
With trying , in case you want it min SDK level 15 till now
you will need to play with versions to get it working in my case these set
are compatable so far with SDK 15 as minimum.
This case i only put these in module app level build.gradle.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:24.2.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'com.squareup.retrofit2', name: 'converter-gson', version: '2.3.0'
implementation 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
implementation 'io.reactivex:rxjava:1.1.6'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
implementation 'com.android.support:recyclerview-v7:24.2.1'
}
In Android Studio you can do this by:
Right-click your module
Click 'Open Module Settings'
Click Dependencies Tab
Click the green plus icon
Select 'Library Dependency' from the dropdown list
Enter "butterknife" in the search field and click the search button
After selecting the library, Android Studio adds the dependency to your module.
Since butterknife does annotation processing, you have to add this to the build.gradle of your module right after the compile statement for butterknife:
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
where the version number at the end should match your version of butterknife.