2012-06-21 68 views
1

我在2個月前發佈了一個應用程序,有時候,我收到了來自用戶的一些錯誤。Android:NoClassDefFoundError對於某些應用程序用戶

這裏是日誌:

java.lang.NoClassDefFoundError: android.os.StrictMode$ThreadPolicy$Builder 
at mdpi.android.MDPIActivity.onCreate(MDPIActivity.java:132) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:123) 
at android.app.ActivityThread.main(ActivityThread.java:4627) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:521) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 
at dalvik.system.NativeStart.main(Native Method) 

奇怪的是,在測試時,我新收到此錯誤,並在那一刻,有大約這個問題的其他用戶6個repports。

這裏是我的清單:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="mdpi.android" 
android:versionCode="4" 
android:versionName="2.1" 
android:installLocation="auto"> 

<uses-sdk android:minSdkVersion="8" /> 

<application 
    android:icon="@drawable/app_icon" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.Black"> 
    android:debuggable=false 


    <activity 
     android:name=".WelcomeScreen" 
     android:configChanges="orientation|keyboardHidden" 
     android:label="@string/app_name" > 

     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter>  
    </activity> 

    <activity android:name=".MDPIActivity" 
     android:configChanges="keyboardHidden|orientation"></activity> 

    <activity android:name=".UserSubmission" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".UserProfile" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".UserInformations" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".UserForgotPassword" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".UserRegistration" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".UserSubmissions" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".UserSubmissionLog" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".UserEmailNotifications"></activity> 
    <activity android:name=".Journals" 
     android:configChanges="keyboardHidden|orientation"></activity> 

    <activity android:name=".JournalsAdding" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".JournalAimsAndScope" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".JournalEditorialBoard" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".JournalContact" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".JournalArticles" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".JournalArticleInfo" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".JournalArticlesVolumeIssuesSelection"></activity> 

    <activity android:name=".MDPI_About" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".MDPI_About_About" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".MDPI_About_Contact" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".User_Registration_Country_Choosing"></activity> 

    <activity android:name=".MDPI_About_OpenAccess" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".UserLoging" 
     android:configChanges="keyboardHidden|orientation"></activity> 

    <activity 
     android:name=".JournalSelectingDialog" 
     android:theme="@android:style/Theme.Dialog" 
     android:configChanges="orientation|keyboardHidden"></activity> 

    <activity android:name=".UserProfileEditing" 
     android:configChanges="orientation|keyboardHidden" 
     android:windowSoftInputMode="stateHidden"></activity> 

    <activity android:name=".User_EditProfile_Country_Choosing" 
     android:configChanges="orientation|keyboardHidden"> 
    </activity> 

    <activity android:name=".JournalsDeleting" 
     android:configChanges="orientation|keyboardHidden"> 
     </activity> 

     <activity android:name=".Highlights" 
     android:configChanges="orientation|keyboardHidden"> 
     </activity> 

     <activity android:name=".Highlights_News" 
     android:configChanges="orientation|keyboardHidden"> 
     </activity> 

     <activity android:name=".Highlights_News_Informations" 
     android:configChanges="orientation|keyboardHidden"> 
     </activity> 

     <activity android:name=".Highlights_NewSpecialIssues" 
     android:configChanges="orientation|keyboardHidden"> 
     </activity> 

     <activity android:name=".Highlights_NewSpecialIssue_Informations" 
     android:configChanges="orientation|keyboardHidden"> 
     </activity> 

     <activity android:name=".Search" 
     android:configChanges="orientation|keyboardHidden"> 
      <intent-filter> 
     <action android:name="android.intent.action.SEARCH" /> 
     </intent-filter> 
     <meta-data android:name="android.app.searchable" 
       android:resource="@xml/searchable"/> 
     </activity> 


     <activity android:name=".SearchInterface" 
     android:configChanges="orientation|keyboardHidden"> 
     <meta-data android:name="android.app.default_searchable" 
       android:value=".Search" /> 
     </activity> 

      <activity android:name=".SpecialIssueInformations" 
     android:configChanges="orientation|keyboardHidden"> 
     </activity> 

      <activity android:name=".ArticlesFromAuthor" 
     android:configChanges="orientation|keyboardHidden"> 
     </activity> 

      <activity android:name=".ChangeWallpaper" 
     android:configChanges="orientation|keyboardHidden"> 
     </activity> 



</application> 
    <uses-permission android:name="android.permission.INTERNET"></uses-permission> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

+0

看到這個[鏈接](http://stackoverflow.com/questions/8575617/i-dont-know-how-to-solve-android-os-networkonmainthreadexception)也 –

+0

你應該發佈你的清單。你在你的應用中使用StrictMode.ThreadPolicy嗎?你在UI線程上做網絡嗎? –

+0

謝謝@VivekKumarSrivastava,正常情況下,我在每個活動中都禁用嚴格模式。 –

回答

5

嚴格模式是在API級別9中引入,並且您已在清單中將8個設置爲最小值。這些可能來自運行2.2.x(API級別8)的用戶。

+0

我有一個來自用戶的消息:MDPI不工作,它會關閉而不會打開:galaxy選項卡。 ü認爲星系標籤是3.0? –

+0

最初的銀河標籤跑2.2(Froyo),所以他們最有可能有同樣的問題,如你所述。 – nmw

+0

啊,好的。因此,如果我將使用:if(android.os.Build.VERSION.SDK_INT> 9){StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()。permitAll()。build(); StrictMode.setThreadPolicy(policy); } 而不是直接禁用嚴格模式,這個shuld解決問題 –

1

在Android的薑餅以下(API 9)StrictMode不存在。所以當導入庫或使用StrictMode代碼時,Activity會拋出一個異常。

可能是它的工作原理以下解決方法幫助(在僞代碼):

在活動

if(9 >= android.os.Build.VERSION.SDK_INT){ 
StrictModeHelper.disable(); 
} 

外部類

(這裏只導入strictmode LIB)

class StrictModeHelper{ 
    public static disable(){ 
    // do disable strict mode stuff 
    } 
} 
+0

我收到用戶發來的消息:「MDPI不能工作,它會關閉而不會打開:galaxy選項卡」。 ü認爲星系標籤是3.0? –

+0

你有沒有用android <2.3測試你的應用程序? (Galaxy Tab是2.2) – MemLeak

+0

不是真的,非常感謝你的答案。 –

相關問題