I'm trying to use the new Android Studio but I can't seem to get it working correctly.
(我正在尝试使用新的Android Studio,但我似乎无法让它正常工作。)
I'm using the Gson library to serialize/deserialize JSON-objects.
(我正在使用Gson库来序列化/反序列化JSON对象。)
But the library somehow isn't included in the build. (但是库不知何故不包含在构建中。)
I had created a new project with just a MainActivity .
(我创建了一个只有MainActivity的新项目。)
Copied gson-2.2.3.jar in the /libs folder and added it as a library dependancy(right click->Add as library). (在/ libs文件夹中复制gson-2.2.3.jar并将其添加为库依赖项(右键单击 - >添加为库)。)
This includes the jar in android studio so it can be referenced from the source files. (这包括android studio中的jar,因此可以从源文件中引用它。)
When I try to run the project it cannot compile so I added:
(当我尝试运行该项目时,它无法编译,所以我添加:)
compile files('libs/gson-2.2.3.jar')
to the dependencies in de .gradle file.
(到de .gradle文件中的依赖项。)
After that it compiles correctly but when running the application I get a ClassDefNotFoundException
. (之后它正确编译,但在运行应用程序时,我得到一个ClassDefNotFoundException
。)
Does anyone know what I'm doing wrong?
(有谁知道我做错了什么?)
ask by Ozzie translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…