иначе, если условия не выполняются в цикле for после minifyenable true в режиме выпуска даже с использованием правил proguard - PullRequest
0 голосов
/ 21 сентября 2019

Я разрабатываю приложение для Android, которое помогает узнать всю информацию о погоде.Я получаю все данные в формате .json, используя Android Volley, но после этого собирает данные в JsonArray.Когда я использую minifyEbnable false в режиме выпуска bulidType, он работает должным образом и отображает данные в программе восстановления, но после использования minifyEnable true возникает проблема.В секции for loop без проверки 4 типа else, если условия пропускаются, а представление переработчика не обновляется.

Вот мой proguard.pro файл

-keep class com.test123.example.wetherinfo.myapplication.** {*;}
-keepattributes Signature
-dontoptimize`enter code here`
-dontpreverify
-allowaccessmodification

-keepattributes *Annotation*


# Support library
-dontwarn android.support.**
-dontwarn android.support.v4.**
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.** { *; }
-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }

# support design
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }


# Keep these for GSON and Jackson
-keepattributes Signature
-keepattributes *Annotation*
-keepattributes EnclosingMethod
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.** { *; }



# Crashlitycs 2.+
-keep class com.crashlytics.** { *; }
-keep class com.crashlytics.android.**
-keepattributes SourceFile, LineNumberTable, *Annotation*
# If you are using custom exceptions, add this line so that custom exception types are skipped during obfuscation:
-keep public class * extends java.lang.Exception
# For Fabric to properly de-obfuscate your crash reports, you need to remove this line from your ProGuard config:
# -printmapping mapping.txt

# Picasso
-dontwarn com.squareup.okhttp.**

# Volley
-keep class com.android.volley.toolbox.ImageLoader { *; }

# OkHttp3
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

#Glide Image Loading

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class * extends com.bumptech.glide.module.AppGlideModule {
 <init>(...);
}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

# Uncomment for DexGuard only
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule

# Needed for Parcelable/SafeParcelable Creators to not get stripped
-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}


Вот мой bulidType раздел:

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

        debug
        {
            debuggable true
            minifyEnabled false
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

Вот мой фактический код:


 try
    {

    jsonObject = new JSONObject(response);
    dataarrArray = jsonObject.getJSONArray("data_info");

//here collecting all data in JsonArray....
// at this stage dataarray.length > 0

        for(i=0;i<dataarrArray.length();i++)
            {

// at this stage also dataarray.length > 0 but i observed that it's itterate only one time

    dataobj = dataarrArray.getJSONObject(i);

// at this stage also dataarray.length > 0 and pass obove condiion

                             if(!dataobj.has("city") && dataobj.has("timestamp") && dataobj.has("cntry_name") && dataobj.has("cntry_id") && dataobj.has("direction") && dataobj.has("temp") && dataobj.has("summary") )
                            {
                               //not get excute even condition is true                                
                                mWhetherEntry = new WhetherEntry(dataobj.getInt("timestamp"),dataobj.getString("cntry_name"),"",dataobj.getString("cntry_id"),dataobj.getString("direction"),dataobj.getString("temp"),dataobj.getString("fad")+" F",dataobj.getString("kel")+" K","","","","","","");
                                applications.add(mWhetherEntry);
                            }
                         //


                            else if(dataobj.has("city") && dataobj.has("timestamp") && dataobj.has("cntry_name") && dataobj.has("cntry_id") && dataobj.has("direction") && !dataobj.has("temp") && !dataobj.has("summary") && !dataobj.has("status_card"))
                            {
                               //not get excute even condition is true
                                mWhetherEntry = new WhetherEntry(dataobj.getInt("timestamp"),dataobj.getString("cntry_name"),dataobj.getString("cntry_id"),"","","","","","","","","","","");
                                applications.add(mWhetherEntry);
                            }

** unreachable stage exit from for loop

            }
// unreachable stage 

            mRecycleitemadpter.notifyDataSetChanged();

 unreachable stage and not upadating recycler view
    }


          catch (JSONException e)
            {
                e.printStackTrace();
            }



Почему цикл не выполняется после minifyEnable true ....?

Я жду вашей помощи .. Заранее спасибо -:) -:)

...