我想编译我的应用程序时遇到问题:
UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added`
看来是android-support-v4.jar的错误。
在我的项目中,我有 3 个库:appcompat、facebook、google_play_services。
我的 gradle 文件:
AppProject/settings.gradle
include ':libraries:google_play_services', ':libraries:appcompat', ':libraries:facebook', ':app'
AppProject/build.gradle :
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } }
AppProject/app/build.gradle:
apply plugin: 'android' dependencies { compile project(':libraries:appcompat') compile project(':libraries:facebook') compile project(':libraries:google_play_services') compile files('libs/android-async-http-1.4.3.jar') compile files('libs/gson-2.2.4.jar') compile files('libs/libGoogleAnalyticsV2.jar') compile files('libs/universal-image-loader-1.8.4.jar') compile files('libs/urbanairship-lib-3.0.0.jar') }
AppProject/libraries/appcompat/build.gradle:
apply plugin: 'android-library' dependencies { compile files('libs/android-support-v4.jar') compile files('libs/android-support-v7-appcompat.jar') }
AppProject/libraries/facebook/buidle.gradle:
apply plugin: 'android-library' dependencies { compile files('libs/android-support-v4.jar') }
AppProject/libraries/google_play_services/buidle.gradle:
apply plugin: 'android-library' dependencies { compile files('libs/google-play-services.jar') }
但是我编译的时候出现了这个错误:
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/NotificationCompatIceCreamSandwich;
你能帮帮我吗?
最佳答案
我发现了问题:
AppProject/settings.gradle
include ':libraries:facebook', ':app'
AppProject/libraries/facebook/build.gradle
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
AppProject/app/build.gradle
apply plugin: 'android'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.google.android.gms:play-services:3.1.36'
compile project(':libraries:facebook')
compile files('libs/android-async-http-1.4.3.jar')
compile files('libs/gson-2.2.4.jar')
compile files('libs/libGoogleAnalyticsV2.jar')
compile files('libs/universal-image-loader-1.8.4.jar')
compile files('libs/urbanairship-lib-3.0.0.jar')
}
关于android - android-support-v4.jar 中的意外顶级异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17947769/