Android Studio: IncorrectOperationException when 'Add as Library' is clicked whilst trying to configure Google Apps Endpoints client libraries

♀尐吖头ヾ 提交于 2019-12-06 07:59:45

问题


I am trying to generate and use the android client libraries for a Python google app engine project following this guide https://developers.google.com/appengine/docs/python/endpoints/consume_android

Everytime I get to this step

Select the library you just added, right-click, then select Add As Library to your project.

I get the following exception:

IncorrectOperationException: Must not change document outside command or undo-transparent action.

I'm new to Android Studio but can't seem to find any resources on how to get endpoints client libraries working in Eclipse. Has anyone else experienced this problem?


回答1:


This is a temporary bug in Android Studio. Instead of using the Add as Library option (which wouldn't work anyway due to https://code.google.com/p/android/issues/detail?id=66610), instead go to File > Project Structure > Modules > your module > Dependencies > + button, File dependency, and select your jar from the file chooser.




回答2:


I encountered the same Incorrect Operation Exception in Android Studio version 0.5.0.

This post helped me: How do I add a library project to Android Studio?

To add your endpoints client library as library to your project, you can manually add your library to the Gradle project, in the settings.gradle file:

  1. Open settings.gradle, which should be in the root of your Android Studio project.

  2. Add the directory, that contains your jar file, which you want to use as a library to the settings.gradle file, like so:

    include ':initial_module', ':libraries:lib1', ':libraries:lib2'

    here are lib1 and lib2 the names of the directories that contain the jar file which i want to use as a library and the :libraries is the directive to treat it as library.

  3. Gradle needs to be synced to pick up the newly added libraries.



来源:https://stackoverflow.com/questions/22259669/android-studio-incorrectoperationexception-when-add-as-library-is-clicked-whi

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