user3626048
user3626048

Reputation: 736

Weird error after importing project from Eclipse to Android Studio

Since some time I'm was developing Android app in Eclipse (important: settings in Eclipse: Project Build Target: API 19). Yesterday I've imported project to Android Studio. After some problems with dependencies (my app uses a few external libraries) I was able to run app. There is part of my build.gradle file:

compileSdkVersion 22
buildToolsVersion "23.0.0"
defaultConfig {
    applicationId "com.myapp"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    renderscriptTargetApi 22
    renderscriptSupportModeEnabled true

    multiDexEnabled true
}

Unfortunatelly when I run it on my phone with Android 4.4.4 it throws strange error:

java.lang.NoClassDefFoundError: com.myapp.settings.Setting

Setting is my class in app module (main module) so how is it possible?

When I run app in AVD with Android 6.0 it works fine!

When I change compileSdkVersion to 21 it runs on phones with Android 5.0 (emulated or physical) but I can't change to lower compileSdkVersion because one of the dependencies - https://github.com/dbachelder/CreditCardEntry - is using compile 'com.android.support:support-v4:22.1.1' and with older version it shows xml file errors in this library.

What am I doing wrong?


EDIT: I've changed some lines in gradle files and removed CreditCardEntry lib and now I'm getting error:

java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager

when I'm initializing Facebook SDK:

FacebookSdk.sdkInitialize(getApplicationContext());

in main Activity.


EDIT2: I've added Facebook SDK library from repository and above error is solved but my old error is back:

java.lang.NoClassDefFoundError: com.myapp.settings.Setting

Upvotes: 0

Views: 282

Answers (2)

user3626048
user3626048

Reputation: 736

I've solved the problem. The problem was improper initialization of MultiDexApplication. I used this topic to solve it: How to enable multidexing with the new Android Multidex support library

Upvotes: 0

user5375375
user5375375

Reputation:

Download the library.jar file and copy it to your /libs/ folder inside your application project.

Open the build.gradle file and edit your dependencies to include the new .jar file:

Now got to your gradle path and through command prompt clean it.

Upvotes: 1

Related Questions