我有一个Android Studio项目,可以很好地构建和运行,但是在Android Studio编辑器中,所有依赖于jar文件的代码都显示为具有编译器错误。这是一个截图:
我的项目结构是
Project
- AndroidApp
- AndroidLibrary
- build
- libs
- acra-4.5.0.jar
- activation.jar
- (More jar files)
- src
- (library source code)
这里是图书馆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')
}
我在idea.log中看到的唯一错误就是这个
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)
如何让Android Studio识别我的jar文件?还有其他任何疑难解答提示吗?
答案 0 :(得分:0)
我通过创建一个新的Java库模块并将所有第三方jar放在那里来解决这个问题。我没有在该模块中添加我自己的任何java代码。然后我使我的Android库模块依赖于该模块。我的新项目结构是
Project
- AndroidApp
- AndroidLibrary
- build
- src
- (library source code)
- Java Library
- libs
- acra-4.5.0.jar
- activation.jar
- (More jar files)