Android Studio just released , I believe many of my friends , like me, began to try to use its development projects, but new things always encounter this or that problem , which is the most I head into third-party jar package can not be compiled problem , because it is something new and relevant information than less , to solve the problem so I spent quite a long time , in order to avoid further detours colleagues , will address the steps listed here .
1, the jar package into the project in the libs folder.
2, select the jar file in the project right click " Add as library ".
3, these two steps are relatively easy to find online , but this project is still not properly compiled , there will be :
Gradle:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ABetone:compileDebug'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
then need to file in the project 's dependencies section build.gradle join
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/xxxx.jar')
}
4, normal compile and run the project at this time , but when you actually create the code that references jar in the class instance , it is possible the system will throw an exception NoClassDefFoundError, this time you can follow these steps :
- into the Command Prompt window.
- navigate to your project 's root directory , ie the directory where build.gradle .
- Run "{android studio installation directory } \ sdk \ tools \ templates \ gradle \ wrapper \ gradlew.bat" clean
- recompiled to run the project
By the above operation, should be able to solve the problem. PS: I have Windows systems, Linux and Max systems gradlew command path may be not the same.
hope the above can help you solve the problem.
没有评论:
发表评论