JAR libraries not being detected

痞子三分冷 提交于 2019-12-24 09:46:57

问题


I created a fresh project in Android Studio which uses external library (JAR). I put this in modules's build.gradle:

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('libs/mylib.jar')
}

But, when using Android Studio editor, it says there are some errors in my code and marks imports and variables (which use this library). It doesn't build properly saying that it cannot find one or another class. However, when I go to project's directory in terminal and execute gradlew manually, it builds APK and it (the APK) install and works just fine.

What am I missing? Is there any another setting in my project which is used for library detection?


回答1:


Android Studio currently does not automatically sync your Gradle build files with your Android Studio (.iml) files. However, version 0.1.3 added a new sync button to the toolbar that will do this manually.

It's mentioned in the second bullet point of this blog post.

There were a lot of fixes in the Gradle project import and build areas. There is now a "sync" button in the toolbar which will reimport the Gradle project state into your Android Studio project. Use this after editing your Gradle files, for example to add a library. In the future we will more automatically handle state syncing, but for now this is the simplest way to keep the IDE up to date with project structure changes made to the Gradle files.



来源:https://stackoverflow.com/questions/17062130/jar-libraries-not-being-detected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!