Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio upgrade to 0.8.5 leads to Gradle errors

My Gradle was working up until I upgraded to Android Studio 0.8.5. Now the gradle build is broken with the error message:

Error:Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0 (of class java.lang.String)

I am attaching the build.gradle file for reference:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://saturday06.github.io/gradle-android-scala-plugin/repository/snapshot' }
        flatDir {
            dirs 'libs/'
        }
//        flatDir {
//            dirs '/Users/sto/workspace/robolectric-gradle-plugin.sonny/build/libs/'
//        }
//        flatDir {
//            dirs '/Users/sto/workspace/gradle-android-scala-plugin/build/libs/'
//        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
        classpath 'jp.leafytree.gradle:gradle-android-scala-plugin:1.0-SNAPSHOT'
        classpath 'org.robolectric:robolectric-gradle-plugin.sonny:0.12.1'
        classpath "commons-io:commons-io:2.4"
        classpath 'net.lingala.zip4j:zip4j:1.3.2'
    }
}

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs/'
    }
}


apply plugin: 'com.android.application'
apply plugin: 'android-scala'
apply plugin: 'robolectric'

robolectric {
    include '**/*Test*.class'
}

android {
    compileSdkVersion 19
    buildToolsVersion '20.0.0'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName '1.0'
//        testInstrumentationRunner "android.test.InstrumentationTestRunner"
        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }
    packagingOptions {
        exclude 'rootdoc.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'decoder.properties'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'LICENSE.txt'
    }

    sourceSets {
        main {
            java.srcDirs = ['src/main/gen-java', 'src/main/java', 'src/main/scala']
        }
        androidTest.setRoot('src/androidTest/')
        androidTest {
            java.srcDirs = ['src/androidTest/scala', 'src/androidTest/java']
        }
    }

    android {
        lintOptions {
            abortOnError false
        }
    }

    buildTypes {
        debug {
            runProguard true
            proguardFile file('proguard-rules-debug.txt')
        }
        release {
            runProguard true
            proguardFile file('proguard-rules.txt')
        }
    }
}

dependencies {
    compile project(':swiper')
    compile 'org.scala-lang:scala-library:2.11.2'
    compile 'org.json4s:json4s-native_2.11:3.2.10'
    compile 'com.google.android.gms:play-services:4.0.30'
    compile 'com.google.android:android:4.1.1.4'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
    compile 'com.loopj.android:android-async-http:1.4.4'
    compile 'com.edmodo:cropper:1.0.1'
    compile 'de.hdodenhof:circleimageview:1.1.1'
    compile 'org.fusesource.mqtt-client:mqtt-client:1.10'
    compile 'log4j:log4j:1.2.17'
    compile 'de.mindpipe.android:android-logging-log4j:1.0.3'
    compile('org.apache.thrift:libthrift:0.9.1') {
        transitive = false
    }
    compile 'ch.hsr:geohash:1.0.10'
    compile 'org.slf4j:slf4j-android:1.7.7'

    androidTestCompile('junit:junit:4.11') {
//        exclude module: 'hamcrest-core'
    }
    androidTestCompile('org.robolectric:robolectric:2.3') {
        exclude module: 'classworlds'
        exclude module: 'commons-logging'
        exclude module: 'httpclient'
        exclude module: 'maven-artifact'
        exclude module: 'maven-artifact-manager'
        exclude module: 'maven-error-diagnostics'
        exclude module: 'maven-model'
        exclude module: 'maven-project'
        exclude module: 'maven-settings'
        exclude module: 'plexus-container-default'
        exclude module: 'plexus-interpolation'
        exclude module: 'plexus-utils'
        exclude module: 'wagon-file'
        exclude module: 'wagon-http-lightweight'
        exclude module: 'wagon-provider-api'
    }

}

I am still able to build using gradle (v1.12) from command line, but without using Studio I can't set my usual breakpoints for debug.

like image 700
ShayakB Avatar asked Aug 13 '26 15:08

ShayakB


1 Answers

Update:

Turns out what was causing this issue for me (and likely for you, given the build file above) was the Scala plugin. There was a bug with the Scala plugin preventing Android Studio from importing Gradle projects. The fix for this has already been pushed live, so to get Android Studio working again you can either disable the Scala plugin or update it.

  1. Open Settings/Preferences
  2. Open the Plugins section on the left
  3. Find the Scala plugin
  4. Right click on the plugin and click Reload List of Plugins
  5. Right click on the plugin again and click Update Plugin

This allowed me to do a Gradle sync and build from Android Studio again, I hope it helps for you!

Original answer below:

It looks like this is a bug with Android Studio. Hopefully it'll be fixed soon.

In the meantime, you can debug your application without launching it from Android Studio by attaching the debugger to a running process of the application. You can do this two ways.

  • Via the menus: Run -> Attach Debugger to Android Process
  • Pressing the button that is two to the right of the play/build button. It looks like a grey phone/rectangle with a little green bug in the bottom right

After you do this, a dialog will show up listing available applications to debug. Select your application and press OK. Your breakpoints should now work.

If you need to debug something that happens on app startup, you can tell Android to wait for a debugger when launching certain applications with the following steps:

  1. On the phone open the Android Settings
  2. Open the Developer Options
  3. Make sure Wait for debugger is checked
  4. Press Select debug app and choose your application

Then when you start your application, it'll wait for you to attach a debugger via one of the two methods mentioned above.

Hope this helps!

like image 191
FuegoFro Avatar answered Aug 15 '26 06:08

FuegoFro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!