Android Studio unable to run project - android

I'm trying to run old project that runs for a lot of time.
Suddenly I'm unable to run it.
This is the build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.1.3"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
// For MobFox
maven {
url "https://jitpack.io"
}
// For AppBrain SDK
maven {
url 'http://swisscodemonkeys.github.io/appbrain-sdk/maven'
}
}
}
This is the gradle-wrapper.properties file:
#Sun Nov 12 11:49:59 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
org.gradle.jvmargs=-Xmx4608M
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
And i get this error:
Gradle sync failed: Could not find gradle.jar (com.android.tools.build:gradle:3.0.0).
Searched in the following locations:https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
When I change the order between the google() and jcenter(), this error disappears but i get this error now:
error: cannot access zzbfm
class file for com.google.android.gms.internal.zzbfm not found
Any idea of how I can fix this issue? I prefer to not upgrade the Gradle version since this is a complicated project and I need to upload an update really soon without making a lot of changes.
EDIT
This is the app build.gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 26
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
}
buildTypes {
debug {
debuggable true
buildConfigField "boolean", "CRASH_LOGGING", "true"
applicationIdSuffix ".dev"
}
release {
debuggable false
buildConfigField "boolean", "CRASH_LOGGING", "true"
minifyEnabled true
proguardFiles 'proguard-project.txt'
}
}
flavorDimensions "regular"
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
implementation "com.android.support:support-compat:26.1.0"
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile('com.thoughtworks.xstream:xstream:1.4.7') {
exclude group: 'xmlpull', module: 'xmlpull'
}
compile 'org.apache.commons:commons-lang3:3.6'
compile 'joda-time:joda-time:2.9.9'
compile('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
// UI & VIEWS
compile 'com.tuyenmonkey:mkloader:1.4.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.github.mmin18:realtimeblurview:1.1.0'
compile 'com.github.PhilJay:ValueBar:v1.0.2'
// IMAGE HANDLING
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
// NETWORK HANDLING
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.9.0'
//RETORFIT
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile('com.squareup.retrofit2:converter-simplexml:2.3.0') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
// FABRIC
compile('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true;
}
// ADS
compile 'com.flurry.android:analytics:8.2.0#aar'
compile 'com.appbrain:appbrain-sdk:14.60#aar'
compile(name: 'android-ad-sdk', ext: 'aar')
compile(name: 'SOMAAndroid-9.1.5-release', ext: 'aar')
compile 'com.applovin:applovin-sdk:+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
samsungDebugCompile files('libs/sdk-v1.0.0.jar')
samsungDebugCompile files('libs/motion-v2.2.2.jar')
samsungReleaseCompile files('libs/sdk-v1.0.0.jar')
samsungReleaseCompile files('libs/motion-v2.2.2.jar')
//debug DB
debugCompile 'com.amitshekhar.android:debug-db:1.0.1'
}
apply plugin: 'com.google.gms.google-services'

Just go the file menu and click on invalidate cache and restart the android studio.
Then from build menu do clean, rebuild and make project.

Related

How to Avoid Conflict in Android Gradle Dependencies

I am new in android and working on an old Android project. It has a Google Places Autocomplete feature which is not working currently as Place SDK for Android it used is deprecated currently. without this everything is working fine but when i am trying to add this places sdk implementation 'com.google.android.libraries.places:places:1.0.0' for auto complete place feature then gradle sync successfully but when try to run the app then it shows error on all xml files as resource linking fails or duplicate value for resource 'attr/font' with config ' etc etc. My question how I can use this sdk without disturbing others. Below is my App level Gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
//buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.myappo"
minSdkVersion 16
targetSdkVersion 25
versionCode 27
versionName "1.5"
manifestPlaceholders = [HOCKEYAPP_APP_ID: "51a9c4471559421b8d53a07cbb3e3fa0"]
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
lintOptions { checkReleaseBuilds false }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
//incremental true
}
repositories {
jcenter()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
useLibrary 'org.apache.http.legacy'
}
allprojects {
repositories {
google()
}
repositories {
maven {
url 'https://maven.google.com'
}
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support:design:25.1.0'
implementation 'com.google.maps.android:android-maps-utils:0.4'
implementation 'com.google.android.gms:play-services:10.0.1'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.hbb20:ccp:1.7.2'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'net.hockeyapp.android:HockeySDK:4.1.3'
implementation 'com.android.support:recyclerview-v7:25.1.1'
implementation 'com.android.support:cardview-v7:25.1.1'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.facebook.android:facebook-android-sdk:4.0.0'
implementation 'com.google.firebase:firebase-messaging:9.6.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.github.krtkush:LinearTimer:v2.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'com.iarcuschin:simpleratingbar:0.1.5'
implementation 'com.paypal.sdk:paypal-android-sdk:2.15.3'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.libraries.places:places:1.0.0' // this is creating problem
}
apply plugin: 'com.google.gms.google-services'
And this is Project level Gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
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 {
jcenter()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
remove bracket from this implementation ("com.google.android.libraries.places:places:1.0.0")
Migrate your project to Android X which is the best solution to prevent the dependency conflict
Migrate to AndroidX

Android Studio - Updating the Version of com.google.android.gms to 11.6.0

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

ClassNotFoundException when referencing Kotlin classes

I try to start migrating a Java based multidexed project to Kotlin but I get ClassNotFoundException whenever the app tries to reference a Kotlin class. The weird thing is that the same code sometimes works sometimes it doesn't. There are computers which produce working apk and others don't. Sometimes a rebuild is enough to solve the problem.
I've tried to google it but I've only found this thread, but there is no resolution. Does this thing work properly for everyone else or aren't there any multidexed Kotlin project yet?
I've tried with AS 2.3.3 and AS 3.0.0-beta6, 2.3.3 android plugun, kotoin version 1.1.50, without proguard.
buildscript {
ext.kotlin_version = '1.1.50'
ext.android_plugin_version = '2.3.3'
ext.support_lib_version = '25.3.1'
ext.play_services_version = '11.0.4'
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath "com.android.tools.build:gradle:$android_plugin_version"
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.google.firebase:firebase-plugins:1.1.1'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
apply plugin: "com.android.application"
apply plugin: "me.tatarka.retrolambda"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "com.google.firebase.firebase-perf"
repositories {
mavenCentral()
jcenter()
maven {
url "https://jitpack.io"
}
}
android {
signingConfigs {
debug {
...
}
}
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.my.app"
signingConfig signingConfigs.debug
minSdkVersion 14
targetSdkVersion 25
versionCode 13
versionName "2.0.1.b8face5"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
testInstrumentationRunner "com.my.app.TestRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//this is because instabug uses rxjava 1 and now we have both 1 and 2 on the classpath
packagingOptions {
exclude "META-INF/rxjava.properties"
}
buildTypes {
debug {
applicationIdSuffix ".debug"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
}
}
}
dependencies {
compile fileTree(include: "*.jar", dir: "libs")
// Force usage of support annotations in the test app, since it is internally used by the runner module.
androidTestCompile("com.android.support.test.espresso:espresso-core:2.2.1") {
exclude module: "support-annotations"
}
androidTestCompile("com.android.support.test.espresso:espresso-contrib:2.2.1") {
// Necessary to avoid version conflicts
exclude group: "com.android.support", module: "appcompat"
exclude group: "com.android.support", module: "support-v4"
exclude group: "com.android.support", module: "support-annotations"
exclude module: "recyclerview-v7"
}
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "com.android.support:appcompat-v7:$support_lib_version"
compile "com.android.support:recyclerview-v7:$support_lib_version"
compile "com.android.support:design:$support_lib_version"
compile "com.android.support:cardview-v7:$support_lib_version"
compile "com.google.android.gms:play-services-auth:$play_services_version"
compile "com.google.android.gms:play-services-identity:$play_services_version"
compile "com.google.android.gms:play-services-location:$play_services_version"
compile "com.google.android.gms:play-services-maps:$play_services_version"
compile "com.google.firebase:firebase-core:$play_services_version"
compile "com.google.firebase:firebase-crash:$play_services_version"
compile "com.google.firebase:firebase-perf:$play_services_version"
compile "com.google.code.gson:gson:2.8.1"
compile "com.google.maps.android:android-maps-utils:0.4"
compile "com.squareup.retrofit2:retrofit:2.3.0"
compile "com.squareup.retrofit2:converter-gson:2.3.0"
compile "com.squareup.retrofit2:adapter-rxjava2:2.3.0"
compile "io.reactivex.rxjava2:rxandroid:2.0.1"
compile "io.reactivex.rxjava2:rxjava:2.1.3"
compile "com.squareup.okhttp3:okhttp-urlconnection:3.8.1"
compile "com.facebook.stetho:stetho:1.5.0"
compile "com.facebook.stetho:stetho-okhttp3:1.5.0"
compile "com.squareup.picasso:picasso:2.5.2"
compile "com.jakewharton:butterknife:8.2.1"
compile "com.annimon:stream:1.1.8"
compile "com.github.lawloretienne:quickreturn:0.0.1"
compile "com.github.chrisbanes:PhotoView:1.2.6"
compile "fr.baloomba:viewpagerindicator:2.4.2"
compile "com.github.bluejamesbond:textjustify-android:2.1.6"
compile "com.turingtechnologies.materialscrollbar:lib:10.1.4"
compile "com.github.PhilJay:MPAndroidChart:v3.0.1"
compile "com.android.support:multidex:1.0.1"
compile "com.bugsnag:bugsnag-android:3.9.0"
//TODO check periodically whether they upgraded to rxjava 2
compile "com.instabug.library:instabug:4.2.11"
testCompile "junit:junit:4.12"
androidTestCompile "com.android.support:support-annotations:$support_lib_version"
androidTestCompile "com.android.support.test:runner:0.5"
androidTestCompile "com.android.support.test:rules:0.5"
annotationProcessor "com.jakewharton:butterknife-compiler:8.2.1"
compile "com.google.dagger:dagger:2.5"
annotationProcessor "com.google.dagger:dagger-compiler:2.5"
provided "javax.annotation:jsr250-api:1.0"
}
apply plugin: "com.google.gms.google-services"
Finally I was able to solve the issue! The exception was caused by a RetroLambda bug and thankfully disappeared after I updated to 3.7.0. The build was nondeterministic because it seems gradle clean doesn't delete everything. After I manually deleted the build folder both in the app and root module, the results became deterministic.
If you are using Java 8 then you should also use Kotlin jre8.
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

Gradle is showing error message on clean build with no clear explanation

App builds and runs successfully but on clean build (not incremental) gradle is showing a error message with no further explanation.
Android Studio version - 2.3.3
Gradle version - 2.3.3
Retro Lambda - 3.6.1
A screen shot is given below:
Project Gradle file
buildscript {
ext.kotlin_version = '1.1.3'
ext.anko_version = '0.10.1'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.project"
minSdkVersion 17
targetSdkVersion 25
versionCode 15
versionName "3.0.1"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
res.srcDirs = [
'src/main/res/layout/member_list2',
'src/main/res/layout/pattern_lock',
'src/main/res/layout/alter',
'src/main/res/layout/member_details',
'src/main/res/layout/maturity_browser',
'src/main/res/layout/mpc_manager',
'src/main/res/layout/settings',
'src/main/res/layout/new_member_account_attached_rcv',
'src/main/res/layout/maturity',
'src/main/res/layout/deposit_browser',
'src/main/res/layout/employee',
'src/main/res/layout/manager',
'src/main/res/layout/deposit',
'src/main/res/layout/controls',
'src/main/res/layout/image_processing',
'src/main/res/layout/selectors',
'src/main/res/layout/zone',
'src/main/res/layout/new_account',
'src/main/res/layout/sync',
'src/main/res/layout/row_views',
'src/main/res/layout/members',
'src/main/res/layout/main',
'src/main/res/layout',
'src/main/res'
]
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
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'
})
compile project(':sqlite-android-3170000')
//compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
//compile 'com.android.support:palette-v7:25.3.1'
compile 'com.github.michaelye.easydialog:easydialog:1.4'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.4'
compile 'com.google.android.gms:play-services-vision:10.2.6'
compile 'com.sothree.slidinguppanel:library:3.3.1'
compile 'it.sephiroth.android.library.bottomnavigation:bottom-navigation:2.0.1-rc1'
compile 'me.zhanghai.android.patternlock:library:2.1.2'
compile 'me.dm7.barcodescanner:zxing:1.9.2'
//compile 'joda-time:joda-time:2.9.9'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
// Anko Layouts
compile "org.jetbrains.anko:anko-sdk25:$anko_version" // sdk15, sdk19, sdk21, sdk23 are also available
compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
// Coroutine listeners for Anko Layouts
compile "org.jetbrains.anko:anko-sdk25-coroutines:$anko_version"
compile "org.jetbrains.anko:anko-appcompat-v7-coroutines:$anko_version"
}
repositories {
mavenCentral()
}
NOTE: Error message appear suddenly few days back and my gradle file was unchanged
In Your Layout file You Use Linear Layout that have retired to define orientation of Linear Layout You Go to Layout File and Set Orientation like
android:orientation = "vertical"
You set Your Orientation According To Your requirement.

Cannot get android-apt working

Twice already I've tried to get android-apt to work, because it's required by the 3rd-party libraries I wanted to use (AndroidAnnotations and PermissionsDispatcher), and both times I bashed my head against the wall until I got tired of hearing the squishing sound.
The problem? Android Studio simply fails to find or fetch the dependencies:
Error:Could not find com.neenbedankt.gradle:plugins:android-apt.
Searched in the following locations:
file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt.pom
file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt-1.8.jar
https://jcenter.bintray.com/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt.pom
https://jcenter.bintray.com/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt-1.8.jar
https://repo1.maven.org/maven2/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt.pom
https://repo1.maven.org/maven2/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt-1.8.jar
Required by:
:MaterialQuoter:unspecified
I'm probably making some sort of ridiculous mistake (I mean, those libraries would not see any use otherwise, right?), but I can't see what I'm doing wrong.
I'm running Android Studio 1.4, in case it's somehow relevant.
This is the gradle file for the project:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle:plugins:android-apt:1.8'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
compile 'com.github.hotchemi:permissionsdispatcher:1.2.1'
apt 'com.github.hotchemi:permissionsdispatcher-processor:1.2.1'
}
This is the gradle file for the module I'm mostly working on:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.callisto.materialquoter"
multiDexEnabled true
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.google.code.findbugs:jsr305:1.3.9'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.github.hotchemi:permissionsdispatcher:1.2.1'
compile 'org.roboguice:roboguice:3.+'
provided 'org.roboguice:roboblender:3.+'
compile 'org.codepond:wizardroid:1.3.0'
compile ('com.octo.android.robospice:robospice:1.4.14') {
exclude group: 'org.apache.commons', module: 'commons-io'
}
compile ('com.octo.android.robospice:robospice-cache:1.4.14') {
exclude group: 'org.apache.commons', module: 'commons-io'
}
compile ('com.octo.android.robospice:robospice-spring-android:1.4.14') {
exclude group: 'org.apache.commons', module: 'commons-io'
}
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
compile 'de.greenrobot:greendao:2.0.0'
}
I had the same problem. This helped me to figure it out.
On the app module itself, add these lines (order is important):
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
dependencies {
compile 'com.github.hotchemi:permissionsdispatcher:1.2.1#aar'
apt 'com.github.hotchemi:permissionsdispatcher-processor:1.2.1'
}
As of the Android Gradle plugin version 2.2, all functionality that was previously provided by android-apt is now available in the Android plugin. This means that android-apt is officially obsolete ;)
Thus,
Make sure you've updated your Gradle plugin to be >= 2.2
Instead of apt use annotationProcessor
Ref: https://bitbucket.org/hvisser/android-apt/wiki/Migration
I figured this way on Android Studio 2.2.1:
This lets me use Butterknife on the main project and also on the library at the same time.
Please note that, on the library, use R2.id.blah instead of R.id.blah when using Butterknife annotations.
Hope works for all.
Also check this link
1) project gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.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
}
2) app graddle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
}
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'
...
//Butterknife https://github.com/JakeWharton/butterknife#library-projects
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
...
}
3) library graddle file
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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'
})
//Butterknife
compile 'com.jakewharton:butterknife-annotations:8.4.0'
compile 'com.jakewharton:butterknife:8.4.0'
...
}

Categories

Resources