0
我需要將android項目轉換爲包含所有類和資源的.jar文件。我們可以選擇執行此操作嗎?我試圖通過轉換到android庫項目,然後到jar文件。它總是顯示空指針異常。如何將android庫項目轉換爲.jar文件與所有類和資源?
我需要將android項目轉換爲包含所有類和資源的.jar文件。我們可以選擇執行此操作嗎?我試圖通過轉換到android庫項目,然後到jar文件。它總是顯示空指針異常。如何將android庫項目轉換爲.jar文件與所有類和資源?
如果庫是純Java代碼,沒有資源,你可以創建一個JAR出來的.class文件,就像你會與常規的Java:
1. Right click the project.
2. Export --> Java --> JAR file.
3. Tick the files to include and name the jar, click "Next".
一步一步的細節櫃面的java見this。 對於android看到這個ans。
You cannot export the library project to a self-contained JAR file, as you would do for
a true library. Instead, you must compile the library indirectly, by referencing
the library in the dependent application and building that application.
編輯:
對於使用該庫的可繪製看this。
是的,我已經更新了我的答案。 – 2014-12-08 09:24:49
我的庫包含更多drawables和xml佈局。我們可以創建jar並在其他項目上使用它? – user3305353 2014-12-08 09:32:45
無法爲android創建jar,請參閱http://stackoverflow.com/q/7973822/3879470,但是如果您將項目設爲庫,則可以像使用其他java項目一樣使用它的類。 – 2014-12-08 10:18:59