2

I am using android annotations in Android Studio, and I keep getting the error when running (after successful build), that Default Activity is not found. It comes and goes, and sometimes it just needs a restart of Android Studio, sometimes a clean and rebuild, and sometime it just does not go away (I have no idea of how to reproduce it consistently).

I understand that things are a bit buggy, but how to reproduce this error consistently, and what is a sure step to remove it each time it appears

    <activity
        android:name="com.example.somghosh.earthmiles.views.MainActivity_"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>

build.girdle

buildscript {
    repositories {
        mavenCentral()

    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+'

    }
}


apply plugin: 'com.android.application'
apply plugin: 'android-apt'

repositories {
    mavenCentral()
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
}


android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.example.somghosh.earthmiles"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
}

apt {
    arguments {
        androidManifestFile variant.processResources.manifestFile
        resourcePackageName "com.example.somghosh.earthmiles"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    apt "org.androidannotations:androidannotations:3.2"
    compile 'org.androidannotations:androidannotations-api:3.2'
    //Core
    compile 'com.github.gabrielemariotti.cards:cardslib-core:2.0.1'
    //Optional for built-in cards
    compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.0.1'
    //Optional for RecyclerView
    compile 'com.github.gabrielemariotti.cards:cardslib-recyclerview:2.0.1'
    //Optional for staggered grid view
    compile 'com.github.gabrielemariotti.cards:cardslib-extra-staggeredgrid:2.0.1'
    //Optional for drag and drop
    compile 'com.github.gabrielemariotti.cards:cardslib-extra-dragdrop:2.0.1'
    compile 'in.srain.cube:ultra-ptr:1.0.5'
    compile 'it.neokree:MaterialTabs:0.10'
    compile 'com.android.support:support-annotations:21.0.3'
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.squareup.retrofit:retrofit:1.8.0'
    compile 'com.google.code.gson:gson:2.3.1'
    //    compile 'com.google.code.gson:gson:1.7.2'
    //    compile 'org.parceler:parceler:0.2.15'
    // new for fix
    compile 'org.parceler:parceler-api:0.2.16-SNAPSHOT'
    provided 'org.parceler:parceler:0.2.16-SNAPSHOT'
    compile 'com.squareup.okhttp:okhttp:2.1.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'com.github.siyamed:android-shape-imageview:0.9.2'
    compile 'com.squareup.picasso:picasso:2.4.0'
    provided 'org.projectlombok:lombok:1.14.8'
    apt "org.projectlombok:lombok:1.14.8"
    compile 'com.github.talenguyen:prettysharedpreferences:1.0.2'
    compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
        // exclusion is not neccessary, but generally a good idea.
        exclude group: 'com.google.android', module: 'support-v4'
    }
    compile 'com.afollestad:material-dialogs:0.4.7'
//    compile 'commons-beanutils:commons-beanutils-core:1.8.3'
}
dowjones123
  • 3,695
  • 5
  • 40
  • 83

2 Answers2

2

It seems to be a bug with Android Studio, I have it too. It just seems to forget about the build directory generated by AA and thus the generated classes in it cannot be resolved.

The quickest solution is to open up the Build Variants (View -> Tool Windows -> Build Variants, if it's not on the UI yet), change the build variant of your module (app) from debug to release then back to debug. Android Studio will pick up the changes and resolve the missing classes again.

EDIT: There's an even better solution, check my other answer.

zsolt.kocsi
  • 333
  • 2
  • 12
0

Just change the apt plugin from 1.2 to 1.3 or greater to solve the problem!

classpath "com.neenbedankt.gradle.plugins:android-apt:1.4"
zsolt.kocsi
  • 333
  • 2
  • 12