2
java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View] 

Android app only crashes if i am testing it with production release version, but debug testing version works fine.

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.config
        debuggable false
    }
7
  • Do you use proguard for release verrsion? Commented Mar 5, 2017 at 14:13
  • Well, can you show some more code? Commented Mar 5, 2017 at 14:15
  • Error comes when the RecyclerView loads by populating data from firebase database. Commented Mar 5, 2017 at 14:18
  • I am not sure which part of the code should i include here. Commented Mar 5, 2017 at 14:19
  • Do you use proguard for release verrsion? Commented Mar 5, 2017 at 14:22

2 Answers 2

1

Possible Proguard is obfuscation some of your files,

Why dont you update your gradle file and set this value to false

 minifyEnabled false

Rebuild a release apk and check. Do let me know if you need an explaination.

Note: Removing proguard is not the solution to your problem. This will just help you run your code. You should check on the proguard issue as well.

Sign up to request clarification or add additional context in comments.

5 Comments

HI, It Worked!! Thank you. i released a version with minifyEnabled false
May know the significance of it? just for a knowledge.
@lalitsonawane Yes it will, but removing proguard is not a solution. Please refer the proguard doc here and also refer to roshan's answer.
Yes why not, Proguard is android's way of protecting the code written from getting reverse engineered. So when you add proguard to your code, your entire code now has ambiguios variable names like ActivityA becomes aA and stuff, which is mapped inside a mapping file, in order for the proguard to work properly you add a rules file to it. Which adds all the various rules to it with the dont-warn , ignore etc keywords. Which make proguard ignore those classes.
so if you want you code to properly work, with proguard you will have to search for all the libraries that you use, add an exception to them in the proguard file.
0

YOu should add default config to your proguard file proguard-android.txt to not obfuscate your View and another types.

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# If you want to enable optimization, you should include the
# following:
# -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
# -optimizationpasses 5
# -allowaccessmodification
#
# Note that you cannot just include these flags in your own
# configuration file; if you are including this file, optimization
# will be turned off. You'll need to either edit this file, or
# duplicate the contents of this file and remove the include of this
# file from your project's proguard.config path property.
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgent
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
    native <methods>;
}
-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
    public static <fields>;
}
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
-dontwarn android.support.**

4 Comments

Yes even this can work. But better if he doesnt mess with Proguard if he's new to programming right?
When you build release version, you need proguard for your code, it has a lot of advantages. developer.android.com/studio/build/shrink-code.html
Yes agreed. even i follow proguard. But let him first know why its happening. Then explain him stuff like Proguard, adding rules etc. And yes 100% agreeing on the fact that proguard is needed.
@MadScientist and better if he doesn't mess with sql injection if he is new too right?... I can't belive what I just read...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.