In my app I use a custom image view from exetrnal jar library. And if I enable proguard, I get exception:
java.lang.RuntimeException: Unable to start activity ComponentInfo{eu.example.testapp/eu.example.testapp.ui.activities.DetailsActivity_}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Binary XML file line #0: Error inflating class fr.idapps.image.IDAppsImageView
in the proguard-android.txt I tried to put:
-keep class fr.idapps.** { *; }
-keep class fr.idapps.image.** { *; }
-keep public class * extends android.widget.ImageView
-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*(...);
}
but nothing helps. I also tried to move this class from the library to my code. Even in this case I got the same error.
Here is the place where this class is inflated:
<eu.example.testapp.ui.views.LocationItem xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/item_background"
android:orientation="vertical"
android:paddingBottom="#dimen/margin_medium" >
<!-- Header -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#color/light_anthracite"
android:padding="#dimen/margin_small"
android:layout_marginBottom="#dimen/margin_medium" >
<ImageView
android:id="#+id/view_location_item_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:src="#drawable/ic_detail_location" />
<TextView
android:id="#+id/view_location_item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/view_detail_item_title_location"
android:paddingLeft="#dimen/margin_medium" />
</LinearLayout>
<fr.idapps.image.IDAppsImageView
android:id="#+id/view_location_item_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/margin_medium"
android:paddingRight="#dimen/margin_medium"
app:imageRatio="preserve" />
</eu.example.testapp.ui.views.LocationItem>
EDIT: I use the last gradle version and enable proguard in this way:
buildTypes {
release {
minifyEnabled true // enables/disables proguard
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "Test-v${variant.versionName}-v${variant.versionCode}.apk"
}
}
}
}
So you need to add your custom class (which having in your package) into proguard-project.txt :-
-keep public class com.abc.xyz
and unable to see that your not include eu.example.testapp.ui.views.LocationItem
Related
I want to play two videos on a screen.But when I play one video the other video get stopped. Anyone knows how can I solve this problem?
In my gradle,
implementation 'cn.jzvd:jiaozivideoplayer:7.7.0'
In my XML,
<cn.jzvd.JzvdStd
android:id="#+id/jzVideo"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<cn.jzvd.JzvdStd
android:id="#+id/jzVideo2"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="5dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/jzVideo"/>
in my activty,
JzvdStd jzvdStd = findViewById(R.id.jzVideo);
JzvdStd jzvdStd2 =findViewById(R.id.jzVideo2);
and setUp link after initialization.
in my proguard-rules.pro
-keep public class cn.jzvd.JZMediaSystem {*; }
-keep public class cn.jzvd.demo.CustomMedia.CustomMedia {*; }
-keep public class cn.jzvd.demo.CustomMedia.JZMediaIjk {*; }
-keep public class cn.jzvd.demo.CustomMedia.JZMediaSystemAssertFolder {*; }
-keep class tv.danmaku.ijk.media.player.** {*; }
-dontwarn tv.danmaku.ijk.media.player.*
-keep interface tv.danmaku.ijk.media.player.** { *; }
My app crashes when I run my app after minifyEnabled true.
The error I am getting after running the app is this
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.instant/com.example.instant.activity.IntroActivity}: android.view.InflateException: Binary XML file line #56 in com.example.instant:layout/activity_intro: Binary XML file line #56 in com.example.instant:layout/activity_intro: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3304)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3443)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7520)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: android.view.InflateException: Binary XML file line #56 in com.example.instant:layout/activity_intro: Binary XML file line #56 in com.example.instant:layout/activity_intro: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
Caused by: android.view.InflateException: Binary XML file line #56 in com.example.instant:layout/activity_intro: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
This is my progaurd file
-keep class com.google.gson.** { *; }
-keep class com.smsdaakindia.instantpay.utils.** { *; }
-keep class com.smsdaakindia.instantpay.model.** { *; }
-keep class com.google.android.material.** { *; }
#-dontwarn com.google.android.material.**
#Material design
#-dontnote com.google.android.material.**
-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }
-dontwarn com.google.android.material.**
-dontnote com.google.android.material.**
-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }
# RETRO LAMBDA
-dontwarn java.lang.invoke.*
# RETROFIT RULES
-keep class com.squareup.** { *; }
-keep interface com.squareup.** { *; }
-dontwarn com.squareup.okhttp.**
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {#retrofit.http.* <methods>;}
-keep interface retrofit.** { *;}
-keep interface com.squareup.** { *; }
-dontwarn rx.**
-dontwarn retrofit.**
-keep class com.google.gson.* { *; }
-keep class com.google.inject.* { *; }
-keep class org.apache.http.* { *; }
-keep class org.apache.james.mime4j.* { *; }
-keep class javax.inject.* { *; }
-keep class retrofit.* { *; }
-keepattributes Signature
-keepattributes *Annotation*
-keepattributes EnclosingMethod
This is my dependencyimplementation 'com.google.android.material:material:1.0.0
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="bottomNavigationHandler"
type="com.example.instant.viewmodel.BottomNavigationHandler" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/navigationParent"
android:orientation="vertical">
<FrameLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<LinearLayout
android:id="#+id/navigationParent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:orientation="vertical">
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="0.01dp"
android:layout_above="#+id/navigation"
android:background="#color/grey_100"
android:elevation="1dp" />
<!-- <include-->
<!-- layout="#layout/bottom_bar"-->
<!-- android:id="#+id/bottom" />-->
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:showAsAction="always|withText"
app:labelVisibilityMode="labeled"
app:itemTextColor="#drawable/bottom_view"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/bottom_nav_items"
android:background="#color/white"
app:onNavigationItemSelected="#{bottomNavigationHandler::onNavigationClick}"
app:elevation="0dp"/>
<!-- <com.google.android.material.bottomnavigation.BottomNavigationView-->
<!-- android:id="#+id/navigation"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="52dp"-->
<!-- android:background="#color/lightgrey"-->
<!-- android:visibility="visible"-->
<!-- android:showAsAction="always|withText"-->
<!-- app:itemBackground="#color/lightlightgrey"-->
<!-- app:itemIconTint="#drawable/bottom_view"-->
<!-- app:itemTextAppearance="#style/TextStyleBNV"-->
<!-- app:itemTextColor="#drawable/bottom_view"-->
<!-- app:labelVisibilityMode="labeled"-->
<!-- app:menu="#menu/bottom_nav_items"-->
<!-- app:onNavigationItemSelected="#{bottomNavigationHandler::onNavigationClick}" />-->
</LinearLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
I'm working on an Android application in Android Studio and I'm struggling to get my new fragment to display. In the logcat I see an error but I'm not sure what it means and can't find the answer to this issue anywhere else. I'm not sure if I'm making other errors in trying to set up this fragment.
I've tried only adding the fragment programmatically but found other examples on YouTube of adding the fragment to XML so I've tried that too and it didn't work either. I've been trying to work this out for days so any help would be greatly appreciated.
I tried starting the new fragment using fragmentTransaction.add and fragmentTransaction.replace with no difference.
Here is the main class
public class Dashboard extends AppCompatActivity {
Button menuButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
menuButton = (Button) findViewById(R.id.menu_button);
menuButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startClassMenu();
}
});
}
public void startClassMenu(){
Fragment classMenuFragment = new ClassMenuFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.class_menu_fragment_place, classMenuFragment);
fragmentTransaction.commit();
}
}
Here is the main class xml
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme" />
<Button
android:id="#+id/menu_button"
android:layout_width="40dp"
android:layout_height="34dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="21dp"
android:layout_marginLeft="21dp"
android:layout_marginTop="82dp"
android:background="#drawable/icon_blue_menu" />
<Button
android:id="#+id/home_button"
android:layout_width="40dp"
android:layout_height="38dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="6dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:background="#drawable/home_icon" />
<Button
android:id="#+id/settings_button"
android:layout_width="37dp"
android:layout_height="33dp"
android:layout_alignBottom="#+id/menu_button"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="100dp"
android:layout_marginRight="100dp"
android:layout_marginBottom="72dp"
android:background="#drawable/icon_settings" />
<fragment
android:id="#+id/class_menu_fragment_place"
android:name="teamingenium.ingeniummobileapplication.fragments.ClassMenuFragment"
android:layout_width="177dp"
android:layout_height="187dp"
android:layout_alignEnd="#+id/menu_button"
android:layout_alignParentTop="true"
android:layout_marginTop="135dp"
android:layout_marginEnd="-127dp" />
Here is the fragment Java class
public class ClassMenuFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View view = inflater.inflate(R.layout.fragment_class_menu, container, false);
return view;
}
}
And here is the fragment xml class
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.ClassMenuFragment"
android:id="#+id/fragment_class_menu">
<TextView
android:id="#+id/fragment_class_menu_text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:text="Fragment Started" />
</FrameLayout>
Here is the error from logcat
2018-12-29 20:09:48.405 1925-1925/system_process E/LoadedApk: Unable to instantiate appComponentFactory
java.lang.ClassNotFoundException: Didn't find class "android.support.v4.app.CoreComponentFactory" on path: DexPathList[[],nativeLibraryDirectories=[/system/priv-app/GoogleSdkSetup/lib/x86, /system/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.LoadedApk.createAppFactory(LoadedApk.java:226)
at android.app.LoadedApk.updateApplicationInfo(LoadedApk.java:338)
at android.app.ActivityThread.handleDispatchPackageBroadcast(ActivityThread.java:5388)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1733)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at com.android.server.SystemServer.run(SystemServer.java:454)
at com.android.server.SystemServer.main(SystemServer.java:294)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:838)
refer to this link fragment;
As you use <fragment in your layout xml, you have no need to invoke startClassMenu() ,just to delete the startClassMenu() method and try again.
Try other two methods:
1, try to use android.app.Fragment and android.app.FragmentManager and android.app.Activity instead of using support library.
2, try to add -keep public class * extends android.support.v4.** in your proguard-rules.pro file
Try these
After checking this "DexPathList", it is definitely due to dexes.
multidex increases the number of methods
The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536
This error can be caused due to using both androidx and legacy android support libraries
Just open project structure and go to Dependencies and select All Modules and check is there any library which contains android.support
Just replace that with androidx version for that library
If still that issue exists then
Try these to fix this issue
dependencies {
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
}
in the latest versions of android studio, just REMOVE these lines if it is there inside the manifest file
<application
...
tools:replace="android:appComponentFactory" // REMOVE THIS
android:appComponentFactory="androidx" // REMOVE THIS
>
Check for this line
defaultConfig {
...
multiDexEnabled true
}
Add this line in your MainActivity.kt
class MyApplication : Application() {
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
MultiDex.install(this) //ADD THIS
}
}
Add this in your proguard-rules.pro file
-keep class com.example.** { *; }
Verify in this
buildTypes {
dev{
minifyEnabled false
}
release {
minifyEnabled true
}
}
In latest version of android studio there is no instant run disable options
Now android studio requires jdk versions above 8 so NO NEED TO ADDING THIS
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
I have inserted code AdMob ads, but it does not show on my phone (I do not run on the shirt). I have not published app on the store.
In AndroidManifest file
Code in layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/gameover"
android:orientation="vertical"
android:paddingLeft="7dp"
android:paddingRight="7dp"
android:background="#color/bgend" >
<Button
android:id="#+id/btnBackhome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/yourBest"
android:layout_marginBottom="80dp"
android:layout_marginRight="48dp"
android:background="#drawable/rate" />
<Button
android:id="#+id/btnReplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/btnBackhome"
android:layout_alignLeft="#+id/yourBest"
android:layout_marginLeft="34dp"
android:background="#drawable/play" />
<TextView
android:id="#+id/yourBest"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/yourMove"
android:layout_alignTop="#+id/yourMove"
android:layout_marginTop="39dp"
android:gravity="center"
android:text="Best: "
android:textColor="#android:color/white"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="#+id/yourMove"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/Replay"
android:layout_alignParentRight="true"
android:layout_marginBottom="74dp"
android:gravity="center"
android:text="New: "
android:textColor="#android:color/white"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/Best"
android:layout_alignLeft="#+id/Move"
android:layout_marginBottom="14dp"
android:gravity="center"
android:text="Game Over"
android:textColor="#android:color/white"
android:textSize="30sp"
android:textStyle="bold" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-........"
/>
</RelativeLayout>
Code gameover.java. I removed the command line to test the virtual machine
package com.vudinh.eastmath;
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
public class GameOverActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.game_over);
// TODO Auto-generated constructor stub
AdView adView = (AdView) this.findViewById(R.id.adView);
//request TEST ads to avoid being disabled for clicking your own ads
AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)// This is for emulators
// .addTestDevice("2EAB96D84FE62876379A9C030AA6A0AC")
.build();
adView.loadAd(adRequest);
}
}
Proguard file:
-dontwarn **CompatHoneycomb
-keep class android.support.v4.** { *; }
-dontwarn android.support.v4.**
-dontskipnonpubliclibraryclassmembers
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-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 class com.startapp.** {
*;
}
-keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile,
LineNumberTable, *Annotation*, EnclosingMethod
-dontwarn android.webkit.JavascriptInterface
-dontwarn com.startapp.**
-keep class javax.** { *; }
-keep class org.** { *; }
-keep class twitter4j.** { *; }
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembers class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
There doesn't appear to be anything wrong with your code.
Have a look at your log, you should see there the ad request and response.
If there are no ads to show, you will see that in the logs, but nothing will be display on the screen.
The problem occurs only when built with proguard + gradle. If exported from android tools and proguard - all references are mapped correctly.
Problem:
I have defined some id's in a library project
<resources>
<item type="id" name="background" />
</resources>
And the activity layout is in main project
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/splash"
tools:ignore="ContentDescription" />
The NullPointer after being built with proguard is thrown at main project's Activity
this.findViewById(R.id.background).setOnClickListener(new View.OnClickListener() {
Don't suggest me redefining id's because it's a wrong approach and crashes anyway.
android:id="#+id/background"
UPDATE: it turns out it messes even id's defined in layout of main project like
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/backgroundTEST"/>
Also crashes with NullPointerException.I thought it was because of library project because the very first one that fails was one from a library project.
The configuration is as follows
The $ANDROID_HOME/tools/proguard/proguard-android.txt is
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-dontoptimize
-dontpreverify
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-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>;
}
-dontwarn android.support.**
The proguard-project.txt for my project
-injars bin/classes
-injars libs
-outjars bin/classes-processed.jar
-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.support.v4.app.FragmentActivity
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
From build.gradle
buildTypes {
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android.txt')
proguardFile 'proguard-project.txt'
signingConfig signingConfigs.release
}
}
My concern was, maybe it does not include getDefaultProguardFile('proguard-android.txt').
Well, for an experiment I've copy-pasted proguard-android.txt contents to proguard-project.txt And still after
gradle clean
gradle assembleRelease
it crashed.
I have that in my Proguard config to cater for R class
-keepclassmembers class **.R$* {
public static <fields>;
}
Try adding the following as well:
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}