2013-10-21 36 views
0

我創建的Android的lib罐子,我把lib文件夾在我的測試應用程序,我開始這JAR文件,但我收到以下錯誤如何引用佈局文件中的外部jar

10-22 00:14:59.349: E/AndroidRuntime(670): FATAL EXCEPTION: main 
10-22 00:14:59.349: E/AndroidRuntime(670): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testapplication/com.example.test.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/ic_launcher.png from xml type layout resource ID #0x7f020000 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.os.Handler.dispatchMessage(Handler.java:99) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.os.Looper.loop(Looper.java:130) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.app.ActivityThread.main(ActivityThread.java:3683) 
10-22 00:14:59.349: E/AndroidRuntime(670): at java.lang.reflect.Method.invokeNative(Native Method) 
10-22 00:14:59.349: E/AndroidRuntime(670): at java.lang.reflect.Method.invoke(Method.java:507) 
10-22 00:14:59.349: E/AndroidRuntime(670): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
10-22 00:14:59.349: E/AndroidRuntime(670): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
10-22 00:14:59.349: E/AndroidRuntime(670): at dalvik.system.NativeStart.main(Native Method) 
10-22 00:14:59.349: E/AndroidRuntime(670): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/ic_launcher.png from xml type layout resource ID #0x7f020000 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1916) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1871) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.content.res.Resources.getLayout(Resources.java:731) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
10-22 00:14:59.349: E/AndroidRuntime(670): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.app.Activity.setContentView(Activity.java:1657) 
10-22 00:14:59.349: E/AndroidRuntime(670): at com.example.test.MainActivity.onCreate(MainActivity.java:12) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 
10-22 00:14:59.349: E/AndroidRuntime(670): ... 11 more 
10-22 00:14:59.349: E/AndroidRuntime(670): Caused by: java.io.FileNotFoundException: Corrupt XML binary file 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.content.res.AssetManager.openXmlAssetNative(Native Method) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:486) 
10-22 00:14:59.349: E/AndroidRuntime(670): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1898) 
10-22 00:14:59.349: E/AndroidRuntime(670): ... 20 more 

請幫我一個活動修復這個問題對不起我的英語不好

+0

你使用eclipse嗎? –

+0

是的,我使用eclipse juno – SelvaMariappan

+0

請嘗試以下操作:右鍵單擊項目>構建路徑>配置構建路徑>訂單和導出>檢查([x])您的庫,並嘗試它是src文件夾上面 –

回答

3

你不能將庫導出到jar,因爲你不能把你的資源放到jar裏。這就是你得到Resources#NotFoundException的原因。這就是docs說:

您可以將庫項目不能導出到一個獨立的JAR文件,如 你會爲一個真正的圖書館做。相反,您必須通過引用從屬應用程序 中的庫並構建該應用程序來間接編譯庫 。

+0

任何方式轉換lib項目作爲jar如果有任何例子意味着要提到bcoz我需要隱藏src – SelvaMariappan

+0

你可以將它導出到aar。 [看到這個](http://stackoverflow.com/questions/16763090/how-to-export-library-to-jar-in-android-studio)。 – Ahmad

相關問題