Android Studio - 在AddThis.jar上崩溃的应用程序 - “未找到来源”消息

时间:2014-09-21 21:48:36

标签: android jar android-studio addthis

我有一个使用AddThis SDK的项目。我已将AddThis.jar作为库添加到Android Studio中的项目中。

当我点击发布到Facebook的按钮时,应用程序崩溃了这个日志:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.apploi/com.addthis.ui.activities.ATActivityGroup}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.apploi/com.addthis.ui.activities.ATShareActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x0
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.apploi/com.addthis.ui.activities.ATShareActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x0
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
            at android.app.ActivityThread.startActivityNow(ActivityThread.java:2035)
            at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
            at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
            at com.addthis.ui.activities.ATActivityGroup.showNextView(ATActivityGroup.java:167)
            at com.addthis.ui.activities.ATActivityGroup.loadViews(ATActivityGroup.java:99)
            at com.addthis.ui.activities.ATActivityGroup.onCreate(ATActivityGroup.java:78)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
            at android.content.res.Resources.getValue(Resources.java:1123)
            at android.content.res.Resources.loadXmlResourceParser(Resources.java:2309)
            at android.content.res.Resources.getLayout(Resources.java:939)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:395)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
            at android.app.Activity.setContentView(Activity.java:1929)
            at com.addthis.ui.activities.ATShareActivity.onCreate(ATShareActivity.java:66)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
            at android.app.ActivityThread.startActivityNow(ActivityThread.java:2035)
            at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
            at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
            at com.addthis.ui.activities.ATActivityGroup.showNextView(ATActivityGroup.java:167)
            at com.addthis.ui.activities.ATActivityGroup.loadViews(ATActivityGroup.java:99)
            at com.addthis.ui.activities.ATActivityGroup.onCreate(ATActivityGroup.java:78)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
Connection reset by peer

据我所知,这句话说ATShareActivity存在问题。 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.apploi/com.addthis.ui.activities.ATShareActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x0

当我导航到AddThis.jar并打开ATShareActivity文件(或jar文件中的任何其他文件)时,屏幕顶部会显示一条消息,说“找不到来源”,标题为Attach Sources...

的可点击链接

我打开Attach Sources...链接,它允许我选择一个目录,但我不知道我应该在这里做什么。

对此有任何想法将不胜感激。

1 个答案:

答案 0 :(得分:1)

感谢您的提示。以下是最终工作的结果:

1)将AddThis转换为Gradle

File > Import Project...AddThisSDK转换为Gradle项目。这创建了一个新项目,我将其命名为AddThisGradle

1B)如果您已经安装了Facebook SDK

打开终端并在新AddThisGradle目录中导航到AddThisGradle/app/libs

在终端中使用命令zip -d addthis0.0.8.jar com/facebook/*addthis0.0.8.jar

中删除Facebook文件

回到Android Studio,检查Facebook目录是否从AddThisGradle消失了

回到Android Studio

中我的主要项目

2)将AddThis添加到项目中

File > Project Structure

中的主项目中选择了Android Studio

按下“项目结构”屏幕左上角的+

出现New Module屏幕

Import Existing Project屏幕中选择New Module

选择AddThisGradle作为source directory

选中import复选框

module name更改为:addthis

点击Finish按钮

等待gradle重新同步

3)添加依赖

返回Project Structure屏幕

app屏幕的左栏中选择Project Structure

选择Dependencies标签

点击+标签屏幕底部的Dependencies按钮

选择+ > 3 Module Dependency

出现Choose Module屏幕

选择:addthis模块

等待gradle重新同步

4)继续尝试

此时,一切看起来都不错,除非我试图运行应用程序时遇到错误Execution failed for task ':app:dexDebug’。我使用了此问题的第一个建议来解决我的问题:Gradle Execution failed for task ':app:dexDebug' with new Android Studio Project