2017-01-16 15 views
-2

真minifyEnabled:NumberFormatExceptionが起動中のアプリは、後に、私はこの問題への解決策を探していた

01-16 12:29:55.975 1199-1334/com.zztproject.curlife E/AndroidRuntime: FATAL EXCEPTION: Thread-16992 
                    Process: com.zztproject.curlife, PID: 1199 
                    java.lang.NumberFormatException: Invalid int: "null" 
                     at java.lang.Integer.invalidInt(Integer.java:138) 
                     at java.lang.Integer.parseInt(Integer.java:358) 
                     at java.lang.Integer.parseInt(Integer.java:334) 
                     at com.zztproject.curlife.HomeActivity$a.run(Unknown Source) 

が、私はこの問題は真minifyEnabled によって引き起こされていることが分かりました。私のGradleファイル(フラグメント):

buildTypes { 
    debug { 
     minifyEnabled true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 
       'proguard-rules.pro' 
    } 
    release { 
     shrinkResources true 
     minifyEnabled true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
compile 'com.android.support:appcompat-v7:24.2.1' 
compile 'com.android.support:support-v4:24.2.1' 
compile 'com.android.support:design:25.0.0' 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:gridlayout-v7:25.0.0' 
compile 'com.google.code.gson:gson:2.6.2' 
compile 'com.android.volley:volley:1.0.0' 
compile group: 'com.koushikdutta.urlimageviewhelper', name: 'urlimageviewhelper', version: '1.0.4'} 

そして、私のproguard-rules.pro:

-keepattributes Signature 
-keepattributes *Annotation* 
-keep class sun.misc.Unsafe { *; } 
-keep class com.google.gson.examples.android.model.** { *; } 
-keepclassmembers class com.zztprojects.curlife { 
public *; 
} 

ここに私のプロジェクトの構造である:私は、私はこの問題を解決するのに役立ち、 project's structure

してください私はStackOverflowで見つけた多くのものを試してみました。

EDIT: HomeActivityから私のヌル:

private void publishProgressEvents(final Event mEvent) { 
    runOnUiThread(new Runnable() { 
     LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     LinearLayout layout = null; 
     LinearLayout container = null; 
     ImageView logo = null; 
     TextView name = null; 
     TextView timePlace = null; 
     String timePlaceInfo; 
     TextView description = null; 
     LinearLayout list = (LinearLayout) findViewById(R.id.listEventsHome); 
     Events event; 
     ImageView photo; 
     @Override 
     public void run() { 
     ... 
     container.setOnClickListener(new View.OnClickListener() { 
       @Override 
       public void onClick(View view) { 
        if(event.eventUrl != "" && event.eventUrl != null) { 
         goToUrlOfEvent(event.eventUrl); 
        } 
       } 
      }); 

EDIT2:今すぐエラーがこの行を示しています

  for (int counter = 0; counter < Integer.parseInt(number.number); counter++) { 

EDIT3:マイEventsNumberクラス:

private class EventsBumber { 
    @SerializedName("number") 
    Integer number; 
} 
+2

'はNumberFormatException:無効INT:この例外は、あなたの' HomeActivity.java'ファイルに投げているように見えます "ヌル" 'ショーコード –

+2

。あなたはそれを共有できますか? –

+0

@IntelliJAmiya問題を引き起こすHomeActicityの具体的な行はありません。 – h3wro

答えて

0

私が持っていましたこの行を追加するだけです の前に 最後に、この断片:

@SerializedName("number") 
    Integer number; 
関連する問題