1

I have checked here and here, but neither solves my problem. I am extending ActionBarActivity after adding v7 appcompat successfully through Gradle.

The issue is that when my Activity extends Activity it works fine. However when I extend ActionBarActivity it crashes with

java.lang.NoClassDefFoundError: com.bignerdranch.android.criminalintent.TestActivity

Here is my activity in manifest:

<activity
    android:name=".TestActivity"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat.Light">
</activity>

Here is my build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.android.support:appcompat-v7:18.0.+'
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 18
    }
}
Community
  • 1
  • 1
Adam Johns
  • 35,397
  • 25
  • 123
  • 176
  • Ok, it is working now. The code is the exact same. The only thing I can think of that I did was delete the libs folder from NameProject/Name/. The strange thing is that it didn't start working right after I did that. It took a few minutes? – Adam Johns Nov 01 '13 at 21:00

2 Answers2

0

Alright, so I've encountered this same problem, and I hope that at least I can add some solutions for anyone who finds this in the future. It looks like Android Studio expects your project to be within a parent directory, so your file structure is something like.

parent dir
    application dir
       app
    settings.gradle

If you're importing a project from Eclipse, then you probably won't have this project structure. I created this same wrapper file structure and then made my settings.gradle have the line include :application-dir. And it worked for me.

I hope this helps someone in the future.

Jonathan
  • 3,369
  • 4
  • 22
  • 27
0

I was also getting same issue.I have downloaded project from Git and same project was working fine on one machine but it was not working on other machine.I was using ActionBarActivity(or you can use AppCompatActivity) and using Library project android-support-v7-appcompat.I was facing same issue and Exception/Error at run time.After lot of troubles i found solution.

You need to check your android-sdk\build-tools directory and check if it is having folder with latest build tool version Example 22.0.1.Else you need to update same using SDK Manager.Check what is the version of the installed build tools if it is older you can download latest build tool version.Now my application is working perfectly fine.

Swapnil
  • 2,409
  • 4
  • 26
  • 48