Question

I have an Android Studio project that builds and runs just fine, but in the Android Studio editors all my code the depends on jar files is displayed as if it has a compiler error. Here's a screenshot: enter image description here

The structure of my project is

Project
- AndroidApp
- AndroidLibrary
  - build
  - libs
     - acra-4.5.0.jar
     - activation.jar
     - (More jar files)
  - src
     - (library source code)

And here's the contents of the library's build.gradle:

apply plugin: 'android-library'

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.1'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 16
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile files('libs/acra-4.5.0.jar')
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')
    compile files('libs/guava-14.0.1.jar')
    compile files('libs/mail.jar')
    compile files('libs/robotium-solo-5.0.1.jar')
}

The only error I see in idea.log is this

2014-05-06 11:45:08,102 [2933958]   INFO - ellij.vfs.persistent.FSRecords - Creating VFS corruption marker; Trace=
java.lang.Exception
    at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.createBrokenMarkerFile(FSRecords.java:193)
    at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.access$2700(FSRecords.java:136)
    at com.intellij.openapi.vfs.newvfs.persistent.FSRecords.invalidateCaches(FSRecords.java:1613)
    at com.intellij.ide.actions.InvalidateCachesAction.actionPerformed(InvalidateCachesAction.java:65)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:164)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter$1.run(ActionMenuItem.java:266)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:924)
    at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:124)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:236)

How can I make Android Studio recognize my jar files? Any other troubleshooting tips?

Was it helpful?

Solution

I solved this problem by creating a new Java Library Module, and putting all my 3rd party jars in there. I didn't add any java code of my own in that module. Then I made my Android Library module dependent on the the module. My new project structure is

Project
- AndroidApp
- AndroidLibrary
  - build
  - src
     - (library source code)
- Java Library
  - libs
     - acra-4.5.0.jar
     - activation.jar
     - (More jar files)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top