I was applying a proguard.
The application is quite large, but the apk build took too long.
(:app:transformClassesAndResourcesWithProguardForDebug 1h 15m 48s 816ms)
And eventually I had to stop.
My 'proguard-rules' are as follows, I want to know the cause.
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-dontoptimize
-dontpreverify
-dontshrink
-keepattributes *Annotation*
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keepattributes Exceptions,InnerClasses,Deprecated,EnclosingMethod
-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
-libraryjars libs
-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);
}
-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.**
-keepclassmembers class * {
#com.google.api.client.util.Key <fields>;
}
-keep class com.google.api.services.*.model.*
-keep class com.google.api.client.**
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault
-dontwarn com.google.common.collect.MinMaxPriorityQueue
-dontobfuscate
-dontwarn com.google.android.analytics.**
-dontwarn com.google.common.**
-keep class com.google.common.collect.MapMakerInternalMap$ReferenceEntry
-keep class com.google.common.cache.LocalCache$ReferenceEntry
-keep class com.google.analytics.tracking.android.CampaignTrackingReceiver
-keep class * extends java.util.ListResourceBundle {
protected java.lang.Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keep class com.google.android.gms.** { *;}
-keep class com.google.gson.** { *;}
-keepnames #com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
#com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep class com.crashlytics.** { *; }
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }
-keepclasseswithmembernames class * {
#butterknife.* <fields>;
}
-keepclasseswithmembernames class * {
#butterknife.* <methods>;
}
-keep class com.android.volley.** { *; }
-keep interface com.android.volley.** { *; }
-keep class org.apache.commons.logging.Log
-keepclassmembers class * {
#android.webkit.JavascriptInterface <methods>;
}
-keep class com.kbeanie.** { *; }
-keep class com.sromku.simple.fb.** {
*;
}
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.facebook.** { *; }
-keep class io.card.** { *; }
-keep class com.androidquery.** { *; }
-keep class pl.tajchert.buswear.** { *; }
-keep class pl.tajchert.buswear.wear.** { *; }
-keep class com.viewpagerindicator.** {*; }
-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
-keep class com.squareup.** {*; }
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep class com.kakao.** { *; }
-keepattributes Signature
-keepclassmembers class * {
public static <fields>;
public *;
}
-dontwarn android.support.v4.**
-dontwarn com.ning.http.client.**
-dontwarn org.jboss.netty.**
-dontwarn org.slf4j.**
-dontwarn com.fasterxml.jackson.databind.**
-dontwarn com.google.android.gms.**
-keep class sun.misc.Unsafe { *; }
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
-keepclassmembers class com.samsung.** { *; }
-keep class com.samsung.** { *; }
-dontwarn com.samsung.**
-keep class myApp.** { *; }
-dontwarn io.airbridge.**
-keep class io.airbridge.** {*;}
-keepattributes Signature
-keepattributes *Annotation*
-keep class sun.misc.Unsafe { *; }
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep class bo.app.** { *; }
-keep class com.appboy.** { *; }
-dontwarn kotlin.**
-keepnames class com.google.android.gms.common.GoogleApiAvailability
-dontwarn com.appsflyer.**
-dontwarn com.android.installreferrer
-keep public class com.google.firebase.iid.FirebaseInstanceId {
public *;
}
-keep public class com.google.android.gms.iid.InstanceID {
public *;
}
And there are a lot of unresolved resources inside the app.
help..
Self answer
I just wanted that finish the app build. And I can write the "dontwarn **".
then I could see the optimize performance of proguard.
after write "dontwarn **", check the each classes.
I hope that these stupid questions and answers will help you. :)
Related
I am using JPA with QueryDSL.
Here are my entities with single table inheritance strategy.
#Entity
#Inheritance(strategy = InheritanceType.SINGLE_TABLE)
#DiscriminatorColumn(name = "type")
public abstract class Parent {
private int parentId;
private LocalDateTime createdAt;
...
}
#Entity
#DiscriminatorValue("a")
public class A extends Parent {
...
}
#Entity
#DiscriminatorValue("b")
public class B extends Parent {
...
}
#Entity
#DiscriminatorValue("c")
public class C extends Parent {
...
}
I have to write a query with QueryDSL that inquires A and B in order of createdAt value.
If I can't do this with QueryDSL what can I do?
I am creating the WebApplication, with many layers (for now important are Model, Repository, BusinessLayer)
Having ClassService, ClassRepository and StudentService, StudentRepository, should ClassServiceMethod call methods from StudentService or StudentRepository?
Please provide as many arguments or additional links/blogs/informations as possible :)
Thanks in advance.
Here is my example code, some generics are added. The question is about GetClassAndBestStudent method:
Services - Business Layer
public class ClassService : BaseService<Class>, IClassService
{
IClassRepository classRepository; // Resolved by IoC, will be injected to BaseService
IStudentRepository studentRepository;
IStudentService studentService;
public virtual Class GetClassWithHighestNotes() { ... } // Do some stuff and call classRepository.GetClassWithHighestNotes()
public virtual Teacher GetTeachersByClass(int classId) { ... } // Do some stuff and call classRepository.GetTeachersByClass()
public virtual GetClassAndBestStudent(int classId)
{
// Question here: Which call is valid?
var best = studentRepository.GetStudentWithHighestNotes()
var best = studentService.GetStudentWithHighestNotes();
}
}
public class StudentService : BaseService<Student>, IStudentService
{
IStudentRepository studentRepository; // Resolved by IoC, will be injected to BaseService
public virtual IEnumerable<Student> GetStudentsByClass(int classId) { ... } // Do some stuff and call studentRepository.GetStudentsByClass()
public virtual Student GetStudentWithHighestNotes() { ... } // Do some stuff and call studentRepository.GetStudentWithHighestNotes()
}
// Abstract, generic CRUD service
public abstract class BaseService<T> : IBaseService<T> where T : MyBase
{
IRepository<T> repository;
public virtual IEnumerable<T> GetAll() { ... } // Do some stuff and call repository.GetAll()
public virtual T GetById(int id) { ... } // Do some stuff and call repository.GetById()
public virtual T Insert(T entity) { ... } // Do some stuff and call repository.Insert()
public virtual T Update(T entity) { ... } // Do some stuff and call repository.Update()
public virtual bool Delete(T entity) { ... } // Do some stuff and call repository.Delete()
public virtual bool Delete(int id) { ... } // Do some stuff and call repository.Delete()
}
Repositories - Data Layer
public class ClassRepository : BaseRepository<Class>, IClassRepository
{
public virtual Class GetClassWithHighestNotes() { ... }
public virtual Teacher GetTeachersByClass(int classId) { ... }
}
public class StudentRepository: BaseRepository<Student> IStudentRepository
{
public virtual IEnumerable<Student> GetStudentsByClass(int classId) { ... }
public virtual Student GetStudentWithHighestNotes() { ... }
}
// Abstract, generic CRUD repository
public abstract class BaseRepository<T> : IRepository<T> where T : MyBase
{
public virtual IEnumerable<T> GetAll() { ... }
public virtual T GetById(int id) { ... }
public virtual T Insert(T entity) { ... }
public virtual T Update(T entity) { ... }
public virtual bool Delete(T entity) { ... }
public virtual bool Delete(int id) { ... }
}
The best practice is calling StudentService from ClassServiceMethod. If the implementation in StudentRepository changes in the future, you can create another repository method like StudentRepositoryNew and utilize the same StudentService.
I have a class which has 2 methods. Each method is having a group associated.
Now I want to set my testng.xml file in such a way that when testcase TC1 executes, Method1() and then Method2() will be called and when testcase TC2 will be executed, Method2() and then Method1() will be executed.
Is there any way by which I can do that?
You can move your test case methods to a helper class and then simply create a test class for each test case, define your methods with their test priorities and/or dependencies, and call your shared test method code. e.g.:
public class TestCaseMethods {
public static void method1() { /*...*/ }
public static void method2() { /*...*/ }
}
public class TC1 {
#Test
public void method1() {
TestCaseMethods.method1();
}
#Test(dependsOnMethods = {"method1"})
public void method2() {
TestCaseMethods.method2();
}
}
public class TC2 {
#Test(dependsOnMethods = {"method2"})
public void method1() {
TestCaseMethods.method1();
}
#Test
public void method2() {
TestCaseMethods.method2();
}
}
You can also use inheritance if you prefer:
public class AbstractTC {
public void method1() { /*...*/ }
public void method2() { /*...*/ }
}
public class TC1 extends AbstractTC {
#Override
#Test
public void method1() {
super.method1();
}
#Override
#Test(dependsOnMethods = {"method1"})
public void method2() {
super.method2();
}
}
public class TC2 extends AbstractTC {
#Test(dependsOnMethods = {"method2"})
public void method1() {
super.method1();
}
#Test
public void method2() {
super.method2();
}
}
I have base class for my services. Attribute OperationBehavior doesn't apply if it defined in base class and I override method in derived class. Of cause, I can duplicate code, but maybe there is other way...
[ServiceContract]
public interface IMyService
{
[OperationContract]
void DoWork();
}
public class MyServiceBase
{
[OperationBehavior(TransactionScopeRequired = true)]
public virtual void DoWork()
{
}
}
public class MyService : MyServiceBase, IMyService
{
public override void DoWork()
{
//No Transaction, because attribute OperationBehavior doesn't apply.
}
}
You will need to do something like the following:
public class MyServiceBase
{
[OperationBehavior(TransactionScopeRequired = true)]
public void DoWork()
{
DoWorkImpl();
}
protected virtual DoWorkImpl()
{
}
}
public class MyService : MyServiceBase, IMyService
{
protected override void DoWorkImpl()
{
//Should have a Tx here now
}
}
I have abstract class Vehicle and two classes that derive from: Car and ForkLift.
public abstract class Vehicle
{
public EngineBase Engine { get; set; }
}
public class Car : Vehicle
{
public GasEngine Engine { get; set; }
}
public class ForkLift : Vehicle
{
public ElectricEngine Engine { get; set; }
}
and Engine clasess:
public abstract class EngineBase
{
}
public class GasEngine : EngineBase
{
}
public class ElectricEngine : EngineBase
{
}
Engines are mapped with "table per class hierarchy". With Vehicles I want to use the same pattern.
How to map Engine class and derived with that Engine property?
How to do it with lazy-loading?
That code does not compile, which makes it improbable that you can map it.
Use a protected field in Vehicle and map it with an access strategy:
public abstract class Vehicle
{
protected Engine _engine;
}
In Fluent NHibernate this would be mapped:
References(x => x.Engine, "EngineId").Access.CamelCaseField(Prefix.Underscore);
Then the classes that extend Vehicle can cast it as needed:
public class Car : Vehicle
{
public GasEngine
{
get { return (GasEngine)_engine; }
set { _engine = Value; }
}
}