Issue
My application works fine before, but after enabling ProGuard in my project the application crash immediately in both 'release' and 'debug' apk. I also disable proguard and try it again and it works.
Now my question is how to use jdbc as well as proguard in my project, is it possible?
Here's what on my debug
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.example.aileen.rotaractclub, PID: 6131
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ExceptionInInitializerError
at com.b.a.bq.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:179)
at java.sql.DriverManager.getConnection(DriverManager.java:213)
at com.example.aileen.rotaractclub.b.a.a(Unknown Source)
at com.example.aileen.rotaractclub.b.a$c.a(Unknown Source)
at com.example.aileen.rotaractclub.b.a$c.doInBackground(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class java.lang.String, int, class java.util.Properties, class java.lang.String, class java.lang.String]
at com.b.a.o.<clinit>(Unknown Source)
at com.b.a.bq.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:179)
at java.sql.DriverManager.getConnection(DriverManager.java:213)
at com.example.aileen.rotaractclub.b.a.a(Unknown Source)
at com.example.aileen.rotaractclub.b.a$c.a(Unknown Source)
at com.example.aileen.rotaractclub.b.a$c.doInBackground(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoSuchMethodException: <init> [class java.lang.String, int, class java.util.Properties, class java.lang.String, class java.lang.String]
at java.lang.Class.getConstructor(Class.java:528)
at java.lang.Class.getConstructor(Class.java:492)
at com.b.a.o.<clinit>(Unknown Source)
at com.b.a.bq.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:179)
at java.sql.DriverManager.getConnection(DriverManager.java:213)
at com.example.aileen.rotaractclub.b.a.a(Unknown Source)
at com.example.aileen.rotaractclub.b.a$c.a(Unknown Source)
at com.example.aileen.rotaractclub.b.a$c.doInBackground(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Here's my AsyncTask
//Deleting Announcement
public class deleting extends AsyncTask<String,String,String> {
Boolean Connection = false;
Boolean isSuccess = false;
ProgressDialog progress;
String title;
String ids;
public deleting(String aydi,String titulo)
{
ids=aydi;
title =titulo;
}
@Override
protected void onPreExecute()
{
super.onPreExecute();
progress = new ProgressDialog(getActivity());
progress.setTitle("Synchronizing");
progress.setMessage("Removing '"+ title +"'\n announcement please wait...");
progress.setIndeterminate(false);
progress.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
progress.show();
progress.setCancelable(false);
}
@Override
protected String doInBackground(String... params) {
try {
try {
connection = connectionclass(secured_Pref.getString("server",""), secured_Pref.getString("user",""), secured_Pref.getString("pass",""));
if (connection == null) {
Connection = false;
}
else
{
Connection = true;
PreparedStatement statement = connection.prepareStatement("DELETE FROM Announcements WHERE ID='"+this.ids.toString()+"' AND Title='"+this.title.toString()+"'");
long i =statement.executeUpdate();
try {
if (i>0)
{
isSuccess = true;
} else {
isSuccess = false;
}
connection.close();
} catch (Exception x) {
Toast.makeText(getActivity(), "Error Occur.", Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e)
{
e.printStackTrace();
Toast.makeText(getActivity(), "Error Occur.", Toast.LENGTH_SHORT).show();
}
} catch (Exception ex) {
isSuccess = false;
}
return null;
}
@Override
protected void onPostExecute(String r) {
super.onPostExecute(r);
if (Connection)
{
Toast.makeText(getActivity(),"Successfully Connected.",Toast.LENGTH_LONG).show();
}
else if(Connection==false)
{
Toast.makeText(getActivity(),"No Internet Connection.",Toast.LENGTH_LONG).show();
}
if (isSuccess)
{
Snackbar.make(getView(), "Announcement is Successfully Removed.", Snackbar.LENGTH_LONG).show();
//Refresh my fragment
FragmentTransaction refresh = getFragmentManager().beginTransaction();
refresh.detach(ViewAnnounce.this).attach(ViewAnnounce.this).commit();
}
else
{
Snackbar.make(getView(), "Oops! Error Occur.", Snackbar.LENGTH_LONG).show();
}
progress.dismiss();
}
}
ProGuard Rule
-ignorewarnings
# Basic ProGuard rules for Firebase Android SDK 2.0.0+
-keep class com.firebase.** { *; }
-keep class org.apache.** { *; }
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class javax.servlet.** { *; }
-keepnames class org.ietf.jgss.** { *; }
-dontwarn org.apache.**
-dontwarn org.w3c.dom.**
-renamesourcefileattribute SourceFile
-keep public class * extends android.app.Application
-optimizationpasses 5
-keepattributes *Annotation*,EnclosingMethod
in my Gradle
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Solution
Already fixed by including this rule to my proguard
-dontshrink
Answered By - user9113430
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.