问题描述
我对我的 Android Studio IDE 快要疯了.
我愿意从 Central (v2.7.1) 添加 Maven 库 simple-xml
项目编译良好p>
Gradle 在它的
build.gradle
中有 lib 依赖:依赖项{编译'com.android.support:appcompat-v7:18.0.0'编译'org.simpleframework:simple-xml:2.7.1'}
在 Android Studio 的模块设置中为 simple-xml 库检查导出:
这里的截图:https://s6.postimg.cc/xxgj56zkx/Module_Settings.png
当我运行我的应用程序时,我找不到类......
java.lang.NoClassDefFoundError: org.simpleframework.xml.core.Persister
我迷路了,听起来 Gradle 由于某些原因没有在 apk 中打包 lib 和依赖项......
Edit1:我的 Android Studio 版本是 0.2.13(最新),Gradle 0.5.+
Edit2:我使用的完整 build.gradle
buildscript {存储库{MavenCentral()}依赖{类路径 'com.android.tools.build:gradle:0.5.+'}}应用插件:'android'存储库{MavenCentral()}安卓 {compileSdkVersion 17构建工具版本17.0.0"默认配置{minSdk 版本 14目标SDK版本18}}依赖{编译'com.android.support:appcompat-v7:18.0.0'编译'org.simpleframework:simple-xml:2.7.1'}
我发现了问题.
正如我所料,这是 graddle 插件 0.5.+.
带有 gradle 插件 0.6.+ (Gradle 1.8) 的 Android Studio 0.3.0 现在修复了这个问题.
但是,我使应用程序以这种方式与 Android Studio 0.2.13 和 gradle 插件 0.5 配合使用:
由于 gradle 插件拒绝从 maven central 部署库,我将库和依赖项下载到我的项目的 lib 目录中.我将项目设置为使用该库作为项目 lib 目录中的本地库.
解决方法的说明:
在模块设置中删除我项目中对 simple-xml(maven 中心)的所有引用
将 simple-xml-2.7.1.jar、stax-1.2.0.jar、stax-api-1.0.1.jar 和 xpp3-1.1.3.3.jar 复制到我的项目中的 lib 目录
在我的项目中选择 lib simple-xml-2.7.1.jar 并使用 Add as Library 上下文菜单导入 lib
像这样更改 build.gradle:
依赖项{
编译'com.android.support:appcompat-v7:18.0.0'编译文件('simple-xml-2.7.1.jar')
}
注意:不要包含依赖项,否则会与 Grzegorz 提到的 Android 系统产生冲突
I am going crazy with my Android Studio IDE.
I am willing to add the Maven library simple-xml from Central (v2.7.1)
The project compiles well
Gradle has the lib dependency in its
build.gradle
:dependencies { compile 'com.android.support:appcompat-v7:18.0.0' compile 'org.simpleframework:simple-xml:2.7.1' }
Export is checked in Android Studio's Module Settings for the simple-xml lib:
Screenshot here: https://s6.postimg.cc/xxgj56zkx/Module_Settings.png
And I got the Class not found when I run my app ...
I am lost, It sounds like Gradle doesn't pack the lib and dependencies in the apk for some reasons ...
Edit1: my Android Studio version is 0.2.13 (latest), Gradle 0.5.+
Edit2: full build.gradle I use
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'org.simpleframework:simple-xml:2.7.1'
}
I found the problem.
It was the graddle plugin 0.5.+ as I expected.
The Android Studio 0.3.0 with gradle plugin 0.6.+ (Gradle 1.8) now fixes the problem.
However, I made the application to work with the Android Studio 0.2.13 and gradle plugin 0.5 this way:
As the gradle plugin refuses to deploy the library from maven central, I downloaded the library and dependencies to the lib directory of my project.I setup the project to use the library as a local one in the lib directory of the project.
Directions for the workaround:
remove all references in my project to simple-xml (maven central) in Module Settings
Copy simple-xml-2.7.1.jar, stax-1.2.0.jar, stax-api-1.0.1.jar and xpp3-1.1.3.3.jar to lib directory in my project
Select the lib simple-xml-2.7.1.jar in my project and Import the lib using Add as Library contextual menu
Change the build.gradle like this:
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0' compile files('simple-xml-2.7.1.jar')
}
Note: do not include the dependencies, otherwise they will create conflicts with the Android system as mentionned by Grzegorz
这篇关于Android Studio - 导入 Simple-Xml 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!