Android Studio 1.0 - 与外部库项目“本地路径不存在”

时间:2014-12-16 13:21:00

标签: android gradle android-studio library-project

即使是“Studio Android 0.8.x”,我也可以将外部库项目作为我项目的模块。

settings.gradle档案中:

include ':app'

// sinapse library
include ':SinapseLibrary2.1'
project(':SinapseLibrary2.1').projectDir = new File('/Users/douglas/AndroidStudioProjects/SinapseLibrary2.1/library')

0.9.x版之后是不可能的。当我运行应用程序时,我收到以下消息。

我在其他几个项目中使用相同的项目库。

这是一个错误,还是有其他选择?

enter image description here

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild
:app:compileDebugNdk UP-TO-DATE
:SinapseLibrary2.1:compileLint
:SinapseLibrary2.1:copyReleaseLint UP-TO-DATE
:SinapseLibrary2.1:mergeReleaseProguardFiles UP-TO-DATE
:SinapseLibrary2.1:preBuild
:SinapseLibrary2.1:preReleaseBuild
:SinapseLibrary2.1:checkReleaseManifest
:SinapseLibrary2.1:prepareReleaseDependencies
:SinapseLibrary2.1:compileReleaseAidl UP-TO-DATE
:SinapseLibrary2.1:compileReleaseRenderscript UP-TO-DATE
:SinapseLibrary2.1:generateReleaseBuildConfig UP-TO-DATE
:SinapseLibrary2.1:generateReleaseAssets UP-TO-DATE
:SinapseLibrary2.1:mergeReleaseAssets UP-TO-DATE
:SinapseLibrary2.1:generateReleaseResValues UP-TO-DATE
:SinapseLibrary2.1:generateReleaseResources UP-TO-DATE
:SinapseLibrary2.1:packageReleaseResources UP-TO-DATE
:SinapseLibrary2.1:processReleaseManifest UP-TO-DATE
:SinapseLibrary2.1:processReleaseResources UP-TO-DATE
:SinapseLibrary2.1:generateReleaseSources UP-TO-DATE
:SinapseLibrary2.1:compileReleaseJava UP-TO-DATE
:SinapseLibrary2.1:processReleaseJavaRes UP-TO-DATE
:SinapseLibrary2.1:packageReleaseJar UP-TO-DATE
:SinapseLibrary2.1:compileReleaseNdk UP-TO-DATE
:SinapseLibrary2.1:packageReleaseJniLibs UP-TO-DATE
:SinapseLibrary2.1:packageReleaseLocalJar UP-TO-DATE
:SinapseLibrary2.1:packageReleaseRenderscript UP-TO-DATE
:SinapseLibrary2.1:bundleRelease UP-TO-DATE
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:app:prepareCromoledRemoteControlSinapseLibrary21UnspecifiedLibrary UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:preDexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
...while parsing br/ind/sinapse/library/BuildConfig.class
1 error; aborting
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/douglas/ferramentas/adt-bundle-mac-x86_64-20140702/build-tools/21.1.2/dx --dex --output /Users/douglas/AndroidStudioProjects/CromoledRemoteControl/app/build/intermediates/pre-dexed/debug/classes-b4d0e7e6eb67c94397ec32d2b0a00147807d74d7.jar /Users/douglas/AndroidStudioProjects/CromoledRemoteControl/app/build/intermediates/exploded-aar/CromoledRemoteControl/SinapseLibrary2.1/unspecified/classes.jar
  Error Code:
    1
  Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
        at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
        at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
        at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
        at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
        at com.android.dx.command.dexer.Main.processClass(Main.java:704)
        at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
        at com.android.dx.command.dexer.Main.access$300(Main.java:83)
        at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
        at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
        at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
        at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
        at com.android.dx.command.dexer.Main.processOne(Main.java:632)
        at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
        at com.android.dx.command.dexer.Main.run(Main.java:246)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)
    ...while parsing br/ind/sinapse/library/BuildConfig.class
    1 error; aborting
Information:BUILD FAILED
Information:Total time: 2.351 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

2 个答案:

答案 0 :(得分:0)

不太确定,但我遇到了类似的错误消息“本地路径不存在”。

我的问题通过使用工具栏上的按钮执行“使用Gradle文件同步项目”来解决。

答案 1 :(得分:0)

谢谢你的关注。最后解决了这个问题,但我无法理解原因是什么。

我解除了使用" Android 0.8.x Studio"版本的项目更改。然后在" Android Studio 1.0.1"中再次导入。更新了proguard参数等。

现在没事了。谢谢。