当我将JsonPath库添加到我的Android Studio(1.4)项目时,出现以下错误:
Error:Execution failed for task ':app:dexDebug'. \>
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException:
Process 'command 'C:\Program Files\JDK_64_bit\bin\java.exe'' finished with
non-zero exit value 2
(我通过文件>项目结构>依赖关系>库依赖关系添加了库> com.jayway.jsonpath:json-path:2.0.0 )
尝试根据其他一些问题建议为应用添加MultiDex支持会导致不同的错误:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. \>
java.util.zip.ZipException: duplicate entry:
org/objectweb/asm/AnnotationVisitor.class
我的项目中的外部库列出了asm-1.0.2和asm-3.3.1,但删除其中一个或两个都无法解决我的问题。
的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.REDACTED.REDACTED"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.jayway.jsonpath:json-path:2.0.0'
compile 'com.android.support:multidex:1.0.1'
}
app.iml (图书馆):
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="butterknife-7.0.1" level="project" />
<orderEntry type="library" exported="" name="asm-3.3.1" level="project" />
<orderEntry type="library" exported="" name="multidex-1.0.1" level="project" />
<orderEntry type="library" exported="" name="json-path-2.0.0" level="project" />
<orderEntry type="library" exported="" name="asm-1.0.2" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="slf4j-api-1.7.10" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" name="json-smart-2.1.1" level="project" />
的AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.REDACTED.REDACTED" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
非常感谢你!
答案 0 :(得分:0)
如果您添加compile 'net.minidev:json-smart:2.2'
,问题将得到解决。
有关该问题的更多背景信息,请参阅https://github.com/jayway/JsonPath/issues/116和https://github.com/jayway/JsonPath/pull/108。尚未发布的2.1.0
版本json-path
将指向2.2
版json-smart
,解决此问题。在此之前,上述解决方法是必要的。
答案 1 :(得分:0)
添加以下代码:
defaultConfig {
multiDexEnabled true
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
dexOptions {
javaMaxHeapSize "4g"
}